Skip to content

Commit

Permalink
[AAE-17909][AAE-17964] fix silent-refresh url is not set with the val…
Browse files Browse the repository at this point in the history
…ue - fix background image set to undefined (#9080)

* [AAE-17909] fix silent-refresh url is not set with the value from the app.config.json

* [AAE-17964] fix backgroundImage is undefined, set a default value
  • Loading branch information
alep85 authored Nov 10, 2023
1 parent 168bb0b commit f2df3c4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
22 changes: 18 additions & 4 deletions lib/core/src/lib/auth/oidc/auth-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('AuthConfigService', () => {
secret: '',
implicitFlow: true,
silentLogin: true,
redirectSilentIframeUri: 'http://localhost:3000/assets/silent-refresh.html',
redirectSilentIframeUri: 'http://localhost:3000/subfolder/assets/silent-refresh.html',
redirectUri: '/subfolder',
redirectUriLogout: '#/logout',
publicUrls: [
Expand All @@ -69,7 +69,7 @@ describe('AuthConfigService', () => {
secret: '',
implicitFlow: true,
silentLogin: true,
redirectSilentIframeUri: 'http://localhost:3000/assets/silent-refresh.html',
redirectSilentIframeUri: 'http://localhost:3000/subfolder2/assets/silent-refresh.html',
redirectUri: '/subfolder2',
redirectUriLogout: '#/logout',
publicUrls: [
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('AuthConfigService', () => {
oidc: true,
issuer: 'http://localhost:3000/auth/realms/alfresco',
redirectUri: 'http://localhost:3000/#/view/authentication-confirmation/?',
silentRefreshRedirectUri: 'http://localhost:3000/silent-refresh.html',
silentRefreshRedirectUri: 'http://localhost:3000/assets/silent-refresh.html',
postLogoutRedirectUri: 'http://localhost:3000/#/logout',
clientId: 'fakeClientId',
scope: 'openid profile email',
Expand All @@ -151,7 +151,7 @@ describe('AuthConfigService', () => {
oidc: true,
issuer: 'http://localhost:3000/auth/realms/alfresco',
redirectUri: 'http://localhost:3000/#/view/authentication-confirmation',
silentRefreshRedirectUri: 'http://localhost:3000/silent-refresh.html',
silentRefreshRedirectUri: 'http://localhost:3000/assets/silent-refresh.html',
postLogoutRedirectUri: 'http://localhost:3000/#/logout',
clientId: 'fakeClientId',
scope: 'openid profile email',
Expand Down Expand Up @@ -182,4 +182,18 @@ describe('AuthConfigService', () => {
expect(service.getRedirectUri()).toBe(expectedUri);
});
});

describe('silentRefreshRedirectUri', () => {
it('should return the silentRefreshRedirectUri with subfolder path', () => {
const expectedUri = 'http://localhost:3000/subfolder/assets/silent-refresh.html';
spyOnProperty(appConfigService, 'oauth2').and.returnValue(mockAuthConfigSubfolderRedirectUri);
expect(service.loadAppConfig().silentRefreshRedirectUri).toBe(expectedUri);
});

it('should return the silentRefreshRedirectUri with subfolder2 path', () => {
const expectedUri = 'http://localhost:3000/subfolder2/assets/silent-refresh.html';
spyOnProperty(appConfigService, 'oauth2').and.returnValue(mockAuthConfigSubfolder2RedirectUri);
expect(service.loadAppConfig().silentRefreshRedirectUri).toBe(expectedUri);
});
});
});
2 changes: 1 addition & 1 deletion lib/core/src/lib/auth/oidc/auth-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AuthConfigService {
oidc: oauth2.implicitFlow || oauth2.codeFlow || false,
issuer: oauth2.host,
redirectUri,
silentRefreshRedirectUri: `${origin}/silent-refresh.html`,
silentRefreshRedirectUri: oauth2.redirectSilentIframeUri,
postLogoutRedirectUri: `${origin}/${oauth2.redirectUriLogout}`,
clientId: oauth2.clientId,
scope: oauth2.scope,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<mat-toolbar
[color]="color"
[style.background-color]="color"
[style.background-image]="'url(' + backgroundImage + ')'">
[style.background-image]="backgroundImage ? 'url(' + backgroundImage + ')' : 'none'">
<button
*ngIf="showSidenavToggle && position === 'start'"
id="adf-sidebar-toggle-start"
Expand Down
18 changes: 18 additions & 0 deletions lib/core/src/lib/layout/components/header/header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ describe('HeaderLayoutComponent', () => {
expect(await toolbar.getCssValue('background-color')).toBe('rgb(66, 245, 126)');
});

it('should background image be set to none if is not provided', async () => {
fixture.detectChanges();

const toolbarHarness = await loader.getHarness(MatToolbarHarness);
const toolbar = await toolbarHarness.host();
expect(await toolbar.getCssValue('background-image')).toEqual('none');
});

it('should background image be set to none if is provided as empty string', async () => {
component.backgroundImage = '';

fixture.detectChanges();

const toolbarHarness = await loader.getHarness(MatToolbarHarness);
const toolbar = await toolbarHarness.host();
expect(await toolbar.getCssValue('background-image')).toEqual('none');
});

it('should change background image when provided', async () => {
component.backgroundImage = '/assets/someImage.png';
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class HeaderLayoutComponent implements OnInit {
@Input() color: ThemePalette | string;

/** Path to a background image for the header. */
@Input() backgroundImage: string;
@Input() backgroundImage = '';

/**
* Toggles whether the sidenav button will be displayed in the header
Expand Down

0 comments on commit f2df3c4

Please sign in to comment.