This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/auth/mtls_proxy_test.go
Jeffrey Smith f0dd43144e rebrand: Switchboard Core → Armature
- Rename Go module switchboard-core → armature (155+ files)
- Rename Docker image → gobha/armature
- Rename K8s resources, secrets, deployments
- Rename Prometheus metrics switchboard_* → armature_*
- Rename env vars SWITCHBOARD_ADMIN_* → ARMATURE_ADMIN_*
- Rename DB names switchboard_core* → armature*
- Update all frontend branding, notification templates, docs
- Update CI scripts, e2e tests, Keycloak realm, nginx conf
- Rename scripts/switchboard-ca.sh → scripts/armature-ca.sh
- Rename k8s/switchboard.yaml → k8s/armature.yaml
- Rename chart alerting/dashboard files
- Fix: DockerHub push uses env: binding for secret injection
- Helm chart updated (name, labels, template functions, dashboard, alerting)
- Replace favicon/icon assets with Armature brand

No functional changes. Pure mechanical rename + CI fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 21:39:58 +00:00

129 lines
2.9 KiB
Go

package auth
import (
"testing"
"armature/store"
)
func TestParseDN(t *testing.T) {
tests := []struct {
name string
dn string
expect map[string]string
}{
{
name: "standard cert DN",
dn: "CN=Jeff Smith,O=Acme Corp,OU=Engineering",
expect: map[string]string{
"CN": "Jeff Smith",
"O": "Acme Corp",
"OU": "Engineering",
},
},
{
name: "with email",
dn: "CN=Jane Doe,emailAddress=jane@acme.com,O=Acme Corp",
expect: map[string]string{
"CN": "Jane Doe",
"emailAddress": "jane@acme.com",
"O": "Acme Corp",
},
},
{
name: "spaces around equals",
dn: "CN = Test User , O = Test Org",
expect: map[string]string{
"CN": "Test User",
"O": "Test Org",
},
},
{
name: "single field",
dn: "CN=Solo",
expect: map[string]string{
"CN": "Solo",
},
},
{
name: "empty string",
dn: "",
expect: map[string]string{},
},
{
name: "no equals sign",
dn: "garbage,data",
expect: map[string]string{},
},
{
name: "country and state",
dn: "CN=Server,C=US,ST=Maryland,L=Laurel,O=DoD",
expect: map[string]string{
"CN": "Server",
"C": "US",
"ST": "Maryland",
"L": "Laurel",
"O": "DoD",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ParseDN(tt.dn)
for k, want := range tt.expect {
got := result[k]
if got != want {
t.Errorf("ParseDN(%q)[%q] = %q, want %q", tt.dn, k, got, want)
}
}
if len(result) != len(tt.expect) {
t.Errorf("ParseDN(%q) returned %d fields, want %d", tt.dn, len(result), len(tt.expect))
}
})
}
}
func TestMTLSConfig_Defaults(t *testing.T) {
p := NewMTLSProxyProvider(MTLSProxyConfig{})
if p.cfg.HeaderDN != "X-SSL-Client-DN" {
t.Errorf("HeaderDN = %q, want X-SSL-Client-DN", p.cfg.HeaderDN)
}
if p.cfg.HeaderVerify != "X-SSL-Client-Verify" {
t.Errorf("HeaderVerify = %q, want X-SSL-Client-Verify", p.cfg.HeaderVerify)
}
if p.cfg.HeaderFingerprint != "X-SSL-Client-Fingerprint" {
t.Errorf("HeaderFingerprint = %q, want X-SSL-Client-Fingerprint", p.cfg.HeaderFingerprint)
}
}
func TestMTLSConfig_Custom(t *testing.T) {
p := NewMTLSProxyProvider(MTLSProxyConfig{
HeaderDN: "X-Client-Cert-DN",
HeaderVerify: "X-Client-Cert-Verify",
})
if p.cfg.HeaderDN != "X-Client-Cert-DN" {
t.Errorf("HeaderDN = %q, want X-Client-Cert-DN", p.cfg.HeaderDN)
}
}
func TestMTLSProvider_Mode(t *testing.T) {
p := NewMTLSProxyProvider(MTLSProxyConfig{})
if p.Mode() != ModeMTLS {
t.Errorf("Mode() = %q, want %q", p.Mode(), ModeMTLS)
}
}
func TestMTLSProvider_NoRegistration(t *testing.T) {
p := NewMTLSProxyProvider(MTLSProxyConfig{})
if p.SupportsRegistration() {
t.Error("mTLS should not support registration")
}
_, err := p.Register(nil, store.Stores{})
if err != ErrNotSupported {
t.Errorf("Register() = %v, want ErrNotSupported", err)
}
}