fix: add cli
This commit is contained in:
@@ -346,11 +346,9 @@ describe('CheckSessionService', () => {
|
||||
|
||||
describe('checkSessionChanged$', () => {
|
||||
it('emits when internal event is thrown', async () => {
|
||||
checkSessionService.checkSessionChanged$
|
||||
.pipe(skip(1))
|
||||
.subscribe((result) => {
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
const result = await lastValueFrom(checkSessionService.checkSessionChanged$
|
||||
.pipe(skip(1)));
|
||||
expect(result).toBe(true);
|
||||
|
||||
const serviceAsAny = checkSessionService as any;
|
||||
|
||||
@@ -358,9 +356,8 @@ describe('CheckSessionService', () => {
|
||||
});
|
||||
|
||||
it('emits false initially', async () => {
|
||||
checkSessionService.checkSessionChanged$.subscribe((result) => {
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
const result = await lastValueFrom(checkSessionService.checkSessionChanged$);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('emits false then true when emitted', async () => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DOCUMENT } from '../dom';
|
||||
import { Injectable, NgZone, OnDestroy, inject } from 'injection-js';
|
||||
import { Injectable, NgZone, type OnDestroy, inject } from 'injection-js';
|
||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import type { OpenIdConfiguration } from '../config/openid-configuration';
|
||||
import { DOCUMENT } from '../dom';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
import { EventTypes } from '../public-events/event-types';
|
||||
import { PublicEventsService } from '../public-events/public-events.service';
|
||||
@@ -74,7 +74,7 @@ export class CheckSessionService implements OnDestroy {
|
||||
}
|
||||
|
||||
start(configuration: OpenIdConfiguration): void {
|
||||
if (!!this.scheduledHeartBeatRunning) {
|
||||
if (this.scheduledHeartBeatRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,13 +141,13 @@ export class CheckSessionService implements OnDestroy {
|
||||
return of();
|
||||
}
|
||||
|
||||
if (!contentWindow) {
|
||||
if (contentWindow) {
|
||||
contentWindow.location.replace(checkSessionIframe);
|
||||
} else {
|
||||
this.loggerService.logWarning(
|
||||
configuration,
|
||||
'CheckSession - init check session: IFrame contentWindow does not exist'
|
||||
);
|
||||
} else {
|
||||
contentWindow.location.replace(checkSessionIframe);
|
||||
}
|
||||
|
||||
return new Observable((observer) => {
|
||||
@@ -197,7 +197,7 @@ export class CheckSessionService implements OnDestroy {
|
||||
|
||||
this.outstandingMessages++;
|
||||
contentWindow.postMessage(
|
||||
clientId + ' ' + sessionState,
|
||||
`${clientId} ${sessionState}`,
|
||||
iframeOrigin
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TestBed } from '@/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { lastValueFrom, of } from 'rxjs';
|
||||
import { vi } from 'vitest';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
import { mockProvider } from '../testing/mock';
|
||||
@@ -20,9 +20,6 @@ describe('RefreshSessionIframeService ', () => {
|
||||
mockProvider(UrlService),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
refreshSessionIframeService = TestBed.inject(RefreshSessionIframeService);
|
||||
urlService = TestBed.inject(UrlService);
|
||||
});
|
||||
@@ -62,7 +59,9 @@ describe('RefreshSessionIframeService ', () => {
|
||||
it('dispatches customevent to window object', async () => {
|
||||
const dispatchEventSpy = vi.spyOn(window, 'dispatchEvent');
|
||||
|
||||
(refreshSessionIframeService as any).initSilentRenewRequest();
|
||||
await lastValueFrom(
|
||||
(refreshSessionIframeService as any).initSilentRenewRequest()
|
||||
);
|
||||
|
||||
expect(dispatchEventSpy).toHaveBeenCalledExactlyOnceWith(
|
||||
new CustomEvent('oidc-silent-renew-init', {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TestBed } from '@/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { TestBed, mockImplementationWhenArgsEqual } from '@/testing';
|
||||
import { lastValueFrom, of } from 'rxjs';
|
||||
import { vi } from 'vitest';
|
||||
import type { OpenIdConfiguration } from '../../config/openid-configuration';
|
||||
import { FlowsDataService } from '../../flows/flows-data.service';
|
||||
@@ -1044,9 +1044,8 @@ describe('UrlService Tests', () => {
|
||||
|
||||
describe('getAuthorizeUrl', () => {
|
||||
it('returns null if no config is given', async () => {
|
||||
service.getAuthorizeUrl(null).subscribe((url) => {
|
||||
expect(url).toBeNull();
|
||||
});
|
||||
const url = await lastValueFrom(service.getAuthorizeUrl(null));
|
||||
expect(url).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null if current flow is code flow and no redirect url is defined', async () => {
|
||||
@@ -1383,7 +1382,7 @@ describe('UrlService Tests', () => {
|
||||
|
||||
resultObs$.subscribe((result) => {
|
||||
expect(result).toBe(
|
||||
`client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256`
|
||||
'client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1414,7 +1413,7 @@ describe('UrlService Tests', () => {
|
||||
|
||||
resultObs$.subscribe((result) => {
|
||||
expect(result).toBe(
|
||||
`client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam`
|
||||
'client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1445,7 +1444,7 @@ describe('UrlService Tests', () => {
|
||||
|
||||
resultObs$.subscribe((result) => {
|
||||
expect(result).toBe(
|
||||
`client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam&any=thing`
|
||||
'client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam&any=thing'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1480,7 +1479,7 @@ describe('UrlService Tests', () => {
|
||||
|
||||
resultObs$.subscribe((result) => {
|
||||
expect(result).toBe(
|
||||
`client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam&any=thing&any=otherThing`
|
||||
'client_id=testClientId&redirect_uri=testRedirectUrl&response_type=testResponseType&scope=testScope&nonce=testNonce&state=testState&code_challenge=testCodeChallenge&code_challenge_method=S256&hd=testHdParam&any=thing&any=otherThing'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1904,8 +1903,7 @@ describe('UrlService Tests', () => {
|
||||
|
||||
resultObs$.subscribe((result: any) => {
|
||||
expect(result).toBe(
|
||||
`authorizationEndpoint?client_id=clientId&redirect_uri=http%3A%2F%2Fany-url.com` +
|
||||
`&response_type=${responseType}&scope=${scope}&nonce=${nonce}&state=${state}&to=add&as=well`
|
||||
`authorizationEndpoint?client_id=clientId&redirect_uri=http%3A%2F%2Fany-url.com&response_type=${responseType}&scope=${scope}&nonce=${nonce}&state=${state}&to=add&as=well`
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -2121,7 +2119,8 @@ describe('UrlService Tests', () => {
|
||||
const value = service.getEndSessionUrl(config);
|
||||
|
||||
// Assert
|
||||
const expectValue = `something.auth0.com/v2/logout?client_id=someClientId&returnTo=https://localhost:1234/unauthorized`;
|
||||
const expectValue =
|
||||
'something.auth0.com/v2/logout?client_id=someClientId&returnTo=https://localhost:1234/unauthorized';
|
||||
|
||||
expect(value).toEqual(expectValue);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user