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 {

View File

@@ -276,7 +276,9 @@ describe('Configuration Service', () => {
false
);
await lastValueFrom(configService.getOpenIDConfigurations());
const { allConfigs, currentConfig } = await lastValueFrom(
configService.getOpenIDConfigurations()
);
expect(allConfigs).toEqual([]);
expect(currentConfig).toBeNull();
});

View File

@@ -1,5 +1,5 @@
import { LogLevel } from '../logging/log-level';
import { OpenIdConfiguration } from './openid-configuration';
import type { OpenIdConfiguration } from './openid-configuration';
export const DEFAULT_CONFIG: OpenIdConfiguration = {
authority: 'https://please_set',

View File

@@ -1,4 +1,3 @@
import { waitForAsync } from '@/testing';
import { lastValueFrom, of } from 'rxjs';
import type { OpenIdConfiguration } from '../openid-configuration';
import { StsConfigHttpLoader, StsConfigStaticLoader } from './config-loader';
@@ -46,8 +45,8 @@ describe('ConfigLoader', () => {
const result = await lastValueFrom(result$);
expect(Array.isArray(result)).toBeTruthy();
expect(result[0].configId).toBe('configId1');
expect(result[1].configId).toBe('configId2');
expect(result[0]!.configId).toBe('configId1');
expect(result[1]!.configId).toBe('configId2');
});
it('returns an array if an observable with a config array is passed', async () => {
@@ -61,8 +60,8 @@ describe('ConfigLoader', () => {
const result = await lastValueFrom(result$);
expect(Array.isArray(result)).toBeTruthy();
expect(result[0].configId).toBe('configId1');
expect(result[1].configId).toBe('configId2');
expect(result[0]!.configId).toBe('configId1');
expect(result[1]!.configId).toBe('configId2');
});
it('returns an array if only one config is passed', async () => {
@@ -74,7 +73,7 @@ describe('ConfigLoader', () => {
const result = await lastValueFrom(result$);
expect(Array.isArray(result)).toBeTruthy();
expect(result[0].configId).toBe('configId1');
expect(result[0]!.configId).toBe('configId1');
});
});
});

View File

@@ -1,7 +1,7 @@
import { inject, Injectable } from 'injection-js';
import { Injectable, inject } from 'injection-js';
import { LoggerService } from '../../logging/logger.service';
import { OpenIdConfiguration } from '../openid-configuration';
import { Level, RuleValidationResult } from './rule';
import type { OpenIdConfiguration } from '../openid-configuration';
import type { Level, RuleValidationResult } from './rule';
import { allMultipleConfigRules, allRules } from './rules';
@Injectable()
@@ -35,14 +35,14 @@ export class ConfigValidationService {
let overallErrorCount = 0;
passedConfigs.forEach((passedConfig) => {
for (const passedConfig of passedConfigs) {
const errorCount = this.processValidationResultsAndGetErrorCount(
allValidationResults,
passedConfig
);
overallErrorCount += errorCount;
});
}
return overallErrorCount === 0;
}
@@ -75,12 +75,12 @@ export class ConfigValidationService {
const allErrorMessages = this.getAllMessagesOfType('error', allMessages);
const allWarnings = this.getAllMessagesOfType('warning', allMessages);
allErrorMessages.forEach((message) =>
this.loggerService.logError(config, message)
);
allWarnings.forEach((message) =>
this.loggerService.logWarning(config, message)
);
for (const message of allErrorMessages) {
this.loggerService.logError(config, message);
}
for (const message of allWarnings) {
this.loggerService.logWarning(config, message);
}
return allErrorMessages.length;
}

View File

@@ -1,4 +1,4 @@
import { OpenIdConfiguration } from '../openid-configuration';
import type { OpenIdConfiguration } from '../openid-configuration';
export interface Rule {
validate(passedConfig: OpenIdConfiguration): RuleValidationResult;

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
export const ensureAuthority = (
passedConfig: OpenIdConfiguration

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
export const ensureClientId = (
passedConfig: OpenIdConfiguration

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
const createIdentifierToCheck = (passedConfig: OpenIdConfiguration): string => {
if (!passedConfig) {

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
export const ensureRedirectRule = (
passedConfig: OpenIdConfiguration

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
export const ensureSilentRenewUrlWhenNoRefreshTokenUsed = (
passedConfig: OpenIdConfiguration

View File

@@ -1,5 +1,5 @@
import { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, RuleValidationResult } from '../rule';
import type { OpenIdConfiguration } from '../../openid-configuration';
import { POSITIVE_VALIDATION_RESULT, type RuleValidationResult } from '../rule';
export const useOfflineScopeWithSilentRenew = (
passedConfig: OpenIdConfiguration