@@ -22,6 +22,11 @@ const TEST_REPO_CONFIG = {
2222 url : 'https://github.com/finos/git-proxy-test.git' ,
2323} ;
2424const TEST_REPO = 'finos/git-proxy-test.git' ;
25+ // user for test cases
26+ const TEST_USER = 'testuser' ;
27+ const TEST_PASSWORD = 'testpassword' ;
28+ const TEST_EMAIL = 'jane.doe@email.com' ;
29+ const TEST_GIT_ACCOUNT = 'testGitAccount' ;
2530
2631describe ( 'test git-proxy-cli' , function ( ) {
2732 // *** help ***
@@ -87,16 +92,12 @@ describe('test git-proxy-cli', function () {
8792 // *** login ***
8893
8994 describe ( 'test git-proxy-cli :: login' , function ( ) {
90- const testUser = 'testuser' ;
91- const testPassword = 'testpassword' ;
92- const testEmail = 'jane.doe@email.com' ;
93-
9495 before ( async function ( ) {
95- await helper . addUserToDb ( testUser , testPassword , testEmail , 'testGitAccount' ) ;
96+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
9697 } ) ;
9798
9899 after ( async function ( ) {
99- await helper . removeUserFromDb ( testUser ) ;
100+ await helper . removeUserFromDb ( TEST_USER ) ;
100101 } ) ;
101102
102103 it ( 'login should fail when server is down' , async function ( ) {
@@ -140,9 +141,9 @@ describe('test git-proxy-cli', function () {
140141 } ) ;
141142
142143 it ( 'login shoud be successful with valid credentials (non-admin)' , async function ( ) {
143- const cli = `npx -- @finos/git-proxy-cli login --username ${ testUser } --password ${ testPassword } ` ;
144+ const cli = `npx -- @finos/git-proxy-cli login --username ${ TEST_USER } --password ${ TEST_PASSWORD } ` ;
144145 const expectedExitCode = 0 ;
145- const expectedMessages = [ `Login "${ testUser } " <${ testEmail } >: OK` ] ;
146+ const expectedMessages = [ `Login "${ TEST_USER } " <${ TEST_EMAIL } >: OK` ] ;
146147 const expectedErrorMessages = null ;
147148 try {
148149 await helper . startServer ( service ) ;
@@ -219,11 +220,13 @@ describe('test git-proxy-cli', function () {
219220
220221 before ( async function ( ) {
221222 await helper . addRepoToDb ( TEST_REPO_CONFIG ) ;
222- await helper . addGitPushToDb ( pushId , TEST_REPO ) ;
223+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
224+ await helper . addGitPushToDb ( pushId , TEST_USER , TEST_EMAIL , TEST_REPO ) ;
223225 } ) ;
224226
225227 after ( async function ( ) {
226228 await helper . removeGitPushFromDb ( pushId ) ;
229+ await helper . removeUserFromDb ( TEST_USER ) ;
227230 await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
228231 } ) ;
229232
@@ -294,11 +297,13 @@ describe('test git-proxy-cli', function () {
294297
295298 before ( async function ( ) {
296299 await helper . addRepoToDb ( TEST_REPO_CONFIG ) ;
297- await helper . addGitPushToDb ( pushId , TEST_REPO ) ;
300+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
301+ await helper . addGitPushToDb ( pushId , TEST_USER , TEST_EMAIL , TEST_REPO ) ;
298302 } ) ;
299303
300304 after ( async function ( ) {
301305 await helper . removeGitPushFromDb ( pushId ) ;
306+ await helper . removeUserFromDb ( TEST_USER ) ;
302307 await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
303308 } ) ;
304309
@@ -415,11 +420,13 @@ describe('test git-proxy-cli', function () {
415420
416421 before ( async function ( ) {
417422 await helper . addRepoToDb ( TEST_REPO_CONFIG ) ;
418- await helper . addGitPushToDb ( pushId , TEST_REPO ) ;
423+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
424+ await helper . addGitPushToDb ( pushId , TEST_USER , TEST_EMAIL , TEST_REPO ) ;
419425 } ) ;
420426
421427 after ( async function ( ) {
422428 await helper . removeGitPushFromDb ( pushId ) ;
429+ await helper . removeUserFromDb ( TEST_USER ) ;
423430 await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
424431 } ) ;
425432
@@ -487,12 +494,17 @@ describe('test git-proxy-cli', function () {
487494
488495 describe ( 'test git-proxy-cli :: git push administration' , function ( ) {
489496 const pushId = `0000000000000000000000000000000000000000__${ Date . now ( ) } ` ;
490- const gitAccount = 'testGitAccount1' ;
491497
492498 before ( async function ( ) {
493499 await helper . addRepoToDb ( TEST_REPO_CONFIG ) ;
494- await helper . addUserToDb ( 'testuser1' , 'testpassword' , 'test@email.com' , gitAccount ) ;
495- await helper . addGitPushToDb ( pushId , TEST_REPO , gitAccount ) ;
500+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
501+ await helper . addGitPushToDb ( pushId , TEST_REPO , TEST_USER , TEST_EMAIL ) ;
502+ } ) ;
503+
504+ after ( async function ( ) {
505+ await helper . removeGitPushFromDb ( pushId ) ;
506+ await helper . removeUserFromDb ( TEST_USER ) ;
507+ await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
496508 } ) ;
497509
498510 after ( async function ( ) {
0 commit comments