@@ -22,6 +22,11 @@ const TEST_REPO_CONFIG = {
22
22
url : 'https://github.com/finos/git-proxy-test.git' ,
23
23
} ;
24
24
const 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 = '[email protected] ' ;
29
+ const TEST_GIT_ACCOUNT = 'testGitAccount' ;
25
30
26
31
describe ( 'test git-proxy-cli' , function ( ) {
27
32
// *** help ***
@@ -87,16 +92,12 @@ describe('test git-proxy-cli', function () {
87
92
// *** login ***
88
93
89
94
describe ( 'test git-proxy-cli :: login' , function ( ) {
90
- const testUser = 'testuser' ;
91
- const testPassword = 'testpassword' ;
92
- const testEmail = '[email protected] ' ;
93
-
94
95
before ( async function ( ) {
95
- await helper . addUserToDb ( testUser , testPassword , testEmail , 'testGitAccount' ) ;
96
+ await helper . addUserToDb ( TEST_USER , TEST_PASSWORD , TEST_EMAIL , TEST_GIT_ACCOUNT ) ;
96
97
} ) ;
97
98
98
99
after ( async function ( ) {
99
- await helper . removeUserFromDb ( testUser ) ;
100
+ await helper . removeUserFromDb ( TEST_USER ) ;
100
101
} ) ;
101
102
102
103
it ( 'login shoud fail when server is down' , async function ( ) {
@@ -140,9 +141,9 @@ describe('test git-proxy-cli', function () {
140
141
} ) ;
141
142
142
143
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 } ` ;
144
145
const expectedExitCode = 0 ;
145
- const expectedMessages = [ `Login "${ testUser } " <${ testEmail } >: OK` ] ;
146
+ const expectedMessages = [ `Login "${ TEST_USER } " <${ TEST_EMAIL } >: OK` ] ;
146
147
const expectedErrorMessages = null ;
147
148
try {
148
149
await helper . startServer ( service ) ;
@@ -219,11 +220,13 @@ describe('test git-proxy-cli', function () {
219
220
220
221
before ( async function ( ) {
221
222
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 ) ;
223
225
} ) ;
224
226
225
227
after ( async function ( ) {
226
228
await helper . removeGitPushFromDb ( pushId ) ;
229
+ await helper . removeUserFromDb ( TEST_USER ) ;
227
230
await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
228
231
} ) ;
229
232
@@ -294,11 +297,13 @@ describe('test git-proxy-cli', function () {
294
297
295
298
before ( async function ( ) {
296
299
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 ) ;
298
302
} ) ;
299
303
300
304
after ( async function ( ) {
301
305
await helper . removeGitPushFromDb ( pushId ) ;
306
+ await helper . removeUserFromDb ( TEST_USER ) ;
302
307
await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
303
308
} ) ;
304
309
@@ -415,11 +420,13 @@ describe('test git-proxy-cli', function () {
415
420
416
421
before ( async function ( ) {
417
422
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 ) ;
419
425
} ) ;
420
426
421
427
after ( async function ( ) {
422
428
await helper . removeGitPushFromDb ( pushId ) ;
429
+ await helper . removeUserFromDb ( TEST_USER ) ;
423
430
await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
424
431
} ) ;
425
432
@@ -487,17 +494,16 @@ describe('test git-proxy-cli', function () {
487
494
488
495
describe ( 'test git-proxy-cli :: git push administration' , function ( ) {
489
496
const pushId = `0000000000000000000000000000000000000000__${ Date . now ( ) } ` ;
490
- const gitAccount = 'testGitAccount1' ;
491
497
492
498
before ( async function ( ) {
493
499
await helper . addRepoToDb ( TEST_REPO_CONFIG ) ;
494
- await helper . addUserToDb ( 'testuser1' , 'testpassword' , '[email protected] ' , 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 ) ;
496
502
} ) ;
497
503
498
504
after ( async function ( ) {
499
- await helper . removeUserFromDb ( 'testuser1' ) ;
500
505
await helper . removeGitPushFromDb ( pushId ) ;
506
+ await helper . removeUserFromDb ( TEST_USER ) ;
501
507
await helper . removeRepoFromDb ( TEST_REPO_CONFIG . name ) ;
502
508
} ) ;
503
509
0 commit comments