@@ -37,11 +37,7 @@ describe('AuthConfigService', () => {
3737 redirectSilentIframeUri : 'http://localhost:3000/assets/silent-refresh.html' ,
3838 redirectUri : '/' ,
3939 redirectUriLogout : '#/logout' ,
40- publicUrls : [
41- '**/preview/s/*' ,
42- '**/settings' ,
43- '**/logout'
44- ]
40+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
4541 } ;
4642
4743 const mockAuthConfigSubfolderRedirectUri : OauthConfigModel = {
@@ -54,11 +50,7 @@ describe('AuthConfigService', () => {
5450 redirectSilentIframeUri : 'http://localhost:3000/subfolder/assets/silent-refresh.html' ,
5551 redirectUri : '/subfolder' ,
5652 redirectUriLogout : '#/logout' ,
57- publicUrls : [
58- '**/preview/s/*' ,
59- '**/settings' ,
60- '**/logout'
61- ]
53+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
6254 } ;
6355
6456 const mockAuthConfigSubfolder2RedirectUri : OauthConfigModel = {
@@ -71,11 +63,7 @@ describe('AuthConfigService', () => {
7163 redirectSilentIframeUri : 'http://localhost:3000/subfolder2/assets/silent-refresh.html' ,
7264 redirectUri : '/subfolder2' ,
7365 redirectUriLogout : '#/logout' ,
74- publicUrls : [
75- '**/preview/s/*' ,
76- '**/settings' ,
77- '**/logout'
78- ]
66+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
7967 } ;
8068
8169 const mockAuthConfigSlashRedirectUri : OauthConfigModel = {
@@ -88,11 +76,7 @@ describe('AuthConfigService', () => {
8876 redirectSilentIframeUri : 'http://localhost:3000/assets/silent-refresh.html' ,
8977 redirectUri : '/' ,
9078 redirectUriLogout : '#/logout' ,
91- publicUrls : [
92- '**/preview/s/*' ,
93- '**/settings' ,
94- '**/logout'
95- ]
79+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
9680 } ;
9781
9882 const mockAuthConfigCodeFlow = {
@@ -106,19 +90,13 @@ describe('AuthConfigService', () => {
10690 redirectSilentIframeUri : 'http://localhost:3000/assets/silent-refresh.html' ,
10791 redirectUri : '/' ,
10892 redirectUriLogout : '#/logout' ,
109- publicUrls : [
110- '**/preview/s/*' ,
111- '**/settings' ,
112- '**/logout'
113- ]
93+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
11494 } ;
11595
11696 beforeEach ( ( ) => {
11797 TestBed . configureTestingModule ( {
11898 imports : [ HttpClientTestingModule ] ,
119- providers : [
120- { provide : AUTH_MODULE_CONFIG , useValue : { useHash : true } }
121- ]
99+ providers : [ { provide : AUTH_MODULE_CONFIG , useValue : { useHash : true } } ]
122100 } ) ;
123101 service = TestBed . inject ( AuthConfigService ) ;
124102 spyOn < any > ( service , 'getLocationOrigin' ) . and . returnValue ( 'http://localhost:3000' ) ;
@@ -195,4 +173,52 @@ describe('AuthConfigService', () => {
195173 expect ( service . loadAppConfig ( ) . silentRefreshRedirectUri ) . toBe ( expectedUri ) ;
196174 } ) ;
197175 } ) ;
176+
177+ describe ( 'postLogoutRedirectUri' , ( ) => {
178+ const getConfig = ( config : Partial < OauthConfigModel > ) : OauthConfigModel => {
179+ const defaultConfig = {
180+ host : 'http://localhost:3000/auth/realms/alfresco' ,
181+ clientId : 'fakeClientId' ,
182+ scope : 'openid profile email' ,
183+ secret : '' ,
184+ implicitFlow : true ,
185+ silentLogin : true ,
186+ redirectSilentIframeUri : 'http://localhost:3000/assets/silent-refresh.html' ,
187+ redirectUri : '/' ,
188+ redirectUriLogout : '/' ,
189+ publicUrls : [ '**/preview/s/*' , '**/settings' , '**/logout' ]
190+ } ;
191+
192+ return {
193+ ...defaultConfig ,
194+ ...config
195+ } ;
196+ } ;
197+ it ( 'should return proper postLogoutRedirectUri when the redirectUriLogout is "/"' , ( ) => {
198+ const testConfig = getConfig ( {
199+ redirectUriLogout : '/'
200+ } ) ;
201+
202+ spyOnProperty ( appConfigService , 'oauth2' ) . and . returnValue ( testConfig ) ;
203+ expect ( service . loadAppConfig ( ) . postLogoutRedirectUri ) . toBe ( 'http://localhost:3000/' ) ;
204+ } ) ;
205+
206+ it ( 'should return proper postLogoutRedirectUri when the redirectUriLogout is empty' , ( ) => {
207+ const testConfig = getConfig ( {
208+ redirectUriLogout : undefined
209+ } ) ;
210+
211+ spyOnProperty ( appConfigService , 'oauth2' ) . and . returnValue ( testConfig ) ;
212+ expect ( service . loadAppConfig ( ) . postLogoutRedirectUri ) . toBe ( 'http://localhost:3000/' ) ;
213+ } ) ;
214+
215+ it ( 'should return proper postLogoutRedirectUri when the redirectUriLogout starts with slash' , ( ) => {
216+ const testConfig = getConfig ( {
217+ redirectUriLogout : '/asd'
218+ } ) ;
219+
220+ spyOnProperty ( appConfigService , 'oauth2' ) . and . returnValue ( testConfig ) ;
221+ expect ( service . loadAppConfig ( ) . postLogoutRedirectUri ) . toBe ( 'http://localhost:3000/asd' ) ;
222+ } ) ;
223+ } ) ;
198224} ) ;
0 commit comments