Skip to content

Commit a49b491

Browse files
committed
Add test case for username as email
1 parent 424579e commit a49b491

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

coderd/coderd_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
248248

249249
// Has it's own auth
250250
"GET:/api/v2/users/oauth2/github/callback": {NoAuthorize: true},
251+
"GET:/api/v2/users/oidc/callback": {NoAuthorize: true},
251252

252253
// All workspaceagents endpoints do not use rbac
253254
"POST:/api/v2/workspaceagents/aws-instance-identity": {NoAuthorize: true},

coderd/userauth_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,18 @@ func TestUserOIDC(t *testing.T) {
319319
Username: "hotdog",
320320
AllowSignups: true,
321321
StatusCode: http.StatusTemporaryRedirect,
322+
}, {
323+
// Services like Okta return the email as the username:
324+
// https://developer.okta.com/docs/reference/api/oidc/#base-claims-always-present
325+
Name: "UsernameAsEmail",
326+
Claims: jwt.MapClaims{
327+
"email": "kyle@kwc.io",
328+
"email_verified": true,
329+
"preferred_username": "kyle@kwc.io",
330+
},
331+
Username: "kyle",
332+
AllowSignups: true,
333+
StatusCode: http.StatusTemporaryRedirect,
322334
}} {
323335
tc := tc
324336
t.Run(tc.Name, func(t *testing.T) {

0 commit comments

Comments
 (0)