nolint:bodyclose
(t *testing.T)
| 30 | |
| 31 | // nolint:bodyclose |
| 32 | func TestUserOIDC(t *testing.T) { |
| 33 | t.Parallel() |
| 34 | |
| 35 | t.Run("OrganizationSync", func(t *testing.T) { |
| 36 | t.Parallel() |
| 37 | |
| 38 | t.Run("SingleOrgDeployment", func(t *testing.T) { |
| 39 | t.Parallel() |
| 40 | |
| 41 | runner := setupOIDCTest(t, oidcTestConfig{ |
| 42 | Config: func(cfg *coderd.OIDCConfig) { |
| 43 | cfg.AllowSignups = true |
| 44 | }, |
| 45 | DeploymentValues: func(dv *codersdk.DeploymentValues) { |
| 46 | dv.OIDC.UserRoleField = "roles" |
| 47 | }, |
| 48 | }) |
| 49 | |
| 50 | claims := jwt.MapClaims{ |
| 51 | "email": "alice@coder.com", |
| 52 | "sub": uuid.NewString(), |
| 53 | } |
| 54 | |
| 55 | // Login a new client that signs up |
| 56 | client, resp := runner.Login(t, claims) |
| 57 | require.Equal(t, http.StatusOK, resp.StatusCode) |
| 58 | runner.AssertOrganizations(t, "alice", true, nil) |
| 59 | |
| 60 | // Force a refresh, and assert nothing has changes |
| 61 | runner.ForceRefresh(t, client, claims) |
| 62 | runner.AssertOrganizations(t, "alice", true, nil) |
| 63 | }) |
| 64 | |
| 65 | t.Run("MultiOrgNoSync", func(t *testing.T) { |
| 66 | t.Parallel() |
| 67 | |
| 68 | runner := setupOIDCTest(t, oidcTestConfig{ |
| 69 | Config: func(cfg *coderd.OIDCConfig) { |
| 70 | cfg.AllowSignups = true |
| 71 | }, |
| 72 | }) |
| 73 | |
| 74 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 75 | second, err := runner.AdminClient.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{ |
| 76 | Name: "second", |
| 77 | DisplayName: "", |
| 78 | Description: "", |
| 79 | Icon: "", |
| 80 | }) |
| 81 | require.NoError(t, err) |
| 82 | |
| 83 | claims := jwt.MapClaims{ |
| 84 | "email": "alice@coder.com", |
| 85 | "sub": uuid.NewString(), |
| 86 | } |
| 87 | |
| 88 | // Login a new client that signs up |
| 89 | _, resp := runner.Login(t, claims) |
nothing calls this directly
no test coverage detected