mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-10 01:20:58 +01:00
test oidc.use_unverified_email
This commit is contained in:
parent
0b9fdb7a16
commit
6e55e61a1a
@ -291,9 +291,10 @@ func TestCleanIdentifier(t *testing.T) {
|
||||
|
||||
func TestOIDCClaimsJSONToUser(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
jsonstr string
|
||||
want User
|
||||
name string
|
||||
jsonstr string
|
||||
useUnverifiedEmail bool
|
||||
want User
|
||||
}{
|
||||
{
|
||||
name: "normal-bool",
|
||||
@ -348,6 +349,24 @@ func TestOIDCClaimsJSONToUser(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "use-unverified-email",
|
||||
jsonstr: `
|
||||
{
|
||||
"sub": "test-unverified-email",
|
||||
"email": "test-unverified-email@test.no",
|
||||
"email_verified": "false"
|
||||
}
|
||||
`,
|
||||
useUnverifiedEmail: true,
|
||||
want: User{
|
||||
Provider: util.RegisterMethodOIDC,
|
||||
ProviderIdentifier: sql.NullString{
|
||||
String: "/test-unverified-email",
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
// From https://github.com/juanfont/headscale/issues/2333
|
||||
name: "okta-oidc-claim-20250121",
|
||||
@ -458,7 +477,7 @@ func TestOIDCClaimsJSONToUser(t *testing.T) {
|
||||
|
||||
var user User
|
||||
|
||||
user.FromClaim(&got)
|
||||
user.FromClaim(&got, tt.useUnverifiedEmail)
|
||||
if diff := cmp.Diff(user, tt.want); diff != "" {
|
||||
t.Errorf("TestOIDCClaimsJSONToUser() mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user