@@ -486,6 +486,10 @@ describe('test git-proxy-cli', function () {
486
486
// *** create user ***
487
487
488
488
describe ( 'test git-proxy-cli :: create-user' , function ( ) {
489
+ const testUser = 'testuser' ;
490
+ const testPassword = 'testpassword' ;
491
+ const testEmail = '[email protected] ' ;
492
+
489
493
it ( 'attempt to create user should fail when server is down' , async function ( ) {
490
494
try {
491
495
// start server -> login -> stop server
@@ -514,9 +518,10 @@ describe('test git-proxy-cli', function () {
514
518
515
519
it ( 'attempt to create user should fail when not admin' , async function ( ) {
516
520
try {
521
+ await helper . addUserToDb ( testUser , testPassword , testEmail , 'testGitAccount' ) ;
517
522
await helper . startServer ( service ) ;
518
523
await helper . runCli (
519
- `npx -- @finos/git-proxy-cli login --username testuser --password testpassword ` ,
524
+ `npx -- @finos/git-proxy-cli login --username ${ testUser } --password ${ testPassword } ` ,
520
525
) ;
521
526
522
527
const cli = `npx -- @finos/git-proxy-cli create-user --username newuser --password newpass --email [email protected] --gitAccount newgit` ;
@@ -525,6 +530,7 @@ describe('test git-proxy-cli', function () {
525
530
const expectedErrorMessages = [ 'Error: Create User: Authentication required' ] ;
526
531
await helper . runCli ( cli , expectedExitCode , expectedMessages , expectedErrorMessages ) ;
527
532
} finally {
533
+ await helper . removeUserFromDb ( testUser ) ;
528
534
await helper . closeServer ( service . httpServer ) ;
529
535
}
530
536
} ) ;
@@ -563,6 +569,7 @@ describe('test git-proxy-cli', function () {
563
569
null ,
564
570
) ;
565
571
} finally {
572
+ await helper . removeUserFromDb ( 'newuser' ) ;
566
573
await helper . closeServer ( service . httpServer ) ;
567
574
}
568
575
} ) ;
@@ -586,6 +593,7 @@ describe('test git-proxy-cli', function () {
586
593
null ,
587
594
) ;
588
595
} finally {
596
+ await helper . removeUserFromDb ( 'newadmin' ) ;
589
597
await helper . closeServer ( service . httpServer ) ;
590
598
}
591
599
} ) ;
0 commit comments