import { Abstraction } from "@webiny/di"; import { Authenticator } from "@webiny/api-core/features/security/authentication/Authenticator/abstractions.js"; import type { IAuthenticator } from "@webiny/api-core/features/security/authentication/Authenticator/abstractions.js"; import type { IdentityData } from "@webiny/api-core/features/security/IdentityContext/index.js"; /** * The identity a test authenticates as. Register an instance in the (root) container to control * who the request runs as: `container.registerInstance(TestIdentity, createIdentity({...}))`. */ export const TestIdentity = new Abstraction("TestIdentity"); class TestAuthenticatorImpl implements IAuthenticator { constructor(private identity: IdentityData | null) {} async authenticate(_token: string): Promise { return this.identity; } } export const TestAuthenticator = Authenticator.createImplementation({ implementation: TestAuthenticatorImpl, dependencies: [TestIdentity] });