@webiny/api-core-testing 0.0.0-unstable.0d717d18dd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-core-testing
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,19 @@
1
+ import { TestHttpEventHandler } from "@webiny/event-handler-core/features/testing";
2
+ import type { EventContext, NextFunction } from "@webiny/event-handler-core";
3
+ import type { IAuthenticationContext } from "@webiny/api-core/features/security/authentication/AuthenticationContext/index.js";
4
+ import type { IIdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
5
+ /**
6
+ * Test-only decorator on the HTTP event handler: authenticates the `authorization` header and sets
7
+ * the resulting identity before the request is dispatched (mirrors the prod identity loader).
8
+ */
9
+ declare class AuthTriggerHandlerImpl implements TestHttpEventHandler.Interface {
10
+ private authCtx;
11
+ private identityCtx;
12
+ private inner;
13
+ constructor(authCtx: IAuthenticationContext, identityCtx: IIdentityContext, inner: TestHttpEventHandler.Interface);
14
+ execute(ctx: EventContext, next: NextFunction): Promise<any>;
15
+ }
16
+ export declare const AuthTriggerHandler: typeof AuthTriggerHandlerImpl & {
17
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IEventHandler<any, any>>;
18
+ };
19
+ export {};
@@ -0,0 +1,27 @@
1
+ import { TestHttpEventHandler } from "@webiny/event-handler-core/features/testing";
2
+ import { AuthenticationContext } from "@webiny/api-core/features/security/authentication/AuthenticationContext/index.js";
3
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
4
+ class AuthTriggerHandlerImpl {
5
+ constructor(authCtx, identityCtx, inner){
6
+ this.authCtx = authCtx;
7
+ this.identityCtx = identityCtx;
8
+ this.inner = inner;
9
+ }
10
+ async execute(ctx, next) {
11
+ const headers = ctx.event?.headers ?? {};
12
+ const token = headers["authorization"] ?? "";
13
+ const identity = await this.authCtx.authenticate(token);
14
+ this.identityCtx.setIdentity(identity);
15
+ return this.inner.execute(ctx, next);
16
+ }
17
+ }
18
+ const AuthTriggerHandler = TestHttpEventHandler.createDecorator({
19
+ decorator: AuthTriggerHandlerImpl,
20
+ dependencies: [
21
+ AuthenticationContext,
22
+ IdentityContext
23
+ ]
24
+ });
25
+ export { AuthTriggerHandler };
26
+
27
+ //# sourceMappingURL=AuthTriggerHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers/AuthTriggerHandler.js","sources":["../../src/handlers/AuthTriggerHandler.ts"],"sourcesContent":["import { TestHttpEventHandler } from \"@webiny/event-handler-core/features/testing\";\nimport type { EventContext, NextFunction } from \"@webiny/event-handler-core\";\nimport { AuthenticationContext } from \"@webiny/api-core/features/security/authentication/AuthenticationContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { IAuthenticationContext } from \"@webiny/api-core/features/security/authentication/AuthenticationContext/index.js\";\nimport type { IIdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/**\n * Test-only decorator on the HTTP event handler: authenticates the `authorization` header and sets\n * the resulting identity before the request is dispatched (mirrors the prod identity loader).\n */\nclass AuthTriggerHandlerImpl implements TestHttpEventHandler.Interface {\n constructor(\n private authCtx: IAuthenticationContext,\n private identityCtx: IIdentityContext,\n private inner: TestHttpEventHandler.Interface\n ) {}\n\n async execute(ctx: EventContext, next: NextFunction): Promise<any> {\n const headers = ctx.event?.headers ?? {};\n const token = headers[\"authorization\"] ?? \"\";\n const identity = await this.authCtx.authenticate(token);\n this.identityCtx.setIdentity(identity);\n return this.inner.execute(ctx, next);\n }\n}\n\nexport const AuthTriggerHandler = TestHttpEventHandler.createDecorator({\n decorator: AuthTriggerHandlerImpl,\n dependencies: [AuthenticationContext, IdentityContext]\n});\n"],"names":["AuthTriggerHandlerImpl","authCtx","identityCtx","inner","ctx","next","headers","token","identity","AuthTriggerHandler","TestHttpEventHandler","AuthenticationContext","IdentityContext"],"mappings":";;;AAWA,MAAMA;IACF,YACYC,OAA+B,EAC/BC,WAA6B,EAC7BC,KAAqC,CAC/C;aAHUF,OAAO,GAAPA;aACAC,WAAW,GAAXA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,QAAQC,GAAiB,EAAEC,IAAkB,EAAgB;QAC/D,MAAMC,UAAUF,IAAI,KAAK,EAAE,WAAW,CAAC;QACvC,MAAMG,QAAQD,OAAO,CAAC,gBAAgB,IAAI;QAC1C,MAAME,WAAW,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAACD;QACjD,IAAI,CAAC,WAAW,CAAC,WAAW,CAACC;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAACJ,KAAKC;IACnC;AACJ;AAEO,MAAMI,qBAAqBC,qBAAqB,eAAe,CAAC;IACnE,WAAWV;IACX,cAAc;QAACW;QAAuBC;KAAgB;AAC1D"}
@@ -0,0 +1,17 @@
1
+ import { TestHttpEventHandler } from "@webiny/event-handler-core/features/testing";
2
+ import type { EventContext, NextFunction } from "@webiny/event-handler-core";
3
+ import type { ITenantContext } from "@webiny/api-core/features/tenancy/TenantContext/abstractions.js";
4
+ /**
5
+ * Test-only decorator on the HTTP event handler: sets the "root" tenant before the request is
6
+ * dispatched (mirrors the prod tenant loader).
7
+ */
8
+ declare class RootTenantInitializerImpl implements TestHttpEventHandler.Interface {
9
+ private tenantCtx;
10
+ private inner;
11
+ constructor(tenantCtx: ITenantContext, inner: TestHttpEventHandler.Interface);
12
+ execute(ctx: EventContext, next: NextFunction): Promise<any>;
13
+ }
14
+ export declare const RootTenantInitializer: typeof RootTenantInitializerImpl & {
15
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IEventHandler<any, any>>;
16
+ };
17
+ export {};
@@ -0,0 +1,40 @@
1
+ import { TestHttpEventHandler } from "@webiny/event-handler-core/features/testing";
2
+ import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/abstractions.js";
3
+ class RootTenantInitializerImpl {
4
+ constructor(tenantCtx, inner){
5
+ this.tenantCtx = tenantCtx;
6
+ this.inner = inner;
7
+ }
8
+ async execute(ctx, next) {
9
+ this.tenantCtx.setTenant({
10
+ id: "root",
11
+ name: "Root",
12
+ description: "",
13
+ status: "enabled",
14
+ isInstalled: false,
15
+ settings: {
16
+ name: {
17
+ full: "Root",
18
+ slug: "root"
19
+ },
20
+ social: {},
21
+ favicon: {},
22
+ logo: {}
23
+ },
24
+ tags: [],
25
+ parent: null,
26
+ createdOn: new Date().toISOString(),
27
+ savedOn: new Date().toISOString()
28
+ });
29
+ return this.inner.execute(ctx, next);
30
+ }
31
+ }
32
+ const RootTenantInitializer = TestHttpEventHandler.createDecorator({
33
+ decorator: RootTenantInitializerImpl,
34
+ dependencies: [
35
+ TenantContext
36
+ ]
37
+ });
38
+ export { RootTenantInitializer };
39
+
40
+ //# sourceMappingURL=RootTenantInitializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers/RootTenantInitializer.js","sources":["../../src/handlers/RootTenantInitializer.ts"],"sourcesContent":["import { TestHttpEventHandler } from \"@webiny/event-handler-core/features/testing\";\nimport type { EventContext, NextFunction } from \"@webiny/event-handler-core\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/abstractions.js\";\nimport type { ITenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/abstractions.js\";\n\n/**\n * Test-only decorator on the HTTP event handler: sets the \"root\" tenant before the request is\n * dispatched (mirrors the prod tenant loader).\n */\nclass RootTenantInitializerImpl implements TestHttpEventHandler.Interface {\n constructor(\n private tenantCtx: ITenantContext,\n private inner: TestHttpEventHandler.Interface\n ) {}\n\n async execute(ctx: EventContext, next: NextFunction): Promise<any> {\n this.tenantCtx.setTenant({\n id: \"root\",\n name: \"Root\",\n description: \"\",\n status: \"enabled\",\n isInstalled: false,\n settings: {\n name: { full: \"Root\", slug: \"root\" },\n social: {},\n favicon: {},\n logo: {}\n } as any,\n tags: [],\n parent: null,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString()\n });\n return this.inner.execute(ctx, next);\n }\n}\n\nexport const RootTenantInitializer = TestHttpEventHandler.createDecorator({\n decorator: RootTenantInitializerImpl,\n dependencies: [TenantContext]\n});\n"],"names":["RootTenantInitializerImpl","tenantCtx","inner","ctx","next","Date","RootTenantInitializer","TestHttpEventHandler","TenantContext"],"mappings":";;AASA,MAAMA;IACF,YACYC,SAAyB,EACzBC,KAAqC,CAC/C;aAFUD,SAAS,GAATA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,QAAQC,GAAiB,EAAEC,IAAkB,EAAgB;QAC/D,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;YACrB,IAAI;YACJ,MAAM;YACN,aAAa;YACb,QAAQ;YACR,aAAa;YACb,UAAU;gBACN,MAAM;oBAAE,MAAM;oBAAQ,MAAM;gBAAO;gBACnC,QAAQ,CAAC;gBACT,SAAS,CAAC;gBACV,MAAM,CAAC;YACX;YACA,MAAM,EAAE;YACR,QAAQ;YACR,WAAW,IAAIC,OAAO,WAAW;YACjC,SAAS,IAAIA,OAAO,WAAW;QACnC;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAACF,KAAKC;IACnC;AACJ;AAEO,MAAME,wBAAwBC,qBAAqB,eAAe,CAAC;IACtE,WAAWP;IACX,cAAc;QAACQ;KAAc;AACjC"}
package/identity.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { type IdentityData } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
+ import type { SecurityIdentity } from "@webiny/api-core/types/security.js";
3
+ /**
4
+ * Build a test admin identity. Override any field via the partial:
5
+ * `createIdentity({ id: "abc", displayName: "Jane" })`.
6
+ */
7
+ export declare const createIdentity: (identity?: Partial<IdentityData>) => SecurityIdentity;
package/identity.js ADDED
@@ -0,0 +1,10 @@
1
+ import { AuthenticatedIdentity } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
+ const createIdentity = (identity = {})=>new AuthenticatedIdentity({
3
+ id: "12345678",
4
+ type: "admin",
5
+ displayName: "John Doe",
6
+ ...identity
7
+ });
8
+ export { createIdentity };
9
+
10
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sources":["../src/identity.ts"],"sourcesContent":["import {\n AuthenticatedIdentity,\n type IdentityData\n} from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { SecurityIdentity } from \"@webiny/api-core/types/security.js\";\n\n/**\n * Build a test admin identity. Override any field via the partial:\n * `createIdentity({ id: \"abc\", displayName: \"Jane\" })`.\n */\nexport const createIdentity = (identity: Partial<IdentityData> = {}): SecurityIdentity => {\n return new AuthenticatedIdentity({\n id: \"12345678\",\n type: \"admin\",\n displayName: \"John Doe\",\n ...identity\n });\n};\n"],"names":["createIdentity","identity","AuthenticatedIdentity"],"mappings":";AAUO,MAAMA,iBAAiB,CAACC,WAAkC,CAAC,CAAC,GACxD,IAAIC,sBAAsB;QAC7B,IAAI;QACJ,MAAM;QACN,aAAa;QACb,GAAGD,QAAQ;IACf"}
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { TestIdentity, TestAuthenticator } from "./mocks/TestAuthenticator.js";
2
+ export { TestPermissions, TestAuthorizer } from "./mocks/TestAuthorizer.js";
3
+ export type { TestPermissionsHolder } from "./mocks/TestAuthorizer.js";
4
+ export { AuthTriggerHandler } from "./handlers/AuthTriggerHandler.js";
5
+ export { RootTenantInitializer } from "./handlers/RootTenantInitializer.js";
6
+ export { createIdentity } from "./identity.js";
7
+ export { defaultIdentity, FULL_ACCESS_ROLE_ID, FULL_ACCESS_TEAM_ID, UNKNOWN_TEAM_ID } from "./tenancySecurity.js";
package/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { TestAuthenticator, TestIdentity } from "./mocks/TestAuthenticator.js";
2
+ export { TestAuthorizer, TestPermissions } from "./mocks/TestAuthorizer.js";
3
+ export { AuthTriggerHandler } from "./handlers/AuthTriggerHandler.js";
4
+ export { RootTenantInitializer } from "./handlers/RootTenantInitializer.js";
5
+ export { createIdentity } from "./identity.js";
6
+ export { FULL_ACCESS_ROLE_ID, FULL_ACCESS_TEAM_ID, UNKNOWN_TEAM_ID, defaultIdentity } from "./tenancySecurity.js";
@@ -0,0 +1,17 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ import type { IAuthenticator } from "@webiny/api-core/features/security/authentication/Authenticator/abstractions.js";
3
+ import type { IdentityData } from "@webiny/api-core/features/security/IdentityContext/index.js";
4
+ /**
5
+ * The identity a test authenticates as. Register an instance in the (root) container to control
6
+ * who the request runs as: `container.registerInstance(TestIdentity, createIdentity({...}))`.
7
+ */
8
+ export declare const TestIdentity: Abstraction<IdentityData | null>;
9
+ declare class TestAuthenticatorImpl implements IAuthenticator {
10
+ private identity;
11
+ constructor(identity: IdentityData | null);
12
+ authenticate(_token: string): Promise<any>;
13
+ }
14
+ export declare const TestAuthenticator: typeof TestAuthenticatorImpl & {
15
+ __abstraction: Abstraction<IAuthenticator>;
16
+ };
17
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ import { Authenticator } from "@webiny/api-core/features/security/authentication/Authenticator/abstractions.js";
3
+ const TestIdentity = new Abstraction("TestIdentity");
4
+ class TestAuthenticatorImpl {
5
+ constructor(identity){
6
+ this.identity = identity;
7
+ }
8
+ async authenticate(_token) {
9
+ return this.identity;
10
+ }
11
+ }
12
+ const TestAuthenticator = Authenticator.createImplementation({
13
+ implementation: TestAuthenticatorImpl,
14
+ dependencies: [
15
+ TestIdentity
16
+ ]
17
+ });
18
+ export { TestAuthenticator, TestIdentity };
19
+
20
+ //# sourceMappingURL=TestAuthenticator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks/TestAuthenticator.js","sources":["../../src/mocks/TestAuthenticator.ts"],"sourcesContent":["import { Abstraction } from \"@webiny/di\";\nimport { Authenticator } from \"@webiny/api-core/features/security/authentication/Authenticator/abstractions.js\";\nimport type { IAuthenticator } from \"@webiny/api-core/features/security/authentication/Authenticator/abstractions.js\";\nimport type { IdentityData } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\n/**\n * The identity a test authenticates as. Register an instance in the (root) container to control\n * who the request runs as: `container.registerInstance(TestIdentity, createIdentity({...}))`.\n */\nexport const TestIdentity = new Abstraction<IdentityData | null>(\"TestIdentity\");\n\nclass TestAuthenticatorImpl implements IAuthenticator {\n constructor(private identity: IdentityData | null) {}\n\n async authenticate(_token: string): Promise<any> {\n return this.identity;\n }\n}\n\nexport const TestAuthenticator = Authenticator.createImplementation({\n implementation: TestAuthenticatorImpl,\n dependencies: [TestIdentity]\n});\n"],"names":["TestIdentity","Abstraction","TestAuthenticatorImpl","identity","_token","TestAuthenticator","Authenticator"],"mappings":";;AASO,MAAMA,eAAe,IAAIC,YAAiC;AAEjE,MAAMC;IACF,YAAoBC,QAA6B,CAAE;aAA/BA,QAAQ,GAARA;IAAgC;IAEpD,MAAM,aAAaC,MAAc,EAAgB;QAC7C,OAAO,IAAI,CAAC,QAAQ;IACxB;AACJ;AAEO,MAAMC,oBAAoBC,cAAc,oBAAoB,CAAC;IAChE,gBAAgBJ;IAChB,cAAc;QAACF;KAAa;AAChC"}
@@ -0,0 +1,23 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ import type { IAuthorizer } from "@webiny/api-core/features/security/authorization/Authorizer/abstractions.js";
3
+ import type { SecurityPermission } from "@webiny/api-core/types/security.js";
4
+ import type { IdentityData } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ /**
6
+ * The permissions granted to the test identity, wrapped in a holder so DI treats it as a single
7
+ * value (not a multiple-binding of SecurityPermission):
8
+ * `container.registerInstance(TestPermissions, { list: [{ name: "*" }] })`.
9
+ */
10
+ export interface TestPermissionsHolder {
11
+ list: SecurityPermission[];
12
+ }
13
+ export declare const TestPermissions: Abstraction<TestPermissionsHolder>;
14
+ declare class TestAuthorizerImpl implements IAuthorizer {
15
+ private permissions;
16
+ private identity;
17
+ constructor(permissions: TestPermissionsHolder, identity: IdentityData | null);
18
+ authorize(): Promise<SecurityPermission[] | null>;
19
+ }
20
+ export declare const TestAuthorizer: typeof TestAuthorizerImpl & {
21
+ __abstraction: Abstraction<IAuthorizer>;
22
+ };
23
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Abstraction } from "@webiny/di";
2
+ import { Authorizer } from "@webiny/api-core/features/security/authorization/Authorizer/abstractions.js";
3
+ import { TestIdentity } from "./TestAuthenticator.js";
4
+ const TestPermissions = new Abstraction("TestPermissions");
5
+ class TestAuthorizerImpl {
6
+ constructor(permissions, identity){
7
+ this.permissions = permissions;
8
+ this.identity = identity;
9
+ }
10
+ async authorize() {
11
+ if (this.permissions.list.length > 0) return this.permissions.list;
12
+ if (this.identity?.type === "api-key" && Array.isArray(this.identity.permissions)) return this.identity.permissions;
13
+ return this.permissions.list;
14
+ }
15
+ }
16
+ const TestAuthorizer = Authorizer.createImplementation({
17
+ implementation: TestAuthorizerImpl,
18
+ dependencies: [
19
+ TestPermissions,
20
+ TestIdentity
21
+ ]
22
+ });
23
+ export { TestAuthorizer, TestPermissions };
24
+
25
+ //# sourceMappingURL=TestAuthorizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocks/TestAuthorizer.js","sources":["../../src/mocks/TestAuthorizer.ts"],"sourcesContent":["import { Abstraction } from \"@webiny/di\";\nimport { Authorizer } from \"@webiny/api-core/features/security/authorization/Authorizer/abstractions.js\";\nimport type { IAuthorizer } from \"@webiny/api-core/features/security/authorization/Authorizer/abstractions.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\nimport type { IdentityData } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { TestIdentity } from \"./TestAuthenticator.js\";\n\n/**\n * The permissions granted to the test identity, wrapped in a holder so DI treats it as a single\n * value (not a multiple-binding of SecurityPermission):\n * `container.registerInstance(TestPermissions, { list: [{ name: \"*\" }] })`.\n */\nexport interface TestPermissionsHolder {\n list: SecurityPermission[];\n}\n\nexport const TestPermissions = new Abstraction<TestPermissionsHolder>(\"TestPermissions\");\n\nclass TestAuthorizerImpl implements IAuthorizer {\n constructor(\n private permissions: TestPermissionsHolder,\n private identity: IdentityData | null\n ) {}\n\n async authorize(): Promise<SecurityPermission[] | null> {\n if (this.permissions.list.length > 0) {\n return this.permissions.list;\n }\n // For api-key identities with embedded permissions, return those (mirrors apiKeyAuthorization).\n if (\n this.identity?.type === \"api-key\" &&\n Array.isArray((this.identity as { permissions?: unknown }).permissions)\n ) {\n return (this.identity as unknown as { permissions: SecurityPermission[] }).permissions;\n }\n return this.permissions.list;\n }\n}\n\nexport const TestAuthorizer = Authorizer.createImplementation({\n implementation: TestAuthorizerImpl,\n dependencies: [TestPermissions, TestIdentity]\n});\n"],"names":["TestPermissions","Abstraction","TestAuthorizerImpl","permissions","identity","Array","TestAuthorizer","Authorizer","TestIdentity"],"mappings":";;;AAgBO,MAAMA,kBAAkB,IAAIC,YAAmC;AAEtE,MAAMC;IACF,YACYC,WAAkC,EAClCC,QAA6B,CACvC;aAFUD,WAAW,GAAXA;aACAC,QAAQ,GAARA;IACT;IAEH,MAAM,YAAkD;QACpD,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,GAC/B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;QAGhC,IACI,IAAI,CAAC,QAAQ,EAAE,SAAS,aACxBC,MAAM,OAAO,CAAE,IAAI,CAAC,QAAQ,CAA+B,WAAW,GAEtE,OAAQ,IAAI,CAAC,QAAQ,CAAsD,WAAW;QAE1F,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI;IAChC;AACJ;AAEO,MAAMC,iBAAiBC,WAAW,oBAAoB,CAAC;IAC1D,gBAAgBL;IAChB,cAAc;QAACF;QAAiBQ;KAAa;AACjD"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@webiny/api-core-testing",
3
+ "version": "0.0.0-unstable.0d717d18dd",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/webiny/webiny-js.git",
12
+ "directory": "packages/api-testing"
13
+ },
14
+ "description": "Shared test utilities for Webiny API packages (mocks, auth/tenant test decorators, identity helpers).",
15
+ "author": "Webiny Ltd.",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "@webiny/api-core": "0.0.0-unstable.0d717d18dd",
19
+ "@webiny/di": "1.0.2",
20
+ "@webiny/event-handler-core": "0.0.0-unstable.0d717d18dd"
21
+ },
22
+ "devDependencies": {
23
+ "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
24
+ "rimraf": "6.1.3",
25
+ "typescript": "7.0.2"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "webiny": {
31
+ "publishFrom": "dist"
32
+ }
33
+ }
@@ -0,0 +1,10 @@
1
+ import { IdentityData } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
+ /**
3
+ * Shared test tenancy/security constants (the default admin identity + full-access role/team ids).
4
+ * Runtime tenancy/security setup is DI-native (TestAuthenticator/TestAuthorizer + the CMS test
5
+ * handler); these plain constants live here in the base test-utils package.
6
+ */
7
+ export declare const defaultIdentity: IdentityData;
8
+ export declare const FULL_ACCESS_ROLE_ID = "full-access-role";
9
+ export declare const FULL_ACCESS_TEAM_ID = "full-access-team";
10
+ export declare const UNKNOWN_TEAM_ID = "unknown-team";
@@ -0,0 +1,11 @@
1
+ const defaultIdentity = {
2
+ id: "id-12345678",
3
+ type: "admin",
4
+ displayName: "John Doe"
5
+ };
6
+ const FULL_ACCESS_ROLE_ID = "full-access-role";
7
+ const FULL_ACCESS_TEAM_ID = "full-access-team";
8
+ const UNKNOWN_TEAM_ID = "unknown-team";
9
+ export { FULL_ACCESS_ROLE_ID, FULL_ACCESS_TEAM_ID, UNKNOWN_TEAM_ID, defaultIdentity };
10
+
11
+ //# sourceMappingURL=tenancySecurity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenancySecurity.js","sources":["../src/tenancySecurity.ts"],"sourcesContent":["import { IdentityData } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\n\n/**\n * Shared test tenancy/security constants (the default admin identity + full-access role/team ids).\n * Runtime tenancy/security setup is DI-native (TestAuthenticator/TestAuthorizer + the CMS test\n * handler); these plain constants live here in the base test-utils package.\n */\nexport const defaultIdentity: IdentityData = {\n id: \"id-12345678\",\n type: \"admin\",\n displayName: \"John Doe\"\n};\n\nexport const FULL_ACCESS_ROLE_ID = \"full-access-role\";\nexport const FULL_ACCESS_TEAM_ID = \"full-access-team\";\nexport const UNKNOWN_TEAM_ID = \"unknown-team\";\n"],"names":["defaultIdentity","FULL_ACCESS_ROLE_ID","FULL_ACCESS_TEAM_ID","UNKNOWN_TEAM_ID"],"mappings":"AAOO,MAAMA,kBAAgC;IACzC,IAAI;IACJ,MAAM;IACN,aAAa;AACjB;AAEO,MAAMC,sBAAsB;AAC5B,MAAMC,sBAAsB;AAC5B,MAAMC,kBAAkB"}