Skip to content

Commit b5b0d90

Browse files
committed
Skip notifications
1 parent a92d059 commit b5b0d90

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

enterprise/coderd/scim_test.go

+13-2
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ func TestScim(t *testing.T) {
113113
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
114114
defer cancel()
115115

116+
// given
116117
scimAPIKey := []byte("hi")
117118
mockAudit := audit.NewMock()
119+
notifyEnq := &testutil.FakeNotificationsEnqueuer{}
118120
client, _ := coderdenttest.New(t, &coderdenttest.Options{
119-
Options: &coderdtest.Options{Auditor: mockAudit},
121+
Options: &coderdtest.Options{
122+
Auditor: mockAudit,
123+
NotificationsEnqueuer: notifyEnq,
124+
},
120125
SCIMAPIKey: scimAPIKey,
121126
AuditLogging: true,
122127
LicenseOptions: &coderdenttest.LicenseOptions{
@@ -129,12 +134,15 @@ func TestScim(t *testing.T) {
129134
})
130135
mockAudit.ResetLogs()
131136

137+
// when
132138
sUser := makeScimUser(t)
133139
res, err := client.Request(ctx, "POST", "/scim/v2/Users", sUser, setScimAuth(scimAPIKey))
134140
require.NoError(t, err)
135141
defer res.Body.Close()
136142
require.Equal(t, http.StatusOK, res.StatusCode)
137143

144+
// then
145+
// Expect audit logs
138146
aLogs := mockAudit.AuditLogs()
139147
require.Len(t, aLogs, 1)
140148
af := map[string]string{}
@@ -143,12 +151,15 @@ func TestScim(t *testing.T) {
143151
assert.Equal(t, coderd.SCIMAuditAdditionalFields, af)
144152
assert.Equal(t, database.AuditActionCreate, aLogs[0].Action)
145153

154+
// Expect users exposed over API
146155
userRes, err := client.Users(ctx, codersdk.UsersRequest{Search: sUser.Emails[0].Value})
147156
require.NoError(t, err)
148157
require.Len(t, userRes.Users, 1)
149-
150158
assert.Equal(t, sUser.Emails[0].Value, userRes.Users[0].Email)
151159
assert.Equal(t, sUser.UserName, userRes.Users[0].Username)
160+
161+
// Expect zero notifications (SkipNotifications = true)
162+
require.Empty(t, notifyEnq.Sent)
152163
})
153164

154165
t.Run("Duplicate", func(t *testing.T) {

0 commit comments

Comments
 (0)