Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-17909][AAE-17964] fix silent-refresh url is not set with the value - fix background image set to undefined #9080

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading