MCPcopy Index your code
hub / github.com/coder/coder / TestScim

Function TestScim

enterprise/coderd/scim_test.go:75–865  ·  view source on GitHub ↗

nolint:gocritic // SCIM authenticates via a special header and bypasses internal RBAC.

(t *testing.T)

Source from the content-addressed store, hash-verified

73
74//nolint:gocritic // SCIM authenticates via a special header and bypasses internal RBAC.
75func TestScim(t *testing.T) {
76 t.Parallel()
77
78 t.Run("postUser", func(t *testing.T) {
79 t.Parallel()
80
81 t.Run("disabled", func(t *testing.T) {
82 t.Parallel()
83
84 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
85 defer cancel()
86
87 client, _ := coderdenttest.New(t, &coderdenttest.Options{
88 SCIMAPIKey: []byte("hi"),
89 LicenseOptions: &coderdenttest.LicenseOptions{
90 AccountID: "coolin",
91 Features: license.Features{
92 codersdk.FeatureSCIM: 0,
93 },
94 },
95 })
96
97 res, err := client.Request(ctx, "POST", "/scim/v2/Users", struct{}{})
98 require.NoError(t, err)
99 defer res.Body.Close()
100 assert.Equal(t, http.StatusForbidden, res.StatusCode)
101 })
102
103 t.Run("noAuth", func(t *testing.T) {
104 t.Parallel()
105
106 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
107 defer cancel()
108
109 client, _ := coderdenttest.New(t, &coderdenttest.Options{
110 SCIMAPIKey: []byte("hi"),
111 LicenseOptions: &coderdenttest.LicenseOptions{
112 AccountID: "coolin",
113 Features: license.Features{
114 codersdk.FeatureSCIM: 1,
115 },
116 },
117 })
118
119 res, err := client.Request(ctx, "POST", "/scim/v2/Users", struct{}{})
120 require.NoError(t, err)
121 defer res.Body.Close()
122 assert.Equal(t, http.StatusUnauthorized, res.StatusCode)
123 })
124
125 t.Run("OK", func(t *testing.T) {
126 t.Parallel()
127
128 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
129 defer cancel()
130
131 // given
132 scimAPIKey := []byte("hi")

Callers

nothing calls this directly

Calls 15

SentMethod · 0.95
OIDCConfigMethod · 0.95
LoginMethod · 0.95
NewFunction · 0.92
NewMockFunction · 0.92
DeploymentValuesFunction · 0.92
RefFunction · 0.92
NewFakeIDPFunction · 0.92
WithServingFunction · 0.92
makeScimUserFunction · 0.85
setScimAuthFunction · 0.85
setScimAuthBearerFunction · 0.85

Tested by

no test coverage detected