@friggframework/devtools 1.0.1-v1-alpha.1 → 1.0.1-v1-alpha.3
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/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "1.0.1-v1-alpha.
|
|
4
|
+
"version": "1.0.1-v1-alpha.3",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@babel/eslint-parser": "^7.18.9",
|
|
7
|
-
"@friggframework/core": "1.0.1-v1-alpha.
|
|
7
|
+
"@friggframework/core": "1.0.1-v1-alpha.3",
|
|
8
8
|
"eslint": "^8.22.0",
|
|
9
9
|
"eslint-config-prettier": "^8.5.0",
|
|
10
10
|
"eslint-plugin-json": "^3.1.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "6a3908e31ccf56fb6be6dab758e55fc5601e6d65"
|
|
41
41
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
Auther,
|
|
2
3
|
ModuleConstants,
|
|
3
4
|
createObjectId,
|
|
4
5
|
connectToDatabase,
|
|
@@ -14,6 +15,22 @@ function testAutherDefinition(definition, mocks) {
|
|
|
14
15
|
userId: createObjectId(),
|
|
15
16
|
...params,
|
|
16
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
|
+
}
|
|
17
34
|
module.api = createMockApiObject(jest, module.api, mocks);
|
|
18
35
|
return module
|
|
19
36
|
}
|
|
@@ -30,9 +47,9 @@ function testAutherDefinition(definition, mocks) {
|
|
|
30
47
|
await disconnectFromDatabase();
|
|
31
48
|
});
|
|
32
49
|
|
|
33
|
-
let requirements,
|
|
50
|
+
let requirements, authCallbackParams;
|
|
34
51
|
if (definition.API.requesterType === ModuleConstants.authType.oauth2) {
|
|
35
|
-
|
|
52
|
+
authCallbackParams = mocks.authorizeResponse || mocks.authorizeParams;
|
|
36
53
|
describe('getAuthorizationRequirements() test', () => {
|
|
37
54
|
it('should return auth requirements', async () => {
|
|
38
55
|
requirements = module.getAuthorizationRequirements();
|
|
@@ -43,8 +60,8 @@ function testAutherDefinition(definition, mocks) {
|
|
|
43
60
|
});
|
|
44
61
|
});
|
|
45
62
|
} else if (definition.API.requesterType === ModuleConstants.authType.basic) {
|
|
46
|
-
// could also confirm
|
|
47
|
-
|
|
63
|
+
// could also confirm authCallbackParams against the auth requirements
|
|
64
|
+
authCallbackParams = mocks.authorizeParams
|
|
48
65
|
describe('getAuthorizationRequirements() test', () => {
|
|
49
66
|
it('should return auth requirements', async () => {
|
|
50
67
|
requirements = module.getAuthorizationRequirements();
|
|
@@ -53,8 +70,8 @@ function testAutherDefinition(definition, mocks) {
|
|
|
53
70
|
});
|
|
54
71
|
});
|
|
55
72
|
} else if (definition.API.requesterType === ModuleConstants.authType.apiKey) {
|
|
56
|
-
// could also confirm
|
|
57
|
-
|
|
73
|
+
// could also confirm authCallbackParams against the auth requirements
|
|
74
|
+
authCallbackParams = mocks.authorizeParams
|
|
58
75
|
describe('getAuthorizationRequirements() test', () => {
|
|
59
76
|
it('should return auth requirements', async () => {
|
|
60
77
|
requirements = module.getAuthorizationRequirements();
|
|
@@ -67,13 +84,13 @@ function testAutherDefinition(definition, mocks) {
|
|
|
67
84
|
describe('Authorization requests', () => {
|
|
68
85
|
let firstRes;
|
|
69
86
|
it('processAuthorizationCallback()', async () => {
|
|
70
|
-
firstRes = await module.processAuthorizationCallback(
|
|
87
|
+
firstRes = await module.processAuthorizationCallback(authCallbackParams);
|
|
71
88
|
expect(firstRes).toBeDefined();
|
|
72
89
|
expect(firstRes.entity_id).toBeDefined();
|
|
73
90
|
expect(firstRes.credential_id).toBeDefined();
|
|
74
91
|
});
|
|
75
92
|
it('retrieves existing entity on subsequent calls', async () => {
|
|
76
|
-
const res = await module.processAuthorizationCallback(
|
|
93
|
+
const res = await module.processAuthorizationCallback(authCallbackParams);
|
|
77
94
|
expect(res).toEqual(firstRes);
|
|
78
95
|
});
|
|
79
96
|
});
|