-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Radoslav Dimitrov <[email protected]>
- Loading branch information
Showing
2 changed files
with
3 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -594,36 +594,6 @@ func (_ *SimpleResolver) Validate(_ context.Context, _ jwt.Token) (*auth.Identit | |
panic("unimplemented") | ||
} | ||
|
||
func TestIsSubjectEmail(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
subject string | ||
expected bool | ||
}{ | ||
{"Valid email", "[email protected]", true}, | ||
{"Invalid email missing @", "testexample.com", false}, | ||
{"Invalid email missing domain", "test@", false}, | ||
{"Invalid email missing tld", "test@example", false}, | ||
{"Valid email with subdomain", "[email protected]", true}, | ||
{"Valid email with multiple dots", "[email protected]", true}, | ||
{"Invalid email missing domain and tld", "example@com", false}, | ||
{"Invalid email with spaces", "user @example.com", false}, | ||
{"Invalid email with special characters", "user@exa!mple.com", false}, | ||
{"Invalid email", "91abede98a29dbfec05daa22e2bf80850ba4ca3d209bd78d0f84adc402638446", false}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
result := isEmail(tt.subject) | ||
require.Equal(t, tt.expected, result) | ||
}) | ||
} | ||
} | ||
|
||
// createSignedJWTToken creates a signed JWT token with the specified subject and email. | ||
func createSignedJWTToken(subject, email string, privateKey *rsa.PrivateKey) (string, error) { | ||
token := gojwt.NewWithClaims(gojwt.SigningMethodRS256, gojwt.MapClaims{ | ||
|