Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: remove shared mutable state between oidc tests#17179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/fix-oidc-race-flake
Apr 1, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletionscoderd/userauth_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1988,30 +1988,36 @@ func TestUserLogout(t *testing.T) {
func TestOIDCDomainErrorMessage(t *testing.T) {
t.Parallel()

fake := oidctest.NewFakeIDP(t, oidctest.WithServing())

allowedDomains := []string{"allowed1.com", "allowed2.org", "company.internal"}
cfg := fake.OIDCConfig(t, nil, func(cfg *coderd.OIDCConfig) {
cfg.EmailDomain = allowedDomains
cfg.AllowSignups = true
})

server := coderdtest.New(t, &coderdtest.Options{
OIDCConfig: cfg,
})
setup := func() (*oidctest.FakeIDP, *codersdk.Client) {
fake := oidctest.NewFakeIDP(t, oidctest.WithServing())

cfg := fake.OIDCConfig(t, nil, func(cfg *coderd.OIDCConfig) {
cfg.EmailDomain = allowedDomains
cfg.AllowSignups = true
})

client := coderdtest.New(t, &coderdtest.Options{
OIDCConfig: cfg,
})
return fake, client
}

// Test case 1: Email domain not in allowed list
t.Run("ErrorMessageOmitsDomains", func(t *testing.T) {
t.Parallel()

fake, client := setup()

// Prepare claims with email from unauthorized domain
claims := jwt.MapClaims{
"email": "user@unauthorized.com",
"email_verified": true,
"sub": uuid.NewString(),
}

_, resp := fake.AttemptLogin(t,server, claims)
_, resp := fake.AttemptLogin(t,client, claims)
defer resp.Body.Close()

require.Equal(t, http.StatusForbidden, resp.StatusCode)
Expand All@@ -2031,14 +2037,16 @@ func TestOIDCDomainErrorMessage(t *testing.T) {
t.Run("MalformedEmailErrorOmitsDomains", func(t *testing.T) {
t.Parallel()

fake, client := setup()

// Prepare claims with an invalid email format (no @ symbol)
claims := jwt.MapClaims{
"email": "invalid-email-without-domain",
"email_verified": true,
"sub": uuid.NewString(),
}

_, resp := fake.AttemptLogin(t,server, claims)
_, resp := fake.AttemptLogin(t,client, claims)
defer resp.Body.Close()

require.Equal(t, http.StatusForbidden, resp.StatusCode)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp