@friggframework/devtools 2.0.0-next.40 → 2.0.0-next.42
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/frigg-cli/__tests__/unit/commands/build.test.js +173 -405
- package/frigg-cli/__tests__/unit/commands/db-setup.test.js +548 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +359 -377
- package/frigg-cli/__tests__/unit/commands/ui.test.js +266 -512
- package/frigg-cli/__tests__/unit/utils/database-validator.test.js +366 -0
- package/frigg-cli/__tests__/unit/utils/error-messages.test.js +304 -0
- package/frigg-cli/__tests__/unit/utils/prisma-runner.test.js +486 -0
- package/frigg-cli/__tests__/utils/prisma-mock.js +194 -0
- package/frigg-cli/__tests__/utils/test-setup.js +22 -21
- package/frigg-cli/db-setup-command/index.js +186 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +151 -162
- package/frigg-cli/generate-iam-command.js +7 -4
- package/frigg-cli/index.js +9 -1
- package/frigg-cli/install-command/index.js +1 -1
- package/frigg-cli/jest.config.js +124 -0
- package/frigg-cli/package.json +4 -1
- package/frigg-cli/start-command/index.js +101 -2
- package/frigg-cli/start-command/start-command.test.js +297 -0
- package/frigg-cli/utils/database-validator.js +158 -0
- package/frigg-cli/utils/error-messages.js +257 -0
- package/frigg-cli/utils/prisma-runner.js +280 -0
- package/infrastructure/CLAUDE.md +481 -0
- package/infrastructure/IAM-POLICY-TEMPLATES.md +30 -12
- package/infrastructure/create-frigg-infrastructure.js +0 -2
- package/infrastructure/iam-generator.js +18 -38
- package/infrastructure/iam-generator.test.js +40 -8
- package/infrastructure/serverless-template.js +25 -4
- package/infrastructure/serverless-template.test.js +45 -0
- package/package.json +6 -6
- package/test/index.js +2 -4
- package/test/mock-integration.js +4 -14
- package/frigg-cli/__tests__/jest.config.js +0 -102
- package/frigg-cli/__tests__/utils/command-tester.js +0 -170
- package/test/auther-definition-tester.js +0 -125
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
Auther,
|
|
3
|
-
ModuleConstants,
|
|
4
|
-
createObjectId,
|
|
5
|
-
connectToDatabase,
|
|
6
|
-
disconnectFromDatabase,
|
|
7
|
-
} = require('@friggframework/core');
|
|
8
|
-
const { createMockApiObject } = require("./mock-integration");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function testAutherDefinition(definition, mocks) {
|
|
12
|
-
const getModule = async (params) => {
|
|
13
|
-
const module = await Auther.getInstance({
|
|
14
|
-
definition,
|
|
15
|
-
userId: createObjectId(),
|
|
16
|
-
...params,
|
|
17
|
-
});
|
|
18
|
-
if (mocks.tokenResponse) {
|
|
19
|
-
mocks.getTokenFrom = async function(code) {
|
|
20
|
-
await this.setTokens(mocks.tokenResponse);
|
|
21
|
-
return mocks.tokenResponse
|
|
22
|
-
}
|
|
23
|
-
mocks.getTokenFromCode = mocks.getTokenFromCode || mocks.getTokenFrom
|
|
24
|
-
mocks.getTokenFromCodeBasicAuthHeader = mocks.getTokenFromCodeBasicAuthHeader || mocks.getTokenFrom
|
|
25
|
-
mocks.getTokenFromClientCredentials = mocks.getTokenFromClientCredentials || mocks.getTokenFrom
|
|
26
|
-
mocks.getTokenFromUsernamePassword = mocks.getTokenFromUsernamePassword || mocks.getTokenFrom
|
|
27
|
-
}
|
|
28
|
-
if (mocks.refreshResponse) {
|
|
29
|
-
mocks.refreshAccessToken = async function(code) {
|
|
30
|
-
await this.setTokens(mocks.refreshResponse);
|
|
31
|
-
return mocks.refreshResponse
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
module.api = createMockApiObject(jest, module.api, mocks);
|
|
35
|
-
return module
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
describe(`${definition.moduleName} Module Tests`, () => {
|
|
40
|
-
let module, authUrl;
|
|
41
|
-
beforeAll(async () => {
|
|
42
|
-
await connectToDatabase();
|
|
43
|
-
module = await getModule();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterAll(async () => {
|
|
47
|
-
await disconnectFromDatabase();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
let requirements, authCallbackParams;
|
|
51
|
-
if (definition.API.requesterType === ModuleConstants.authType.oauth2) {
|
|
52
|
-
authCallbackParams = mocks.authorizeResponse || mocks.authorizeParams;
|
|
53
|
-
describe('getAuthorizationRequirements() test', () => {
|
|
54
|
-
it('should return auth requirements', async () => {
|
|
55
|
-
requirements = await module.getAuthorizationRequirements();
|
|
56
|
-
expect(requirements).toBeDefined();
|
|
57
|
-
expect(requirements.type).toEqual(ModuleConstants.authType.oauth2);
|
|
58
|
-
expect(requirements.url).toBeDefined();
|
|
59
|
-
authUrl = requirements.url;
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
} else if (definition.API.requesterType === ModuleConstants.authType.basic) {
|
|
63
|
-
// could also confirm authCallbackParams against the auth requirements
|
|
64
|
-
authCallbackParams = mocks.authorizeParams
|
|
65
|
-
describe('getAuthorizationRequirements() test', () => {
|
|
66
|
-
it('should return auth requirements', async () => {
|
|
67
|
-
requirements = module.getAuthorizationRequirements();
|
|
68
|
-
expect(requirements).toBeDefined();
|
|
69
|
-
expect(requirements.type).toEqual(ModuleConstants.authType.basic);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
} else if (definition.API.requesterType === ModuleConstants.authType.apiKey) {
|
|
73
|
-
// could also confirm authCallbackParams against the auth requirements
|
|
74
|
-
authCallbackParams = mocks.authorizeParams
|
|
75
|
-
describe('getAuthorizationRequirements() test', () => {
|
|
76
|
-
it('should return auth requirements', async () => {
|
|
77
|
-
requirements = module.getAuthorizationRequirements();
|
|
78
|
-
expect(requirements).toBeDefined();
|
|
79
|
-
expect(requirements.type).toEqual(ModuleConstants.authType.apiKey);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
describe('Authorization requests', () => {
|
|
85
|
-
let firstRes;
|
|
86
|
-
it('processAuthorizationCallback()', async () => {
|
|
87
|
-
firstRes = await module.processAuthorizationCallback(authCallbackParams);
|
|
88
|
-
expect(firstRes).toBeDefined();
|
|
89
|
-
expect(firstRes.entity_id).toBeDefined();
|
|
90
|
-
expect(firstRes.credential_id).toBeDefined();
|
|
91
|
-
});
|
|
92
|
-
it('retrieves existing entity on subsequent calls', async () => {
|
|
93
|
-
const res = await module.processAuthorizationCallback(authCallbackParams);
|
|
94
|
-
expect(res).toEqual(firstRes);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('Test credential retrieval and module instantiation', () => {
|
|
99
|
-
it('retrieve by entity id', async () => {
|
|
100
|
-
const newModule = await getModule({
|
|
101
|
-
userId: module.userId,
|
|
102
|
-
entityId: module.entity.id
|
|
103
|
-
});
|
|
104
|
-
expect(newModule).toBeDefined();
|
|
105
|
-
expect(newModule.entity).toBeDefined();
|
|
106
|
-
expect(newModule.credential).toBeDefined();
|
|
107
|
-
expect(await newModule.testAuth()).toBeTruthy();
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('retrieve by credential id', async () => {
|
|
112
|
-
const newModule = await getModule({
|
|
113
|
-
userId: module.userId,
|
|
114
|
-
credentialId: module.credential.id
|
|
115
|
-
});
|
|
116
|
-
expect(newModule).toBeDefined();
|
|
117
|
-
expect(newModule.credential).toBeDefined();
|
|
118
|
-
expect(await newModule.testAuth()).toBeTruthy();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
module.exports = { testAutherDefinition }
|
|
125
|
-
|