Skip to content

Commit 85c886f

Browse files
committed
fixup! fix(scim): ensure scim users aren't created with their own org
1 parent e2681d7 commit 85c886f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

coderd/users_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,31 @@ func TestPostUsers(t *testing.T) {
478478
require.Equal(t, http.StatusNotFound, apiErr.StatusCode())
479479
})
480480

481+
t.Run("CreateWithoutOrg", func(t *testing.T) {
482+
t.Parallel()
483+
auditor := audit.NewMock()
484+
client := coderdtest.New(t, &coderdtest.Options{Auditor: auditor})
485+
numLogs := len(auditor.AuditLogs())
486+
487+
_ = coderdtest.CreateFirstUser(t, client)
488+
numLogs++ // add an audit log for user create
489+
numLogs++ // add an audit log for login
490+
491+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
492+
defer cancel()
493+
494+
_, err := client.CreateUser(ctx, codersdk.CreateUserRequest{
495+
Email: "another@user.org",
496+
Username: "someone-else",
497+
Password: "SomeSecurePassword!",
498+
})
499+
require.NoError(t, err)
500+
501+
require.Len(t, auditor.AuditLogs(), numLogs)
502+
require.Equal(t, database.AuditActionCreate, auditor.AuditLogs()[numLogs-1].Action)
503+
require.Equal(t, database.AuditActionLogin, auditor.AuditLogs()[numLogs-2].Action)
504+
})
505+
481506
t.Run("Create", func(t *testing.T) {
482507
t.Parallel()
483508
auditor := audit.NewMock()

0 commit comments

Comments
 (0)