nolint:gocritic // SCIM authenticates via a special header and bypasses internal RBAC.
(t *testing.T)
| 73 | |
| 74 | //nolint:gocritic // SCIM authenticates via a special header and bypasses internal RBAC. |
| 75 | func 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") |
nothing calls this directly
no test coverage detected