diff --git a/hscontrol/types/users_test.go b/hscontrol/types/users_test.go index f36489a3..86f68501 100644 --- a/hscontrol/types/users_test.go +++ b/hscontrol/types/users_test.go @@ -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) }