Skip to content

Commit 75bb4cd

Browse files
committed
make fmt
1 parent 949ca4d commit 75bb4cd

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

coderd/domain_error_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,103 @@ import (
1919
// attempts to login, the error message doesn't expose the list of authorized domains.
2020
func TestOIDCDomainErrorMessage(t *testing.T) {
2121
t.Parallel()
22-
22+
2323
// Setup OIDC fake provider
2424
fake := oidctest.NewFakeIDP(t, oidctest.WithServing())
25-
25+
2626
// Configure OIDC provider with domain restrictions
2727
allowedDomains := []string{"allowed1.com", "allowed2.org", "company.internal"}
2828
cfg := fake.OIDCConfig(t, nil, func(cfg *coderd.OIDCConfig) {
2929
cfg.EmailDomain = allowedDomains
3030
cfg.AllowSignups = true
3131
})
32-
32+
3333
// Create a Coder server with OIDC enabled
3434
server := coderdtest.New(t, &coderdtest.Options{
3535
OIDCConfig: cfg,
3636
})
37-
37+
3838
// Test case 1: Email domain not in allowed list
3939
t.Run("ErrorMessageOmitsDomains", func(t *testing.T) {
4040
t.Parallel()
41-
41+
4242
// Prepare claims with email from unauthorized domain
4343
claims := jwt.MapClaims{
4444
"email": "user@unauthorized.com",
4545
"email_verified": true,
4646
"sub": uuid.NewString(),
4747
}
48-
48+
4949
// Attempt login and check for failure
5050
_, resp := fake.AttemptLogin(t, server, claims)
5151
defer resp.Body.Close()
52-
52+
5353
// Verify the status code
5454
require.Equal(t, http.StatusForbidden, resp.StatusCode)
55-
55+
5656
// Check the response content
5757
data, err := io.ReadAll(resp.Body)
5858
require.NoError(t, err)
59-
59+
6060
// Verify the message contains the generic text
6161
require.Contains(t, string(data), "is not from an authorized domain")
6262
require.Contains(t, string(data), "Please contact your administrator")
63-
63+
6464
// Verify it doesn't contain any of the allowed domains
6565
for _, domain := range allowedDomains {
6666
require.NotContains(t, string(data), domain)
6767
}
6868
})
69-
69+
7070
// Test case 2: Malformed email without @ symbol
7171
t.Run("MalformedEmailErrorOmitsDomains", func(t *testing.T) {
7272
t.Parallel()
73-
73+
7474
// Prepare claims with an invalid email format (no @ symbol)
7575
claims := jwt.MapClaims{
7676
"email": "invalid-email-without-domain",
7777
"email_verified": true,
7878
"sub": uuid.NewString(),
7979
}
80-
80+
8181
// Attempt login and check for failure
8282
_, resp := fake.AttemptLogin(t, server, claims)
8383
defer resp.Body.Close()
84-
84+
8585
// Verify the status code
8686
require.Equal(t, http.StatusForbidden, resp.StatusCode)
87-
87+
8888
// Check the response content
8989
data, err := io.ReadAll(resp.Body)
9090
require.NoError(t, err)
91-
91+
9292
// Verify the message contains the generic text
9393
require.Contains(t, string(data), "is not from an authorized domain")
9494
require.Contains(t, string(data), "Please contact your administrator")
95-
95+
9696
// Verify it doesn't contain any of the allowed domains
9797
for _, domain := range allowedDomains {
9898
require.NotContains(t, string(data), domain)
9999
}
100100
})
101-
101+
102102
// Test case 3: Authorized domain (should succeed)
103103
t.Run("AuthorizedDomainSucceeds", func(t *testing.T) {
104104
t.Parallel()
105-
105+
106106
// Prepare claims with an authorized domain
107107
claims := jwt.MapClaims{
108108
"email": "user@allowed1.com",
109109
"email_verified": true,
110110
"sub": uuid.NewString(),
111111
}
112-
112+
113113
// Attempt login and expect success
114114
client, _ := fake.Login(t, server, claims)
115-
115+
116116
// Verify the user was created correctly
117117
user, err := client.User(context.Background(), "me")
118118
require.NoError(t, err)
119119
require.Equal(t, "user", user.Username)
120120
})
121-
}
121+
}

0 commit comments

Comments
 (0)