feat: import Sea vHost single-server testing release

This commit is contained in:
canglan committed 2026-10-30 08:39:10 +08:00
commit 248badd33e
441 files changed
+63221

No files matched your search

@@ -0,0 +1,33 @@
package httpapi
import (
"sea-vhost/internal/store"
"testing"
)
func TestOIDCPasswordPolicyDoesNotAffectHosts(t *testing.T) {
off := false
c := secretServiceConfig{UserPasswordLogin: &off, AdminPasswordLogin: &off}
if !oidcPasswordAllowed(c, "host") || oidcPasswordAllowed(c, "admin") || oidcPasswordAllowed(c, "tenant") {
t.Fatal("password policy scope incorrect")
}
if !oidcPasswordAllowed(secretServiceConfig{}, "admin") || !oidcPasswordAllowed(secretServiceConfig{}, "tenant") {
t.Fatal("old settings must preserve password login")
}
}
func TestOIDCProviderIdentityIncludesIssuer(t *testing.T) {
a := oidcProviderKey(secretServiceConfig{Issuer: "https://id.example.com"})
if a != oidcProviderKey(secretServiceConfig{Issuer: "https://id.example.com/"}) || a == oidcProviderKey(secretServiceConfig{Issuer: "https://other.example.com"}) || len(a) > 40 {
t.Fatal("issuer isolation invalid")
}
}
func TestSSOAutomaticCreationRequiresVerifiedEmail(t *testing.T) {
for _, p := range []store.PendingOIDCLogin{{Email: "a@example.com"}, {Email: "not-an-email", EmailVerified: true}, {Email: "Name <a@example.com>", EmailVerified: true}} {
if validSSOEmail(p) {
t.Fatal("untrusted email accepted")
}
}
if !validSSOEmail(store.PendingOIDCLogin{Email: "a@example.com", EmailVerified: true}) {
t.Fatal("verified email rejected")
}
}