mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Replace linting configurations
The previous package was outdated, preventing us from updating TS. This one also lints YAML and JSON, and applies many more rules to the test files, explaining all the changes in this PR.
This commit is contained in:
@@ -7,7 +7,6 @@ import { NotImplementedHttpError } from '../../../src/util/errors/NotImplemented
|
||||
|
||||
let clientId: string | undefined;
|
||||
const solidTokenVerifier = jest.fn(async(): Promise<SolidAccessTokenPayload> =>
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
({ aud: 'solid', exp: 1234, iat: 1234, iss: 'example.com/idp', webid: 'http://alice.example/card#me', client_id: clientId }));
|
||||
jest.mock('@solid/access-token-verifier', (): any =>
|
||||
({ createSolidTokenVerifier: (): SolidTokenVerifierFunction => solidTokenVerifier }));
|
||||
|
||||
@@ -8,7 +8,6 @@ import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
|
||||
|
||||
let clientId: string | undefined;
|
||||
const solidTokenVerifier = jest.fn(async(): Promise<SolidAccessTokenPayload> =>
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
({ aud: 'solid', exp: 1234, iat: 1234, iss: 'example.com/idp', webid: 'http://alice.example/card#me', client_id: clientId }));
|
||||
jest.mock('@solid/access-token-verifier', (): any =>
|
||||
({ createSolidTokenVerifier: (): SolidTokenVerifierFunction => solidTokenVerifier }));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AuxiliaryReader } from '../../../src/authorization/AuxiliaryReader';
|
||||
import type { PermissionReaderInput, PermissionReader } from '../../../src/authorization/PermissionReader';
|
||||
import type { PermissionReader, PermissionReaderInput } from '../../../src/authorization/PermissionReader';
|
||||
import type { AccessMap, PermissionMap, PermissionSet } from '../../../src/authorization/permissions/Permissions';
|
||||
import { AccessMode } from '../../../src/authorization/permissions/Permissions';
|
||||
import type { AuxiliaryStrategy } from '../../../src/http/auxiliary/AuxiliaryStrategy';
|
||||
|
||||
@@ -2,9 +2,9 @@ import type { Credentials } from '../../../src/authentication/Credentials';
|
||||
import { OwnerPermissionReader } from '../../../src/authorization/OwnerPermissionReader';
|
||||
import { AclMode } from '../../../src/authorization/permissions/AclPermissionSet';
|
||||
import type { AccessMap } from '../../../src/authorization/permissions/Permissions';
|
||||
import { AuxiliaryIdentifierStrategy } from '../../../src/http/auxiliary/AuxiliaryIdentifierStrategy';
|
||||
import type { AuxiliaryIdentifierStrategy } from '../../../src/http/auxiliary/AuxiliaryIdentifierStrategy';
|
||||
import type { ResourceIdentifier } from '../../../src/http/representation/ResourceIdentifier';
|
||||
import { PodStore } from '../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { PodStore } from '../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { StorageLocationStrategy } from '../../../src/server/description/StorageLocationStrategy';
|
||||
import { IdentifierMap, IdentifierSetMultiMap } from '../../../src/util/map/IdentifierMap';
|
||||
import { compareMaps } from '../../util/Util';
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { Representation } from '../../../../src/http/representation/Represe
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import * as fetchUtil from '../../../../src/util/FetchUtil';
|
||||
import { ACL, VCARD } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
describe('An AgentGroupAccessChecker', (): void => {
|
||||
|
||||
@@ -8,7 +8,6 @@ import type { Guarded } from '../../../src/util/GuardedStream';
|
||||
import { AS } from '../../../src/util/Vocabularies';
|
||||
|
||||
jest.mock('ws', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
WebSocketServer: jest.fn().mockImplementation((): any => ({
|
||||
handleUpgrade(upgradeRequest: any, socket: any, head: any, callback: any): void {
|
||||
callback(socket, upgradeRequest);
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { HttpRequest } from '../../../../../src/server/HttpRequest';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
import { UnsupportedMediaTypeHttpError } from '../../../../../src/util/errors/UnsupportedMediaTypeHttpError';
|
||||
import { guardedStreamFrom } from '../../../../../src/util/StreamUtil';
|
||||
|
||||
const { defaultGraph, literal, namedNode, quad, variable } = DataFactory;
|
||||
|
||||
describe('An N3PatchBodyParser', (): void => {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHt
|
||||
import { UnsupportedMediaTypeHttpError } from '../../../../../src/util/errors/UnsupportedMediaTypeHttpError';
|
||||
import { ContentType } from '../../../../../src/util/Header';
|
||||
import { guardedStreamFrom } from '../../../../../src/util/StreamUtil';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
describe('A SparqlUpdateBodyParser', (): void => {
|
||||
@@ -39,6 +40,7 @@ describe('A SparqlUpdateBodyParser', (): void => {
|
||||
|
||||
it('errors when receiving an unexpected error.', async(): Promise<void> => {
|
||||
const mock = jest.spyOn(algebra, 'translate').mockImplementationOnce((): any => {
|
||||
// eslint-disable-next-line ts/no-throw-literal
|
||||
throw 'apple';
|
||||
});
|
||||
input.request = guardedStreamFrom(
|
||||
|
||||
@@ -34,7 +34,6 @@ describe('An AcceptPreferenceParser', (): void => {
|
||||
it('parses accept-datetime headers.', async(): Promise<void> => {
|
||||
request.headers = { 'accept-datetime': 'Tue, 20 Mar 2001 20:35:00 GMT' };
|
||||
await expect(preferenceParser.handle({ request }))
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
.resolves.toEqual({ datetime: { 'Tue, 20 Mar 2001 20:35:00 GMT': 1 }});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PreferenceParser } from '../../../../../src/http/input/preferences/PreferenceParser';
|
||||
import type { PreferenceParser } from '../../../../../src/http/input/preferences/PreferenceParser';
|
||||
import { UnionPreferenceParser } from '../../../../../src/http/input/preferences/UnionPreferenceParser';
|
||||
import { InternalServerError } from '../../../../../src/util/errors/InternalServerError';
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { RepresentationMetadata } from '../../../../src/http/representation/Repr
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode } = DataFactory;
|
||||
|
||||
describe('BasicRepresentation', (): void => {
|
||||
|
||||
@@ -4,7 +4,8 @@ import { DataFactory } from 'n3';
|
||||
import type { NamedNode, Quad } from 'rdf-js';
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import { ContentType } from '../../../../src/util/Header';
|
||||
import { CONTENT_TYPE_TERM, SOLID_META, RDFS } from '../../../../src/util/Vocabularies';
|
||||
import { CONTENT_TYPE_TERM, RDFS, SOLID_META } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { defaultGraph, literal, namedNode, quad } = DataFactory;
|
||||
|
||||
// Helper functions to filter quads
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AccountInitializer } from '../../../src/identity/AccountInitializer';
|
||||
import { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
|
||||
import { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
|
||||
import type { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
|
||||
import type { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
|
||||
|
||||
describe('An AccountInitializer', (): void => {
|
||||
const email = 'email@example.com';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { interactionPolicy } from 'oidc-provider';
|
||||
import type { KoaContextWithOIDC } from 'oidc-provider';
|
||||
import { AccountPromptFactory } from '../../../../src/identity/configuration/AccountPromptFactory';
|
||||
import { CookieStore } from '../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import { WebIdStore } from '../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { CookieStore } from '../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import type { WebIdStore } from '../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import DefaultPolicy = interactionPolicy.DefaultPolicy;
|
||||
import Prompt = interactionPolicy.Prompt;
|
||||
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import { Readable } from 'stream';
|
||||
import { exportJWK, generateKeyPair } from 'jose';
|
||||
import type * as Koa from 'koa';
|
||||
import { ErrorHandler } from '../../../../src/http/output/error/ErrorHandler';
|
||||
import { ResponseWriter } from '../../../../src/http/output/ResponseWriter';
|
||||
import type { ErrorHandler } from '../../../../src/http/output/error/ErrorHandler';
|
||||
import type { ResponseWriter } from '../../../../src/http/output/ResponseWriter';
|
||||
import { IdentityProviderFactory } from '../../../../src/identity/configuration/IdentityProviderFactory';
|
||||
import type { JwkGenerator } from '../../../../src/identity/configuration/JwkGenerator';
|
||||
import { PromptFactory } from '../../../../src/identity/configuration/PromptFactory';
|
||||
import {
|
||||
import type { PromptFactory } from '../../../../src/identity/configuration/PromptFactory';
|
||||
import type {
|
||||
ClientCredentialsStore,
|
||||
} from '../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import type { Interaction } from '../../../../src/identity/interaction/InteractionHandler';
|
||||
import type { InteractionRoute } from '../../../../src/identity/interaction/routing/InteractionRoute';
|
||||
import type { AdapterFactory } from '../../../../src/identity/storage/AdapterFactory';
|
||||
import { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
import { extractErrorTerms } from '../../../../src/util/errors/HttpErrorUtil';
|
||||
import { OAuthHttpError } from '../../../../src/util/errors/OAuthHttpError';
|
||||
import type { errors, Configuration, KoaContextWithOIDC } from '../../../../templates/types/oidc-provider';
|
||||
import type { Configuration, errors, KoaContextWithOIDC } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
jest.mock('oidc-provider', (): any => {
|
||||
const fn = jest.fn((issuer: string, config: Configuration): any => ({ issuer, config, use: jest.fn() }));
|
||||
// The base export is the Provider class, but we also need some of the deeper exports like interactionPolicy
|
||||
@@ -69,11 +68,6 @@ describe('An IdentityProviderFactory', (): void => {
|
||||
delete process.env.NODE_ENV;
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
process.env.JEST_WORKER_ID = jestWorkerId;
|
||||
process.env.NODE_ENV = nodeEnv;
|
||||
});
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
// Disabling devInteractions to prevent warnings when testing the path
|
||||
// where we use the actual library instead of a mock.
|
||||
@@ -145,6 +139,11 @@ describe('An IdentityProviderFactory', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
process.env.JEST_WORKER_ID = jestWorkerId;
|
||||
process.env.NODE_ENV = nodeEnv;
|
||||
});
|
||||
|
||||
it('creates a correct configuration.', async(): Promise<void> => {
|
||||
// This is the output of our mock function
|
||||
const provider = await factory.getProvider() as any;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
|
||||
import type {
|
||||
AccountStore } from '../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import {
|
||||
ACCOUNT_SETTINGS_REMEMBER_LOGIN,
|
||||
AccountStore,
|
||||
} from '../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import { CookieStore } from '../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import type { CookieStore } from '../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import { CookieInteractionHandler } from '../../../../src/identity/interaction/CookieInteractionHandler';
|
||||
import type { JsonRepresentation } from '../../../../src/identity/interaction/InteractionUtil';
|
||||
import type {
|
||||
|
||||
@@ -77,7 +77,6 @@ describe('InteractionUtil', (): void => {
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
provider = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
Session: {
|
||||
find: jest.fn().mockResolvedValue({
|
||||
accountId: 'accountId',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import type { AccountIdRoute } from '../../../../src/identity/interaction/account/AccountIdRoute';
|
||||
import type { InteractionHandlerInput,
|
||||
InteractionHandler } from '../../../../src/identity/interaction/InteractionHandler';
|
||||
import type { InteractionHandler,
|
||||
InteractionHandlerInput } from '../../../../src/identity/interaction/InteractionHandler';
|
||||
import { LockingInteractionHandler } from '../../../../src/identity/interaction/LockingInteractionHandler';
|
||||
import type { ReadWriteLocker } from '../../../../src/util/locking/ReadWriteLocker';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import type { JsonInteractionHandlerInput,
|
||||
JsonInteractionHandler } from '../../../../src/identity/interaction/JsonInteractionHandler';
|
||||
import type { JsonInteractionHandler,
|
||||
JsonInteractionHandlerInput } from '../../../../src/identity/interaction/JsonInteractionHandler';
|
||||
import type { JsonView } from '../../../../src/identity/interaction/JsonView';
|
||||
import { ViewInteractionHandler } from '../../../../src/identity/interaction/ViewInteractionHandler';
|
||||
import { MethodNotAllowedHttpError } from '../../../../src/util/errors/MethodNotAllowedHttpError';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CreateAccountHandler } from '../../../../../src/identity/interaction/account/CreateAccountHandler';
|
||||
import { AccountStore } from '../../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import type { AccountStore } from '../../../../../src/identity/interaction/account/util/AccountStore';
|
||||
|
||||
describe('A CreateAccountHandler', (): void => {
|
||||
const accountId = 'accountId';
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import {
|
||||
assertAccountId, parsePath, verifyAccountId,
|
||||
} from '../../../../../../src/identity/interaction/account/util/AccountUtil';
|
||||
|
||||
import { InteractionRoute } from '../../../../../../src/identity/interaction/routing/InteractionRoute';
|
||||
import type { InteractionRoute } from '../../../../../../src/identity/interaction/routing/InteractionRoute';
|
||||
import { InternalServerError } from '../../../../../../src/util/errors/InternalServerError';
|
||||
import { NotFoundHttpError } from '../../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { ACCOUNT_SETTINGS_REMEMBER_LOGIN } from '../../../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import { BaseAccountStore } from '../../../../../../src/identity/interaction/account/util/BaseAccountStore';
|
||||
import type {
|
||||
AccountLoginStorage } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
ACCOUNT_TYPE,
|
||||
AccountLoginStorage,
|
||||
} from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { InternalServerError } from '../../../../../../src/util/errors/InternalServerError';
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Adapter } from 'oidc-provider';
|
||||
import type { Adapter } from 'oidc-provider';
|
||||
import {
|
||||
ClientCredentialsAdapter, ClientCredentialsAdapterFactory,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/ClientCredentialsAdapterFactory';
|
||||
import type {
|
||||
ClientCredentials,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import {
|
||||
ClientCredentialsStore,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { AdapterFactory } from '../../../../../src/identity/storage/AdapterFactory';
|
||||
|
||||
describe('A ClientCredentialsAdapterFactory', (): void => {
|
||||
@@ -82,7 +80,6 @@ describe('A ClientCredentialsAdapterFactory', (): void => {
|
||||
});
|
||||
|
||||
it('returns valid client_credentials Client metadata if a matching token was found.', async(): Promise<void> => {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
await expect(adapter.find(label)).resolves.toEqual({
|
||||
client_id: label,
|
||||
client_secret: secret,
|
||||
@@ -90,7 +87,7 @@ describe('A ClientCredentialsAdapterFactory', (): void => {
|
||||
redirect_uris: [],
|
||||
response_types: [],
|
||||
});
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
|
||||
expect(sourceAdapter.find).toHaveBeenCalledTimes(1);
|
||||
expect(sourceAdapter.find).toHaveBeenLastCalledWith(label);
|
||||
expect(credentialsStore.findByLabel).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
import type {
|
||||
ClientCredentialsIdRoute,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsIdRoute';
|
||||
import {
|
||||
import type {
|
||||
ClientCredentialsStore,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
@@ -6,11 +6,9 @@ import type {
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsIdRoute';
|
||||
import type {
|
||||
ClientCredentials,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import {
|
||||
ClientCredentialsStore,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
|
||||
const uuid = '4c9b88c1-7502-4107-bb79-2a3a590c7aa3';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
import type {
|
||||
ClientCredentialsIdRoute,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsIdRoute';
|
||||
import {
|
||||
import type {
|
||||
ClientCredentialsStore,
|
||||
} from '../../../../../src/identity/interaction/client-credentials/util/ClientCredentialsStore';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
AccountLoginStorage } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
ACCOUNT_TYPE,
|
||||
AccountLoginStorage,
|
||||
} from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
BaseClientCredentialsStore,
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('A LogoutHandler', (): void => {
|
||||
expect(outputMetadata?.get(SOLID_HTTP.terms.accountCookie)?.value).toBe(cookie);
|
||||
const date = outputMetadata?.get(SOLID_HTTP.terms.accountCookieExpiration);
|
||||
expect(date).toBeDefined();
|
||||
expect(new Date(date!.value) < new Date()).toBe(true);
|
||||
expect(new Date(date!.value).getTime()).toBeLessThan(new Date().getTime());
|
||||
expect(cookieStore.delete).toHaveBeenCalledTimes(1);
|
||||
expect(cookieStore.delete).toHaveBeenLastCalledWith(cookie);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { RepresentationMetadata } from '../../../../../src/http/representation/RepresentationMetadata';
|
||||
import { ACCOUNT_SETTINGS_REMEMBER_LOGIN,
|
||||
import type {
|
||||
AccountStore } from '../../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import { CookieStore } from '../../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import { ACCOUNT_SETTINGS_REMEMBER_LOGIN } from '../../../../../src/identity/interaction/account/util/AccountStore';
|
||||
import type { CookieStore } from '../../../../../src/identity/interaction/account/util/CookieStore';
|
||||
import type { JsonRepresentation } from '../../../../../src/identity/interaction/InteractionUtil';
|
||||
import type { JsonInteractionHandlerInput } from '../../../../../src/identity/interaction/JsonInteractionHandler';
|
||||
import type { LoginOutputType } from '../../../../../src/identity/interaction/login/ResolveLoginHandler';
|
||||
|
||||
@@ -26,7 +26,6 @@ describe('A CancelOidcHandler', (): void => {
|
||||
expect(oidcInteraction.persist).toHaveBeenCalledTimes(1);
|
||||
expect(oidcInteraction.result).toEqual({
|
||||
error: 'access_denied',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
error_description: 'User cancelled the interaction.',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import { ClientInfoHandler } from '../../../../../src/identity/interaction/oidc/
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
import type Provider from '../../../../../templates/types/oidc-provider';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
describe('A ClientInfoHandler', (): void => {
|
||||
let oidcInteraction: Interaction;
|
||||
const clientMetadata = {
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('A ConsentHandler', (): void => {
|
||||
accountId,
|
||||
persist: jest.fn(),
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
|
||||
params: { client_id: clientId },
|
||||
prompt: { details: {}},
|
||||
persist: jest.fn(),
|
||||
@@ -68,12 +68,10 @@ describe('A ConsentHandler', (): void => {
|
||||
grantFn = jest.fn((props): DummyGrant => new DummyGrant(props)) as any;
|
||||
grantFn.find = jest.fn((grantId: string): any => grantId ? knownGrant : undefined);
|
||||
provider = {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
Grant: grantFn,
|
||||
Session: {
|
||||
find: (): unknown => oidcInteraction.session,
|
||||
},
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
} as any;
|
||||
|
||||
providerFactory = {
|
||||
|
||||
@@ -20,11 +20,9 @@ describe('A ForgetWebIdHandler', (): void => {
|
||||
} as any;
|
||||
|
||||
provider = {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
Session: {
|
||||
find: jest.fn().mockResolvedValue({ persist: jest.fn() }),
|
||||
},
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
} as any;
|
||||
|
||||
providerFactory = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { ProviderFactory } from '../../../../../src/identity/configuration/ProviderFactory';
|
||||
import type { Interaction } from '../../../../../src/identity/interaction/InteractionHandler';
|
||||
import { PickWebIdHandler } from '../../../../../src/identity/interaction/oidc/PickWebIdHandler';
|
||||
import { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
import { FoundHttpError } from '../../../../../src/util/errors/FoundHttpError';
|
||||
import type Provider from '../../../../../templates/types/oidc-provider';
|
||||
@@ -35,11 +35,9 @@ describe('A PickWebIdHandler', (): void => {
|
||||
} satisfies Partial<WebIdStore> as any;
|
||||
|
||||
provider = {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
Session: {
|
||||
find: jest.fn().mockResolvedValue({ persist: jest.fn() }),
|
||||
},
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
} as any;
|
||||
|
||||
providerFactory = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CreatePasswordHandler } from '../../../../../src/identity/interaction/password/CreatePasswordHandler';
|
||||
import type { PasswordIdRoute } from '../../../../../src/identity/interaction/password/util/PasswordIdRoute';
|
||||
import { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
|
||||
describe('A CreatePasswordHandler', (): void => {
|
||||
const id = 'id';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DeletePasswordHandler } from '../../../../../src/identity/interaction/password/DeletePasswordHandler';
|
||||
import type { PasswordIdRoute } from '../../../../../src/identity/interaction/password/util/PasswordIdRoute';
|
||||
import { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
describe('A DeletePasswordHandler', (): void => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ForgotPasswordHandler } from '../../../../../src/identity/interaction/password/ForgotPasswordHandler';
|
||||
import { EmailSender } from '../../../../../src/identity/interaction/password/util/EmailSender';
|
||||
import { ForgotPasswordStore } from '../../../../../src/identity/interaction/password/util/ForgotPasswordStore';
|
||||
import { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { EmailSender } from '../../../../../src/identity/interaction/password/util/EmailSender';
|
||||
import type { ForgotPasswordStore } from '../../../../../src/identity/interaction/password/util/ForgotPasswordStore';
|
||||
import type { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { InteractionRoute } from '../../../../../src/identity/interaction/routing/InteractionRoute';
|
||||
import { TemplateEngine } from '../../../../../src/util/templates/TemplateEngine';
|
||||
import type { TemplateEngine } from '../../../../../src/util/templates/TemplateEngine';
|
||||
|
||||
describe('A ForgotPasswordHandler', (): void => {
|
||||
const id = 'id';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PasswordLoginHandler } from '../../../../../src/identity/interaction/password/PasswordLoginHandler';
|
||||
import { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
|
||||
describe('A PasswordLoginHandler', (): void => {
|
||||
let json: unknown;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UpdatePasswordHandler } from '../../../../../src/identity/interaction/password/UpdatePasswordHandler';
|
||||
import type { PasswordIdRoute } from '../../../../../src/identity/interaction/password/util/PasswordIdRoute';
|
||||
import { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PasswordStore } from '../../../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
describe('An UpdatePasswordHandler', (): void => {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { hash } from 'bcryptjs';
|
||||
import type {
|
||||
AccountLoginStorage } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
ACCOUNT_TYPE,
|
||||
AccountLoginStorage,
|
||||
} from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { BasePasswordStore } from '../../../../../../src/identity/interaction/password/util/BasePasswordStore';
|
||||
import { InternalServerError } from '../../../../../../src/util/errors/InternalServerError';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CreatePodHandler } from '../../../../../src/identity/interaction/pod/CreatePodHandler';
|
||||
import type { PodIdRoute } from '../../../../../src/identity/interaction/pod/PodIdRoute';
|
||||
import { PodCreator } from '../../../../../src/identity/interaction/pod/util/PodCreator';
|
||||
import { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { PodCreator } from '../../../../../src/identity/interaction/pod/util/PodCreator';
|
||||
import type { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { WebIdLinkRoute } from '../../../../../src/identity/interaction/webid/WebIdLinkRoute';
|
||||
|
||||
describe('A CreatePodHandler', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PodIdRoute } from '../../../../../src/identity/interaction/pod/PodIdRoute';
|
||||
import { UpdateOwnerHandler } from '../../../../../src/identity/interaction/pod/UpdateOwnerHandler';
|
||||
import { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
describe('An UpdateOwnerHandler', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BasePodCreator } from '../../../../../../src/identity/interaction/pod/util/BasePodCreator';
|
||||
import { PodStore } from '../../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import { WebIdStore } from '../../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { PodStore } from '../../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { WebIdStore } from '../../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { IdentifierGenerator } from '../../../../../../src/pods/generate/IdentifierGenerator';
|
||||
|
||||
describe('A BasePodCreator', (): void => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
AccountLoginStorage } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
ACCOUNT_TYPE,
|
||||
AccountLoginStorage,
|
||||
} from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { BasePodStore } from '../../../../../../src/identity/interaction/pod/util/BasePodStore';
|
||||
import type { PodManager } from '../../../../../../src/pods/PodManager';
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { ServerResponse } from 'http';
|
||||
import { createResponse } from 'node-mocks-http';
|
||||
import { RepresentationMetadata } from '../../../../../../src/http/representation/RepresentationMetadata';
|
||||
import { OwnerMetadataWriter } from '../../../../../../src/identity/interaction/pod/util/OwnerMetadataWriter';
|
||||
import { PodStore } from '../../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { PodStore } from '../../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { StorageLocationStrategy } from '../../../../../../src/server/description/StorageLocationStrategy';
|
||||
import type { HttpResponse } from '../../../../../../src/server/HttpResponse';
|
||||
import { joinUrl } from '../../../../../../src/util/PathUtil';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import type { PodStore } from '../../../../../src/identity/interaction/pod/util/PodStore';
|
||||
import { LinkWebIdHandler } from '../../../../../src/identity/interaction/webid/LinkWebIdHandler';
|
||||
import { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdLinkRoute } from '../../../../../src/identity/interaction/webid/WebIdLinkRoute';
|
||||
import { OwnershipValidator } from '../../../../../src/identity/ownership/OwnershipValidator';
|
||||
import { StorageLocationStrategy } from '../../../../../src/server/description/StorageLocationStrategy';
|
||||
import type { OwnershipValidator } from '../../../../../src/identity/ownership/OwnershipValidator';
|
||||
import type { StorageLocationStrategy } from '../../../../../src/server/description/StorageLocationStrategy';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
|
||||
describe('A LinkWebIdHandler', (): void => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UnlinkWebIdHandler } from '../../../../../src/identity/interaction/webid/UnlinkWebIdHandler';
|
||||
import { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdStore } from '../../../../../src/identity/interaction/webid/util/WebIdStore';
|
||||
import type { WebIdLinkRoute } from '../../../../../src/identity/interaction/webid/WebIdLinkRoute';
|
||||
import { NotFoundHttpError } from '../../../../../src/util/errors/NotFoundHttpError';
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ACCOUNT_TYPE,
|
||||
import type {
|
||||
AccountLoginStorage } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { ACCOUNT_TYPE } from '../../../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { BaseWebIdStore } from '../../../../../../src/identity/interaction/webid/util/BaseWebIdStore';
|
||||
import { BadRequestHttpError } from '../../../../../../src/util/errors/BadRequestHttpError';
|
||||
import { InternalServerError } from '../../../../../../src/util/errors/InternalServerError';
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { ExpiringStorage } from '../../../../src/storage/keyvalue/ExpiringS
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
import { extractErrorTerms } from '../../../../src/util/errors/HttpErrorUtil';
|
||||
import { SOLID } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { literal, namedNode, quad } = DataFactory;
|
||||
|
||||
jest.mock('uuid');
|
||||
|
||||
@@ -6,7 +6,6 @@ import type { Adapter } from '../../../../templates/types/oidc-provider';
|
||||
|
||||
jest.mock('cross-fetch');
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
describe('A ClientIdAdapterFactory', (): void => {
|
||||
const fetchMock: jest.Mock = fetch as any;
|
||||
const id = 'https://app.example.com/card#me';
|
||||
|
||||
@@ -90,7 +90,6 @@ jest.mock('../../../src/init/cluster/SingleThreaded', (): any => ({
|
||||
}));
|
||||
|
||||
jest.mock('componentsjs', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ComponentsManager: {
|
||||
build: jest.fn(async(): Promise<ComponentsManager<App>> => manager),
|
||||
},
|
||||
@@ -439,7 +438,7 @@ describe('AppRunner', (): void => {
|
||||
it('checks for threading issues when starting in multithreaded mode.', async(): Promise<void> => {
|
||||
const createdApp = await new AppRunner().createCli();
|
||||
expect(createdApp).toBe(app);
|
||||
expect(listSingleThreadedComponentsMock).toHaveBeenCalled();
|
||||
expect(listSingleThreadedComponentsMock).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('throws an error if there are threading issues detected.', async(): Promise<void> => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { writeJson } from 'fs-extra';
|
||||
import { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
|
||||
import { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
|
||||
import type { AccountStore } from '../../../src/identity/interaction/account/util/AccountStore';
|
||||
import type { PasswordStore } from '../../../src/identity/interaction/password/util/PasswordStore';
|
||||
import type { PodCreator } from '../../../src/identity/interaction/pod/util/PodCreator';
|
||||
import { SeededAccountInitializer } from '../../../src/init/SeededAccountInitializer';
|
||||
import { mockFileSystem } from '../../util/Util';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { YargsParameter, YargsCliExtractor } from '../../../../src/init/cli/YargsCliExtractor';
|
||||
import { YargsCliExtractor, YargsParameter } from '../../../../src/init/cli/YargsCliExtractor';
|
||||
|
||||
const error = jest.spyOn(console, 'error').mockImplementation(jest.fn());
|
||||
const log = jest.spyOn(console, 'log').mockImplementation(jest.fn());
|
||||
@@ -76,7 +76,6 @@ describe('A YargsCliExtractor', (): void => {
|
||||
// This can probably be fixed by changing jest setup to already load the custom env before loading the tests,
|
||||
// but does not seem worth it just for this test.
|
||||
const { env } = process;
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
process.env = { ...env, TEST_ENV_PORT: '3333' };
|
||||
extractor = new YargsCliExtractor(parameters, { loadFromEnv: true, envVarPrefix: 'TEST_ENV' });
|
||||
const argv = [ 'node', 'script', '-b', 'http://localhost:3333/' ];
|
||||
|
||||
@@ -22,7 +22,6 @@ function mockComponentsManagerFn(length: number): jest.Mocked<ComponentsManager<
|
||||
}
|
||||
|
||||
jest.mock('jsonld-context-parser/lib/ContextParser', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ContextParser: jest.fn().mockImplementation((): any => ({
|
||||
parse: jest.fn(async(): Promise<any> => ({
|
||||
expandTerm: jest.fn((): any => myExpandTerm()),
|
||||
@@ -31,11 +30,9 @@ jest.mock('jsonld-context-parser/lib/ContextParser', (): any => ({
|
||||
}));
|
||||
|
||||
jest.mock('componentsjs', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ComponentsManager: {
|
||||
build: jest.fn(async(props: any): Promise<ComponentsManager<any>> => mockComponentsManagerFn(props.length)),
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
PrefetchedDocumentLoader: jest.fn().mockImplementation((): any => ({
|
||||
load: jest.fn(),
|
||||
})),
|
||||
|
||||
@@ -10,6 +10,6 @@ describe('A WorkerManager', (): void => {
|
||||
const wm = new WorkerManager(cm);
|
||||
Object.assign(cm, { spawnWorkers: jest.fn() });
|
||||
await wm.handle();
|
||||
expect(cm.spawnWorkers).toHaveBeenCalled();
|
||||
expect(cm.spawnWorkers).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { BasicRepresentation } from '../../../../src/http/representation/BasicRe
|
||||
import type { Representation } from '../../../../src/http/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
|
||||
import { SingleContainerJsonStorage } from '../../../../src/init/migration/SingleContainerJsonStorage';
|
||||
import { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import type { ResourceStore } from '../../../../src/storage/ResourceStore';
|
||||
import { NotFoundHttpError } from '../../../../src/util/errors/NotFoundHttpError';
|
||||
import { isContainerIdentifier } from '../../../../src/util/PathUtil';
|
||||
import { LDP } from '../../../../src/util/Vocabularies';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ACCOUNT_TYPE, AccountLoginStorage } from '../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import type { AccountLoginStorage } from '../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import { ACCOUNT_TYPE } from '../../../../src/identity/interaction/account/util/LoginStorage';
|
||||
import {
|
||||
CLIENT_CREDENTIALS_STORAGE_TYPE,
|
||||
} from '../../../../src/identity/interaction/client-credentials/util/BaseClientCredentialsStore';
|
||||
@@ -6,7 +7,7 @@ import { PASSWORD_STORAGE_TYPE } from '../../../../src/identity/interaction/pass
|
||||
import { OWNER_STORAGE_TYPE, POD_STORAGE_TYPE } from '../../../../src/identity/interaction/pod/util/BasePodStore';
|
||||
import { WEBID_STORAGE_TYPE } from '../../../../src/identity/interaction/webid/util/BaseWebIdStore';
|
||||
import { V6MigrationInitializer } from '../../../../src/init/migration/V6MigrationInitializer';
|
||||
import { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
import type { KeyValueStorage } from '../../../../src/storage/keyvalue/KeyValueStorage';
|
||||
|
||||
type Account = {
|
||||
webId: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { resetInternalLoggerFactory, getLoggerFor, setGlobalLoggerFactory } from '../../../src/logging/LogUtil';
|
||||
import { getLoggerFor, resetInternalLoggerFactory, setGlobalLoggerFactory } from '../../../src/logging/LogUtil';
|
||||
|
||||
let currentFactory: any;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import process from 'process';
|
||||
import { BaseLogger, WrappingLogger } from '../../../src/logging/Logger';
|
||||
import type { SimpleLogger, LogMetadata } from '../../../src/logging/Logger';
|
||||
import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger';
|
||||
|
||||
describe('Logger', (): void => {
|
||||
describe('a BaseLogger', (): void => {
|
||||
|
||||
@@ -7,6 +7,6 @@ describe('VoidLogger', (): void => {
|
||||
});
|
||||
|
||||
it('does nothing when log is invoked.', async(): Promise<void> => {
|
||||
expect(logger.log('debug', 'my message', { abc: true })).toBe(logger);
|
||||
expect(logger.log()).toBe(logger);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,7 +9,6 @@ const manager: jest.Mocked<ComponentsManager<any>> = {
|
||||
} as any;
|
||||
|
||||
jest.mock('componentsjs', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ComponentsManager: {
|
||||
build: jest.fn(async(): Promise<ComponentsManager<any>> => manager),
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('A SubfolderResourcesGenerator', (): void => {
|
||||
extraResources = [];
|
||||
|
||||
source = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars
|
||||
generate: jest.fn((folder, loc, opt): AsyncIterable<Resource> => {
|
||||
if (folder.endsWith('base')) {
|
||||
return yieldResources(baseResources);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import type { ServerResponse, IncomingMessage, Server } from 'http';
|
||||
import type { IncomingMessage, Server, ServerResponse } from 'http';
|
||||
import { Readable } from 'stream';
|
||||
import type { Logger } from '../../../src/logging/Logger';
|
||||
import { getLoggerFor } from '../../../src/logging/LogUtil';
|
||||
|
||||
@@ -9,7 +9,6 @@ import { WebSocketServerConfigurator } from '../../../src/server/WebSocketServer
|
||||
import { flushPromises } from '../../util/Util';
|
||||
|
||||
jest.mock('ws', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
WebSocketServer: jest.fn().mockImplementation((): any => ({
|
||||
handleUpgrade(upgradeRequest: any, socket: any, head: any, callback: any): void {
|
||||
callback(socket, upgradeRequest);
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('A KeyValueChannelStorage', (): void => {
|
||||
internalStorage = internalMap as any;
|
||||
|
||||
locker = {
|
||||
withWriteLock: jest.fn(async <T,>(rid: ResourceIdentifier, whileLocked: () => T | Promise<T>):
|
||||
withWriteLock: jest.fn(async <T>(rid: ResourceIdentifier, whileLocked: () => T | Promise<T>):
|
||||
Promise<T> => whileLocked()),
|
||||
withReadLock: jest.fn(),
|
||||
};
|
||||
|
||||
@@ -27,7 +27,6 @@ describe('A ListeningActivityHandler', (): void => {
|
||||
let storage: jest.Mocked<NotificationChannelStorage>;
|
||||
let emitter: ActivityEmitter;
|
||||
let notificationHandler: jest.Mocked<NotificationHandler>;
|
||||
let handler: ListeningActivityHandler;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
jest.clearAllMocks();
|
||||
@@ -49,8 +48,8 @@ describe('A ListeningActivityHandler', (): void => {
|
||||
handleSafe: jest.fn().mockResolvedValue(undefined),
|
||||
} as any;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
handler = new ListeningActivityHandler(storage, emitter, notificationHandler);
|
||||
// eslint-disable-next-line no-new
|
||||
new ListeningActivityHandler(storage, emitter, notificationHandler);
|
||||
});
|
||||
|
||||
it('calls the NotificationHandler if there is an event.', async(): Promise<void> => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { NOTIFY } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
describe('A NotificationDescriber', (): void => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { HttpResponse } from '../../../../../src/server/HttpResponse';
|
||||
import { WebhookWebId } from '../../../../../src/server/notifications/WebhookChannel2023/WebhookWebId';
|
||||
import { readableToString } from '../../../../../src/util/StreamUtil';
|
||||
import { SOLID } from '../../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
describe('A WebhookWebId', (): void => {
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
import { NotImplementedHttpError } from '../../../../../src/util/errors/NotImplementedHttpError';
|
||||
|
||||
jest.mock('ws', (): any => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
WebSocketServer: jest.fn().mockImplementation((): any => ({
|
||||
handleUpgrade(upgradeRequest: any, socket: any, head: any, callback: any): void {
|
||||
callback(socket, upgradeRequest);
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
AbsolutePathInteractionRoute,
|
||||
} from '../../../../../src/identity/interaction/routing/AbsolutePathInteractionRoute';
|
||||
import type { NotificationChannel } from '../../../../../src/server/notifications/NotificationChannel';
|
||||
|
||||
import {
|
||||
generateWebSocketUrl,
|
||||
} from '../../../../../src/server/notifications/WebSocketChannel2023/WebSocket2023Util';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { HttpRequest,
|
||||
import type { HttpHandler,
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
TargetExtractor,
|
||||
ResourceIdentifier,
|
||||
HttpHandler } from '../../../../src';
|
||||
TargetExtractor } from '../../../../src';
|
||||
import { joinUrl } from '../../../../src';
|
||||
import { RouterHandler } from '../../../../src/server/util/RouterHandler';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BasicRepresentation } from '../../../src/http/representation/BasicRepresentation';
|
||||
import type { Representation } from '../../../src/http/representation/Representation';
|
||||
import { BinarySliceResourceStore } from '../../../src/storage/BinarySliceResourceStore';
|
||||
import { ResourceStore } from '../../../src/storage/ResourceStore';
|
||||
import type { ResourceStore } from '../../../src/storage/ResourceStore';
|
||||
import { InternalServerError } from '../../../src/util/errors/InternalServerError';
|
||||
import { RangeNotSatisfiedHttpError } from '../../../src/util/errors/RangeNotSatisfiedHttpError';
|
||||
import { readableToString } from '../../../src/util/StreamUtil';
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ContentType } from '../../../src/util/Header';
|
||||
import { SingleRootIdentifierStrategy } from '../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import { trimTrailingSlashes } from '../../../src/util/PathUtil';
|
||||
import { guardedStreamFrom } from '../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, SOLID_HTTP, LDP, PIM, RDF, SOLID_META, DC, SOLID_AS, AS } from '../../../src/util/Vocabularies';
|
||||
import { AS, CONTENT_TYPE, DC, LDP, PIM, RDF, SOLID_AS, SOLID_HTTP, SOLID_META } from '../../../src/util/Vocabularies';
|
||||
import { SimpleSuffixStrategy } from '../../util/SimpleSuffixStrategy';
|
||||
|
||||
const { namedNode, quad, literal } = DataFactory;
|
||||
@@ -107,7 +107,7 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
const metadataStrategy = new SimpleSuffixStrategy('.meta');
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
mockDate = jest.spyOn(global, 'Date').mockReturnValue(now as any);
|
||||
mockDate = jest.spyOn(globalThis, 'Date').mockReturnValue(now as any);
|
||||
|
||||
accessor = new SimpleDataAccessor();
|
||||
|
||||
@@ -879,4 +879,3 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import { guardedStreamFrom, readableToString } from '../../../../src/util/Stream
|
||||
import { toLiteral } from '../../../../src/util/TermUtil';
|
||||
import { CONTENT_TYPE, DC, LDP, POSIX, RDF, SOLID_META, XSD } from '../../../../src/util/Vocabularies';
|
||||
import { mockFileSystem } from '../../../util/Util';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
jest.mock('fs');
|
||||
@@ -221,7 +222,7 @@ describe('A FileDataAccessor', (): void => {
|
||||
}
|
||||
return result;
|
||||
}),
|
||||
mapUrlToFilePath: jest.fn((...args): Promise<ResourceLink> => mapper.mapUrlToFilePath(...args)),
|
||||
mapUrlToFilePath: jest.fn(async(...args): Promise<ResourceLink> => mapper.mapUrlToFilePath(...args)),
|
||||
};
|
||||
|
||||
accessor = new FileDataAccessor(badMapper);
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { Guarded } from '../../../../src/util/GuardedStream';
|
||||
import { BaseIdentifierStrategy } from '../../../../src/util/identifiers/BaseIdentifierStrategy';
|
||||
import { guardedStreamFrom, readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, LDP, POSIX, RDF } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode } = DataFactory;
|
||||
|
||||
class DummyStrategy extends BaseIdentifierStrategy {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { SingleRootIdentifierStrategy } from '../../../../src/util/identifiers/S
|
||||
import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import type { TemplateEngine } from '../../../../src/util/templates/TemplateEngine';
|
||||
import { LDP, RDF } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { namedNode: nn, quad } = DataFactory;
|
||||
|
||||
describe('A ContainerToTemplateConverter', (): void => {
|
||||
|
||||
@@ -55,7 +55,6 @@ describe('An ErrorToJsonConverter', (): void => {
|
||||
it('adds OAuth fields if present.', async(): Promise<void> => {
|
||||
const out: OAuthErrorFields = {
|
||||
error: 'error',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
error_description: 'error_description',
|
||||
scope: 'scope',
|
||||
state: 'state',
|
||||
@@ -74,7 +73,6 @@ describe('An ErrorToJsonConverter', (): void => {
|
||||
errorCode: 'H400',
|
||||
stack: error.stack,
|
||||
error: 'error',
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
error_description: 'error_description',
|
||||
scope: 'scope',
|
||||
state: 'state',
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BasicRepresentation } from '../../../../src/http/representation/BasicRe
|
||||
import { ErrorToQuadConverter } from '../../../../src/storage/conversion/ErrorToQuadConverter';
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
import { DC, SOLID_ERROR } from '../../../../src/util/Vocabularies';
|
||||
|
||||
const { literal, namedNode, quad } = DataFactory;
|
||||
|
||||
describe('An ErrorToQuadConverter', (): void => {
|
||||
|
||||
@@ -9,8 +9,8 @@ import { QuadToRdfConverter } from '../../../../src/storage/conversion/QuadToRdf
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { readableToString } from '../../../../src/util/StreamUtil';
|
||||
import { DC, PREFERRED_PREFIX_TERM, SOLID_META } from '../../../../src/util/Vocabularies';
|
||||
import quad = DataFactory.quad;
|
||||
const { namedNode, triple } = DataFactory;
|
||||
|
||||
const { namedNode, triple, quad } = DataFactory;
|
||||
|
||||
describe('A QuadToRdfConverter', (): void => {
|
||||
const converter = new QuadToRdfConverter();
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { ResourceIdentifier } from '../../../../src/http/representation/Res
|
||||
import { RdfToQuadConverter } from '../../../../src/storage/conversion/RdfToQuadConverter';
|
||||
import { INTERNAL_QUADS } from '../../../../src/util/ContentTypes';
|
||||
import { BadRequestHttpError } from '../../../../src/util/errors/BadRequestHttpError';
|
||||
|
||||
const { namedNode, triple, literal, quad } = DataFactory;
|
||||
|
||||
// All of this is necessary to not break the cross-fetch imports that happen in `rdf-parse`
|
||||
@@ -21,7 +22,6 @@ jest.mock('cross-fetch', (): any => {
|
||||
// Require the original module to not be mocked...
|
||||
const originalFetch = jest.requireActual('cross-fetch');
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
__esModule: true,
|
||||
...originalFetch,
|
||||
fetch: mock,
|
||||
|
||||
@@ -120,7 +120,7 @@ describe('A WrappedExpiringStorage', (): void => {
|
||||
it('removes expired entries after a given time.', async(): Promise<void> => {
|
||||
// Disable interval function and simply check it was called with the correct parameters
|
||||
// Otherwise it gets quite difficult to verify the async interval function gets executed
|
||||
const mockInterval = jest.spyOn(global, 'setInterval');
|
||||
const mockInterval = jest.spyOn(globalThis, 'setInterval');
|
||||
|
||||
// We only need to call the timer.unref() once when the object is created
|
||||
const mockTimer = { unref: jest.fn() };
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'jest-rdf';
|
||||
import { DataFactory, Store } from 'n3';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
import type { Patch } from '../../../../src/http/representation/Patch';
|
||||
@@ -12,7 +13,7 @@ import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplemen
|
||||
import { FilterPattern } from '../../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom } from '../../../../src/util/StreamUtil';
|
||||
import { SimpleSuffixStrategy } from '../../../util/SimpleSuffixStrategy';
|
||||
import 'jest-rdf';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
function getPatch(): Patch {
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { RepresentationPatcherInput } from '../../../../src/storage/patch/R
|
||||
import { ConflictHttpError } from '../../../../src/util/errors/ConflictHttpError';
|
||||
import { InternalServerError } from '../../../../src/util/errors/InternalServerError';
|
||||
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
|
||||
|
||||
const { namedNode, quad, variable } = DataFactory;
|
||||
|
||||
describe('An N3Patcher', (): void => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'jest-rdf';
|
||||
import { DataFactory } from 'n3';
|
||||
import type { Quad } from 'rdf-js';
|
||||
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
|
||||
@@ -10,8 +11,8 @@ import type { RepresentationPatcher,
|
||||
RepresentationPatcherInput } from '../../../../src/storage/patch/RepresentationPatcher';
|
||||
import { InternalServerError } from '../../../../src/util/errors/InternalServerError';
|
||||
import { readableToQuads } from '../../../../src/util/StreamUtil';
|
||||
|
||||
const { quad, namedNode } = DataFactory;
|
||||
import 'jest-rdf';
|
||||
|
||||
describe('An RdfPatcher,', (): void => {
|
||||
let patcher: jest.Mocked<RepresentationPatcher<RdfDatasetRepresentation>>;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'jest-rdf';
|
||||
import { Store, DataFactory } from 'n3';
|
||||
import { DataFactory, Store } from 'n3';
|
||||
import type { Quad } from 'rdf-js';
|
||||
import type { Algebra } from 'sparqlalgebrajs';
|
||||
import { translate } from 'sparqlalgebrajs';
|
||||
|
||||
@@ -6,6 +6,7 @@ import { DataFactory } from 'n3';
|
||||
import rdfDereferencer from 'rdf-dereference';
|
||||
import { RdfToQuadConverter } from '../../../src/storage/conversion/RdfToQuadConverter';
|
||||
import { fetchDataset, responseToDataset } from '../../../src/util/FetchUtil';
|
||||
|
||||
const { namedNode, quad } = DataFactory;
|
||||
|
||||
jest.mock('rdf-dereference', (): any => ({
|
||||
|
||||
@@ -95,7 +95,6 @@ describe('HeaderUtil', (): void => {
|
||||
range: 'a/b', weight: 1, parameters: { extension: {}, mediaType: {}},
|
||||
}]);
|
||||
expect(parseAccept('a/b; q=1 ; a')).toEqual([{
|
||||
// eslint-disable-next-line id-length
|
||||
range: 'a/b', weight: 1, parameters: { extension: { a: '' }, mediaType: {}},
|
||||
}]);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('LockUtil', (): void => {
|
||||
});
|
||||
|
||||
it('works with jitter.', async(): Promise<void> => {
|
||||
jest.spyOn(global.Math, 'random').mockReturnValue(1);
|
||||
jest.spyOn(globalThis.Math, 'random').mockReturnValue(1);
|
||||
let elapsed = Date.now();
|
||||
const promise = setJitterTimeout(1000, 100).then((): void => {
|
||||
elapsed = Date.now() - elapsed;
|
||||
@@ -25,7 +25,7 @@ describe('LockUtil', (): void => {
|
||||
await expect(promise).resolves.toBeUndefined();
|
||||
expect(elapsed).toBe(1100);
|
||||
// Clean up
|
||||
jest.spyOn(global.Math, 'random').mockRestore();
|
||||
jest.spyOn(globalThis.Math, 'random').mockRestore();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,6 @@ describe('PromiseUtil', (): void => {
|
||||
const resultTrue = Promise.resolve(true);
|
||||
const resultFalse = Promise.resolve(false);
|
||||
const resultError = Promise.reject(new Error('generic error'));
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const resultInfinite = new Promise<boolean>((): void => {});
|
||||
|
||||
it('returns false if no promise is provided.', async(): Promise<void> => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'jest-rdf';
|
||||
import { DataFactory } from 'n3';
|
||||
import { parseQuads, serializeQuads, termToInt, uniqueQuads } from '../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom, readableToString } from '../../../src/util/StreamUtil';
|
||||
|
||||
const { literal, namedNode, quad } = DataFactory;
|
||||
|
||||
describe('QuadUtil', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'jest-rdf';
|
||||
import type { Readable } from 'stream';
|
||||
import type { NamedNode, Literal } from 'n3';
|
||||
import type { Literal, NamedNode } from 'n3';
|
||||
import { BasicRepresentation } from '../../../src/http/representation/BasicRepresentation';
|
||||
import type { Representation } from '../../../src/http/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../../src/http/representation/RepresentationMetadata';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { PassThrough, Readable } from 'stream';
|
||||
import arrayifyStream from 'arrayify-stream';
|
||||
import { Quad, NamedNode, Literal, BlankNode, Store } from 'n3';
|
||||
import { BlankNode, Literal, NamedNode, Quad, Store } from 'n3';
|
||||
import type { Logger } from '../../../src/logging/Logger';
|
||||
import { getLoggerFor } from '../../../src/logging/LogUtil';
|
||||
import { isHttpRequest } from '../../../src/server/HttpRequest';
|
||||
import {
|
||||
guardedStreamFrom, pipeSafely, transformSafely,
|
||||
readableToString, readableToQuads, readJsonStream, getSingleItem,
|
||||
getSingleItem, guardedStreamFrom, pipeSafely,
|
||||
readableToQuads, readableToString, readJsonStream, transformSafely,
|
||||
} from '../../../src/util/StreamUtil';
|
||||
import { flushPromises } from '../../util/Util';
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
isUrl,
|
||||
isValidFileName,
|
||||
msToDuration,
|
||||
sanitizeUrlPart,
|
||||
splitCommaSeparated,
|
||||
isValidFileName,
|
||||
isUrl,
|
||||
msToDuration,
|
||||
} from '../../../src/util/StringUtil';
|
||||
|
||||
describe('HeaderUtil', (): void => {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import 'jest-rdf';
|
||||
import { DataFactory } from 'n3';
|
||||
import {
|
||||
toNamedTerm,
|
||||
toPredicateTerm,
|
||||
toObjectTerm,
|
||||
toLiteral,
|
||||
isTerm,
|
||||
toLiteral,
|
||||
toNamedTerm,
|
||||
toObjectTerm,
|
||||
toPredicateTerm,
|
||||
} from '../../../src/util/TermUtil';
|
||||
import { XSD } from '../../../src/util/Vocabularies';
|
||||
|
||||
const { literal, namedNode } = DataFactory;
|
||||
|
||||
describe('TermUtil', (): void => {
|
||||
|
||||
@@ -7,7 +7,7 @@ jest.useFakeTimers();
|
||||
describe('TimerUtil', (): void => {
|
||||
describe('#setSafeInterval', (): void => {
|
||||
let logger: jest.Mocked<Logger>;
|
||||
let callback: jest.Mock<(...cbArgs: any[]) => void>;
|
||||
let callback: jest.Mock;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
logger = { error: jest.fn() } as any;
|
||||
|
||||
@@ -47,6 +47,7 @@ describe('A WaterfallHandler', (): void => {
|
||||
|
||||
it('throws unknown errors if no Error objects are thrown.', async(): Promise<void> => {
|
||||
handlerFalse.canHandle = async(): Promise<void> => {
|
||||
// eslint-disable-next-line ts/no-throw-literal
|
||||
throw 'apple';
|
||||
};
|
||||
const handler = new WaterfallHandler([ handlerFalse, handlerFalse ]);
|
||||
|
||||
@@ -52,6 +52,7 @@ class SimpleReadWriteLocker extends BaseReadWriteLocker {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable ts/no-floating-promises */
|
||||
describe('A BaseReadWriteLocker', (): void => {
|
||||
let resourceLocker: ResourceLocker;
|
||||
let countLocker: ResourceLocker;
|
||||
@@ -163,7 +164,6 @@ describe('A BaseReadWriteLocker', (): void => {
|
||||
// Otherwise the internal write lock might not be acquired yet
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resourceId, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -198,7 +198,6 @@ describe('A BaseReadWriteLocker', (): void => {
|
||||
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resource2Id, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -233,7 +232,6 @@ describe('A BaseReadWriteLocker', (): void => {
|
||||
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resourceId, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -243,7 +241,6 @@ describe('A BaseReadWriteLocker', (): void => {
|
||||
|
||||
const delayedLockRead2 = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withReadLock(resourceId, async(): Promise<void> => {
|
||||
order.push('read 2 start');
|
||||
await promRead2;
|
||||
@@ -287,7 +284,6 @@ describe('A BaseReadWriteLocker', (): void => {
|
||||
// We want to make sure the read operation only starts while the write operation is busy
|
||||
const delayedLockRead = new Promise<void>((resolve): void => {
|
||||
emitter.on('writeStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withReadLock(resourceId, (): any => {
|
||||
order.push('read');
|
||||
resolve();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readdir } from 'fs-extra';
|
||||
import { InternalServerError, FileSystemResourceLocker, joinFilePath } from '../../../../src';
|
||||
import { FileSystemResourceLocker, InternalServerError, joinFilePath } from '../../../../src';
|
||||
import { getTestFolder, removeFolder } from '../../../integration/Config';
|
||||
|
||||
// Due to the nature of using a file locking library, this is a unit test that writes to disk.
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Redis } from 'ioredis';
|
||||
import type { ReadWriteLocker, ResourceLocker } from '../../../../src';
|
||||
import { InternalServerError } from '../../../../src';
|
||||
import { RedisLocker } from '../../../../src/util/locking/RedisLocker';
|
||||
import type { RedisResourceLock, RedisReadWriteLock } from '../../../../src/util/locking/scripts/RedisLuaScripts';
|
||||
import type { RedisReadWriteLock, RedisResourceLock } from '../../../../src/util/locking/scripts/RedisLuaScripts';
|
||||
import { flushPromises } from '../../../util/Util';
|
||||
|
||||
interface LockState {
|
||||
@@ -99,6 +99,7 @@ const redis: jest.Mocked<Redis & RedisResourceLock & RedisReadWriteLock> = {
|
||||
|
||||
jest.mock('ioredis', (): any => jest.fn().mockImplementation((): Redis => redis));
|
||||
|
||||
/* eslint-disable ts/no-floating-promises */
|
||||
describe('A RedisLocker', (): void => {
|
||||
it('will generate keys with the given namespacePrefix.', async(): Promise<void> => {
|
||||
const identifier = { path: 'http://test.com/resource' };
|
||||
@@ -243,7 +244,6 @@ describe('A RedisLocker', (): void => {
|
||||
// Otherwise the internal write lock might not be acquired yet
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resource1, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -278,7 +278,6 @@ describe('A RedisLocker', (): void => {
|
||||
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resource2, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -313,7 +312,6 @@ describe('A RedisLocker', (): void => {
|
||||
|
||||
const delayedLockWrite = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withWriteLock(resource1, (): any => {
|
||||
order.push('write');
|
||||
resolve();
|
||||
@@ -323,7 +321,6 @@ describe('A RedisLocker', (): void => {
|
||||
|
||||
const delayedLockRead2 = new Promise<void>((resolve): void => {
|
||||
emitter.on('readStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withReadLock(resource1, async(): Promise<void> => {
|
||||
order.push('read 2 start');
|
||||
await promRead2;
|
||||
@@ -367,7 +364,6 @@ describe('A RedisLocker', (): void => {
|
||||
// We want to make sure the read operation only starts while the write operation is busy
|
||||
const delayedLockRead = new Promise<void>((resolve): void => {
|
||||
emitter.on('writeStarted', (): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
locker.withReadLock(resource1, (): any => {
|
||||
order.push('read');
|
||||
resolve();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { StaticTemplateEngine, NotFoundHttpError } from '../../../../src';
|
||||
import { NotFoundHttpError, StaticTemplateEngine } from '../../../../src';
|
||||
import type { AsyncHandler, TemplateEngineInput } from '../../../../src';
|
||||
import Dict = NodeJS.Dict;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user