@@ -436,6 +436,72 @@ describe('CheckAuthService', () => {
436436 } ) ;
437437 } )
438438 ) ;
439+
440+ it (
441+ 'should start check session and validation after forceRefreshSession has been called and is authenticated after forcing with silentrenew' ,
442+ waitForAsync ( ( ) => {
443+ spyOn ( configurationProvider , 'hasAsLeastOneConfig' ) . and . returnValue ( true ) ;
444+ spyOn ( configurationProvider , 'getOpenIDConfiguration' ) . and . returnValue ( { authority : 'authority' } ) ;
445+ spyOn ( callBackService , 'isCallback' ) . and . returnValue ( false ) ;
446+ spyOn ( authStateService , 'areAuthStorageTokensValid' ) . and . returnValue ( false ) ;
447+ spyOn ( callBackService , 'handleCallbackAndFireEvents' ) . and . returnValue ( of ( null ) ) ;
448+ spyOn ( checkSessionService , 'isCheckSessionConfigured' ) . and . returnValue ( true ) ;
449+ spyOn ( silentRenewService , 'isSilentRenewConfigured' ) . and . returnValue ( true ) ;
450+
451+ const checkSessionServiceStartSpy = spyOn ( checkSessionService , 'start' ) ;
452+ const periodicallyTokenCheckServiceSpy = spyOn ( periodicallyTokenCheckService , 'startTokenValidationPeriodically' ) ;
453+ const getOrCreateIframeSpy = spyOn ( silentRenewService , 'getOrCreateIframe' ) ;
454+
455+ spyOn ( refreshSessionService , 'forceRefreshSession' ) . and . returnValue (
456+ of ( {
457+ idToken : 'idToken' ,
458+ accessToken : 'access_token' ,
459+ isAuthenticated : true ,
460+ userData : null ,
461+ configId : 'configId' ,
462+ } )
463+ ) ;
464+
465+ checkAuthService . checkAuthIncludingServer ( 'configId' ) . subscribe ( ( result ) => {
466+ expect ( checkSessionServiceStartSpy ) . toHaveBeenCalledOnceWith ( 'configId' ) ;
467+ expect ( periodicallyTokenCheckServiceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
468+ expect ( getOrCreateIframeSpy ) . toHaveBeenCalledOnceWith ( 'configId' ) ;
469+ } ) ;
470+ } )
471+ ) ;
472+
473+ it (
474+ 'should start check session and validation after forceRefreshSession has been called and is authenticated after forcing without silentrenew' ,
475+ waitForAsync ( ( ) => {
476+ spyOn ( configurationProvider , 'hasAsLeastOneConfig' ) . and . returnValue ( true ) ;
477+ spyOn ( configurationProvider , 'getOpenIDConfiguration' ) . and . returnValue ( { authority : 'authority' } ) ;
478+ spyOn ( callBackService , 'isCallback' ) . and . returnValue ( false ) ;
479+ spyOn ( authStateService , 'areAuthStorageTokensValid' ) . and . returnValue ( false ) ;
480+ spyOn ( callBackService , 'handleCallbackAndFireEvents' ) . and . returnValue ( of ( null ) ) ;
481+ spyOn ( checkSessionService , 'isCheckSessionConfigured' ) . and . returnValue ( true ) ;
482+ spyOn ( silentRenewService , 'isSilentRenewConfigured' ) . and . returnValue ( false ) ;
483+
484+ const checkSessionServiceStartSpy = spyOn ( checkSessionService , 'start' ) ;
485+ const periodicallyTokenCheckServiceSpy = spyOn ( periodicallyTokenCheckService , 'startTokenValidationPeriodically' ) ;
486+ const getOrCreateIframeSpy = spyOn ( silentRenewService , 'getOrCreateIframe' ) ;
487+
488+ spyOn ( refreshSessionService , 'forceRefreshSession' ) . and . returnValue (
489+ of ( {
490+ idToken : 'idToken' ,
491+ accessToken : 'access_token' ,
492+ isAuthenticated : true ,
493+ userData : null ,
494+ configId : 'configId' ,
495+ } )
496+ ) ;
497+
498+ checkAuthService . checkAuthIncludingServer ( 'configId' ) . subscribe ( ( result ) => {
499+ expect ( checkSessionServiceStartSpy ) . toHaveBeenCalledOnceWith ( 'configId' ) ;
500+ expect ( periodicallyTokenCheckServiceSpy ) . toHaveBeenCalledTimes ( 1 ) ;
501+ expect ( getOrCreateIframeSpy ) . not . toHaveBeenCalled ( ) ;
502+ } ) ;
503+ } )
504+ ) ;
439505 } ) ;
440506
441507 describe ( 'checkAuthMultiple' , ( ) => {
0 commit comments