28 lines
899 B
Go
28 lines
899 B
Go
package governance
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
// TestBootstrapRequiresThePublicOrigin guards the WebAuthn origin without requiring names for built-in rows.
|
|
func TestBootstrapRequiresThePublicOrigin(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
url string
|
|
wantErr error
|
|
}{
|
|
{"https://archie.example.test/", nil},
|
|
{"", ErrInvalidIdentity},
|
|
{"https://archie.example.test/some/path", ErrInvalidIdentity},
|
|
} {
|
|
r := AccountRegistration{PublicURL: tc.url, Email: "owner@example.test", DisplayName: "Owner"}
|
|
role, org, err := registrationScope(t.Context(), &r, true)
|
|
if !errors.Is(err, tc.wantErr) {
|
|
t.Errorf("register with origin %q: %v, want %v", tc.url, err, tc.wantErr)
|
|
}
|
|
if err == nil && (r.PublicURL != "https://archie.example.test" || role != RoleOwner || org != DefaultOrgID) {
|
|
t.Errorf("bootstrap scope = %s/%s, origin = %q", org, role, r.PublicURL)
|
|
}
|
|
}
|
|
}
|