fix: fix all biome

This commit is contained in:
2025-01-31 05:57:51 +08:00
parent 316361bd3c
commit c9d0066d64
114 changed files with 2255 additions and 2068 deletions

View File

@@ -39,9 +39,6 @@ describe('AuthWellKnownDataService', () => {
mockProvider(LoggerService),
],
});
});
beforeEach(() => {
service = TestBed.inject(AuthWellKnownDataService);
loggerService = TestBed.inject(LoggerService);
dataService = TestBed.inject(DataService);
@@ -73,7 +70,7 @@ describe('AuthWellKnownDataService', () => {
const dataServiceSpy = vi
.spyOn(dataService, 'get')
.mockReturnValue(of(null));
const urlWithSuffix = `myUrl/.well-known/openid-configuration`;
const urlWithSuffix = 'myUrl/.well-known/openid-configuration';
await lastValueFrom(
(service as any).getWellKnownDocument(urlWithSuffix, {
@@ -89,7 +86,8 @@ describe('AuthWellKnownDataService', () => {
const dataServiceSpy = vi
.spyOn(dataService, 'get')
.mockReturnValue(of(null));
const urlWithSuffix = `myUrl/.well-known/openid-configuration/and/some/more/stuff`;
const urlWithSuffix =
'myUrl/.well-known/openid-configuration/and/some/more/stuff';
await lastValueFrom(
(service as any).getWellKnownDocument(urlWithSuffix, {
@@ -105,7 +103,7 @@ describe('AuthWellKnownDataService', () => {
const dataServiceSpy = vi
.spyOn(dataService, 'get')
.mockReturnValue(of(null));
const urlWithoutSuffix = `myUrl`;
const urlWithoutSuffix = 'myUrl';
const urlWithSuffix = `${urlWithoutSuffix}/.well-known/test-openid-configuration`;
await lastValueFrom(
@@ -128,14 +126,13 @@ describe('AuthWellKnownDataService', () => {
)
);
(service as any)
.getWellKnownDocument('anyurl', { configId: 'configId1' })
.subscribe({
next: (res: unknown) => {
expect(res).toBeTruthy();
expect(res).toEqual(DUMMY_WELL_KNOWN_DOCUMENT);
},
});
const res: unknown = await lastValueFrom(
(service as any).getWellKnownDocument('anyurl', {
configId: 'configId1',
})
);
expect(res).toBeTruthy();
expect(res).toEqual(DUMMY_WELL_KNOWN_DOCUMENT);
});
it('should retry twice', async () => {
@@ -147,14 +144,13 @@ describe('AuthWellKnownDataService', () => {
)
);
(service as any)
.getWellKnownDocument('anyurl', { configId: 'configId1' })
.subscribe({
next: (res: any) => {
expect(res).toBeTruthy();
expect(res).toEqual(DUMMY_WELL_KNOWN_DOCUMENT);
},
});
const res: any = await lastValueFrom(
(service as any).getWellKnownDocument('anyurl', {
configId: 'configId1',
})
);
expect(res).toBeTruthy();
expect(res).toEqual(DUMMY_WELL_KNOWN_DOCUMENT);
});
it('should fail after three tries', async () => {
@@ -167,11 +163,13 @@ describe('AuthWellKnownDataService', () => {
)
);
(service as any).getWellKnownDocument('anyurl', 'configId').subscribe({
error: (err: unknown) => {
expect(err).toBeTruthy();
},
});
try {
await lastValueFrom(
(service as any).getWellKnownDocument('anyurl', 'configId')
);
} catch (err: unknown) {
expect(err).toBeTruthy();
}
});
});
@@ -181,7 +179,7 @@ describe('AuthWellKnownDataService', () => {
of({ jwks_uri: 'jwks_uri' })
);
const spy = vi.spyOn(service as any, 'getWellKnownDocument')();
const spy = vi.spyOn(service as any, 'getWellKnownDocument');
const result = await lastValueFrom(
service.getWellKnownEndPointsForConfig({
@@ -201,15 +199,15 @@ describe('AuthWellKnownDataService', () => {
authWellknownEndpointUrl: undefined,
};
service.getWellKnownEndPointsForConfig(config).subscribe({
error: (error) => {
expect(loggerSpy).toHaveBeenCalledExactlyOnceWith(
config,
'no authWellknownEndpoint given!'
);
expect(error.message).toEqual('no authWellknownEndpoint given!');
},
});
try {
await lastValueFrom(service.getWellKnownEndPointsForConfig(config));
} catch (error: any) {
expect(loggerSpy).toHaveBeenCalledExactlyOnceWith(
config,
'no authWellknownEndpoint given!'
);
expect(error.message).toEqual('no authWellknownEndpoint given!');
}
});
it('should merge the mapped endpoints with the provided endpoints', async () => {
@@ -233,7 +231,7 @@ describe('AuthWellKnownDataService', () => {
},
})
);
expect(result).toEqual(jasmine.objectContaining(expected));
expect(result).toEqual(expect.objectContaining(expected));
});
});
});

View File

@@ -1,12 +1,12 @@
import { inject, Injectable } from 'injection-js';
import { Observable, throwError } from 'rxjs';
import { type Observable, throwError } from 'rxjs';
import { map, retry } from 'rxjs/operators';
import { DataService } from '../../api/data.service';
import { LoggerService } from '../../logging/logger.service';
import { OpenIdConfiguration } from '../openid-configuration';
import { AuthWellKnownEndpoints } from './auth-well-known-endpoints';
import type { OpenIdConfiguration } from '../openid-configuration';
import type { AuthWellKnownEndpoints } from './auth-well-known-endpoints';
const WELL_KNOWN_SUFFIX = `/.well-known/openid-configuration`;
const WELL_KNOWN_SUFFIX = '/.well-known/openid-configuration';
@Injectable()
export class AuthWellKnownDataService {

View File

@@ -35,15 +35,15 @@ describe('AuthWellKnownService', () => {
describe('getAuthWellKnownEndPoints', () => {
it('getAuthWellKnownEndPoints throws an error if not config provided', async () => {
service.queryAndStoreAuthWellKnownEndPoints(null).subscribe({
error: (error) => {
expect(error).toEqual(
new Error(
'Please provide a configuration before setting up the module'
)
);
},
});
try {
await lastValueFrom(service.queryAndStoreAuthWellKnownEndPoints(null));
} catch (error) {
expect(error).toEqual(
new Error(
'Please provide a configuration before setting up the module'
)
);
}
});
it('getAuthWellKnownEndPoints calls always dataservice', async () => {
@@ -91,18 +91,18 @@ describe('AuthWellKnownService', () => {
);
const publicEventsServiceSpy = vi.spyOn(publicEventsService, 'fireEvent');
service
.queryAndStoreAuthWellKnownEndPoints({ configId: 'configId1' })
.subscribe({
error: (err) => {
expect(err).toBeTruthy();
expect(publicEventsServiceSpy).toHaveBeenCalledTimes(1);
expect(publicEventsServiceSpy).toHaveBeenCalledExactlyOnceWith(
EventTypes.ConfigLoadingFailed,
null
);
},
});
try {
await lastValueFrom(
service.queryAndStoreAuthWellKnownEndPoints({ configId: 'configId1' })
);
} catch (err: any) {
expect(err).toBeTruthy();
expect(publicEventsServiceSpy).toHaveBeenCalledTimes(1);
expect(publicEventsServiceSpy).toHaveBeenCalledExactlyOnceWith(
EventTypes.ConfigLoadingFailed,
null
);
}
});
});
});

View File

@@ -1,12 +1,12 @@
import { inject, Injectable } from 'injection-js';
import { Observable, throwError } from 'rxjs';
import { Injectable, inject } from 'injection-js';
import { type Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { EventTypes } from '../../public-events/event-types';
import { PublicEventsService } from '../../public-events/public-events.service';
import { StoragePersistenceService } from '../../storage/storage-persistence.service';
import { OpenIdConfiguration } from '../openid-configuration';
import type { OpenIdConfiguration } from '../openid-configuration';
import { AuthWellKnownDataService } from './auth-well-known-data.service';
import { AuthWellKnownEndpoints } from './auth-well-known-endpoints';
import type { AuthWellKnownEndpoints } from './auth-well-known-endpoints';
@Injectable()
export class AuthWellKnownService {