@@ -478,6 +478,31 @@ func TestPostUsers(t *testing.T) {
478
478
require .Equal (t , http .StatusNotFound , apiErr .StatusCode ())
479
479
})
480
480
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
+
481
506
t .Run ("Create" , func (t * testing.T ) {
482
507
t .Parallel ()
483
508
auditor := audit .NewMock ()
0 commit comments