@@ -183,6 +183,19 @@ describe('GitOps Account - Subscribe', () => {
183183 expect ( req . body . errors [ 0 ] . msg ) . toBe ( 'Invalid window value (minimum 30s)' ) ;
184184 } ) ;
185185
186+ test ( 'GITOPS_ACCOUNT_SUITE - Should return error - window cannot be lower than 1(m/h)' , async ( ) => {
187+ const payload = JSON . parse ( JSON . stringify ( VALID_SUBSCRIPTION_REQUEST ) ) ;
188+ payload . settings . window = "0m" ;
189+
190+ const req = await request ( app )
191+ . post ( '/gitops/v1/account/subscribe' )
192+ . set ( 'Authorization' , `Bearer ${ adminMasterAccountToken } ` )
193+ . send ( payload )
194+ . expect ( 422 ) ;
195+
196+ expect ( req . body . errors [ 0 ] . msg ) . toBe ( 'Invalid window value (minimum 1[m/h])' ) ;
197+ } ) ;
198+
186199 test ( 'GITOPS_ACCOUNT_SUITE - Should return error - window cannot use different units than [s,m,h]' , async ( ) => {
187200 const payload = JSON . parse ( JSON . stringify ( VALID_SUBSCRIPTION_REQUEST ) ) ;
188201 payload . settings . window = '1d' ;
@@ -204,6 +217,7 @@ describe('GitOps Account - Update', () => {
204217 repository : 'https://github.com/switcherapi/switcher-gitops-fixture' ,
205218 branch : 'main' ,
206219 environment : EnvType . DEFAULT ,
220+ path : 'path/to/file' ,
207221 domain : {
208222 id : String ( domainId ) ,
209223 name : 'Test Domain'
@@ -294,55 +308,42 @@ describe('GitOps Account - Update', () => {
294308
295309} )
296310
297- describe ( 'GitOps Account - Update Token' , ( ) => {
311+ describe ( 'GitOps Account - Update All Token' , ( ) => {
298312 beforeAll ( setupDatabase ) ;
299313
300- const VALID_UPDATE_REQUEST = {
301- repository : 'https://github.com/switcherapi/switcher-gitops-fixture' ,
302- branch : 'main' ,
303- environment : EnvType . DEFAULT ,
304- domain : {
305- id : String ( domainId ) ,
306- name : 'Test Domain'
307- } ,
308- settings : {
309- active : true ,
310- window : '30s' ,
311- forceprune : true
312- }
313- } ;
314-
315314 const VALID_TOKEN_UPDATE_REQUEST = {
316- environment : EnvType . DEFAULT ,
315+ environments : [ EnvType . DEFAULT ] ,
317316 token : '123456' ,
318317 domain : {
319318 id : String ( domainId )
320319 }
321320 } ;
322321
323- test ( 'GITOPS_ACCOUNT_SUITE - Should update account token' , async ( ) => {
324- // given
325- const expectedResponse = JSON . parse ( JSON . stringify ( VALID_UPDATE_REQUEST ) ) ;
326- expectedResponse . token = '...123' ;
327-
322+ test ( 'GITOPS_ACCOUNT_SUITE - Should update account tokens' , async ( ) => {
328323 const postStub = sinon . stub ( axios , 'put' ) . resolves ( {
329324 status : 200 ,
330- data : expectedResponse
325+ data : {
326+ result : true ,
327+ message : 'Account tokens updated successfully'
328+ }
331329 } ) ;
332330
333331 // test
334332 const req = await request ( app )
335- . put ( '/gitops/v1/account/token ' )
333+ . put ( '/gitops/v1/account/tokens ' )
336334 . set ( 'Authorization' , `Bearer ${ adminMasterAccountToken } ` )
337335 . send ( VALID_TOKEN_UPDATE_REQUEST )
338336 . expect ( 200 ) ;
339337
340338 // assert
341- expect ( req . body ) . toMatchObject ( expectedResponse ) ;
339+ expect ( req . body ) . toMatchObject ( {
340+ result : true ,
341+ message : 'Account tokens updated successfully'
342+ } ) ;
342343 postStub . restore ( ) ;
343344 } ) ;
344345
345- test ( 'GITOPS_ACCOUNT_SUITE - Should return error - error updating account token ' , async ( ) => {
346+ test ( 'GITOPS_ACCOUNT_SUITE - Should return error - error updating account tokens ' , async ( ) => {
346347 // given
347348 const postStub = sinon . stub ( axios , 'put' ) . resolves ( {
348349 status : 500 ,
@@ -353,7 +354,7 @@ describe('GitOps Account - Update Token', () => {
353354
354355 // test
355356 const req = await request ( app )
356- . put ( '/gitops/v1/account/token ' )
357+ . put ( '/gitops/v1/account/tokens ' )
357358 . set ( 'Authorization' , `Bearer ${ adminMasterAccountToken } ` )
358359 . send ( VALID_TOKEN_UPDATE_REQUEST )
359360 . expect ( 500 ) ;
@@ -374,7 +375,7 @@ describe('GitOps Account - Update Token', () => {
374375
375376 // test
376377 const req = await request ( app )
377- . put ( '/gitops/v1/account/token ' )
378+ . put ( '/gitops/v1/account/tokens ' )
378379 . set ( 'Authorization' , `Bearer ${ adminMasterAccountToken } ` )
379380 . send ( VALID_TOKEN_UPDATE_REQUEST )
380381 . expect ( 500 ) ;
@@ -389,7 +390,7 @@ describe('GitOps Account - Update Token', () => {
389390 delete payload . domain . id ;
390391
391392 const req = await request ( app )
392- . put ( '/gitops/v1/account/token ' )
393+ . put ( '/gitops/v1/account/tokens ' )
393394 . set ( 'Authorization' , `Bearer ${ adminMasterAccountToken } ` )
394395 . send ( payload )
395396 . expect ( 422 ) ;
0 commit comments