@velocitycareerlabs/tests-helpers 1.21.0-dev-build.15d87fefa → 1.21.0-dev-build.1ef9b50bd
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 +9 -9
- package/src/build-fastify.js +5 -4
- package/src/regexes.js +1 -0
- package/src/test-oauth-user.js +48 -32
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@velocitycareerlabs/tests-helpers",
|
3
|
-
"version": "1.21.0-dev-build.
|
3
|
+
"version": "1.21.0-dev-build.1ef9b50bd",
|
4
4
|
"description": "Generic helpers for tests",
|
5
5
|
"repository": "https://github.com/velocitycareerlabs/packages",
|
6
6
|
"main": "index.js",
|
@@ -21,13 +21,13 @@
|
|
21
21
|
"@fastify/swagger-ui": "~1.9.2",
|
22
22
|
"@spencejs/spence-events": "^0.10.2",
|
23
23
|
"@spencejs/spence-mongo-repos": "^0.10.2",
|
24
|
-
"@velocitycareerlabs/common-functions": "1.21.0-dev-build.
|
25
|
-
"@velocitycareerlabs/common-schemas": "1.21.0-dev-build.
|
26
|
-
"@velocitycareerlabs/crypto": "1.21.0-dev-build.
|
27
|
-
"@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.
|
28
|
-
"@velocitycareerlabs/jwt": "1.21.0-dev-build.
|
29
|
-
"@velocitycareerlabs/logger": "1.21.0-dev-build.
|
30
|
-
"@velocitycareerlabs/rest-queries": "1.21.0-dev-build.
|
24
|
+
"@velocitycareerlabs/common-functions": "1.21.0-dev-build.1ef9b50bd",
|
25
|
+
"@velocitycareerlabs/common-schemas": "1.21.0-dev-build.1ef9b50bd",
|
26
|
+
"@velocitycareerlabs/crypto": "1.21.0-dev-build.1ef9b50bd",
|
27
|
+
"@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.1ef9b50bd",
|
28
|
+
"@velocitycareerlabs/jwt": "1.21.0-dev-build.1ef9b50bd",
|
29
|
+
"@velocitycareerlabs/logger": "1.21.0-dev-build.1ef9b50bd",
|
30
|
+
"@velocitycareerlabs/rest-queries": "1.21.0-dev-build.1ef9b50bd",
|
31
31
|
"ajv-formats": "2.1.1",
|
32
32
|
"dotenv": "^16.0.0",
|
33
33
|
"env-var": "^7.0.0",
|
@@ -54,5 +54,5 @@
|
|
54
54
|
"nanoid": "~3.3.1",
|
55
55
|
"prettier": "~2.8.8"
|
56
56
|
},
|
57
|
-
"gitHead": "
|
57
|
+
"gitHead": "671f970153308549b8d39a7b7374c8e3ddac029f"
|
58
58
|
}
|
package/src/build-fastify.js
CHANGED
@@ -45,7 +45,9 @@ const {
|
|
45
45
|
customFastifyQueryStringParser,
|
46
46
|
} = require('@velocitycareerlabs/rest-queries');
|
47
47
|
|
48
|
-
const {
|
48
|
+
const {
|
49
|
+
testRegistrarSuperUser: defaultOAuthUser,
|
50
|
+
} = require('./test-oauth-user');
|
49
51
|
|
50
52
|
const defaultOverrides = { reqConfig: (x) => x };
|
51
53
|
|
@@ -75,7 +77,7 @@ const testOAuthPlugin = fp((server, options, next) => {
|
|
75
77
|
req.user = JSON.parse(req.headers['x-override-oauth-user']);
|
76
78
|
} else {
|
77
79
|
// eslint-disable-next-line better-mutation/no-mutation
|
78
|
-
req.user =
|
80
|
+
req.user = defaultOAuthUser;
|
79
81
|
}
|
80
82
|
});
|
81
83
|
next();
|
@@ -238,7 +240,7 @@ const buildFastify = (
|
|
238
240
|
for (const key in payload) {
|
239
241
|
form.append(key, payload[key]);
|
240
242
|
}
|
241
|
-
|
243
|
+
return server.inject({
|
242
244
|
method,
|
243
245
|
url,
|
244
246
|
payload: form.getBuffer(),
|
@@ -249,7 +251,6 @@ const buildFastify = (
|
|
249
251
|
...headers,
|
250
252
|
},
|
251
253
|
});
|
252
|
-
return response;
|
253
254
|
};
|
254
255
|
|
255
256
|
return initServer(server);
|
package/src/regexes.js
CHANGED
package/src/test-oauth-user.js
CHANGED
@@ -13,63 +13,79 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
+
const { nanoid } = require('nanoid');
|
16
17
|
|
17
|
-
const
|
18
|
-
|
18
|
+
const VNF_GROUP_ID_CLAIM = 'http://velocitynetwork.foundation/groupId';
|
19
|
+
const DEFAULT_GROUP_ID = 'did:ion:1234';
|
20
|
+
|
21
|
+
const testRegistrarSuperUser = {
|
22
|
+
sub: `auth0|${nanoid()}`,
|
19
23
|
scope: 'admin:organizations admin:credentialTypes',
|
20
24
|
};
|
21
25
|
|
22
|
-
const
|
23
|
-
sub:
|
24
|
-
scope:
|
26
|
+
const testNoGroupRegistrarUser = {
|
27
|
+
sub: `auth0|${nanoid()}`,
|
28
|
+
scope:
|
29
|
+
'write:organizations read:organizations write:users read:users write:credentialTypes read:credentialTypes',
|
25
30
|
};
|
26
31
|
|
27
|
-
const
|
28
|
-
|
29
|
-
|
32
|
+
const testRegistrarUser = {
|
33
|
+
sub: `auth0|${nanoid()}`,
|
34
|
+
scope:
|
35
|
+
'write:organizations read:organizations write:users read:users write:credentialTypes read:credentialTypes',
|
36
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
30
37
|
};
|
31
38
|
|
32
|
-
const
|
33
|
-
sub:
|
39
|
+
const testIAMSuperUser = {
|
40
|
+
sub: `auth0|${nanoid()}`,
|
34
41
|
scope: 'admin:users',
|
35
42
|
};
|
36
43
|
|
37
|
-
const
|
38
|
-
sub:
|
44
|
+
const testWriteIAMUser = {
|
45
|
+
sub: `auth0|${nanoid()}`,
|
39
46
|
scope: 'write:users',
|
40
|
-
|
47
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
48
|
+
};
|
49
|
+
|
50
|
+
const testReadIAMUser = {
|
51
|
+
sub: `auth0|${nanoid()}`,
|
52
|
+
scope: 'read:users',
|
53
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
41
54
|
};
|
42
55
|
|
43
|
-
const
|
44
|
-
sub:
|
56
|
+
const testWriteOrganizationsUser = {
|
57
|
+
sub: `auth0|${nanoid()}`,
|
45
58
|
scope: 'write:organizations',
|
59
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
46
60
|
};
|
47
61
|
|
48
|
-
const
|
49
|
-
sub:
|
62
|
+
const testReadOrganizationsUser = {
|
63
|
+
sub: `auth0|${nanoid()}`,
|
50
64
|
scope: 'read:organizations',
|
51
|
-
|
65
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
52
66
|
};
|
53
67
|
|
54
|
-
const
|
55
|
-
sub:
|
68
|
+
const testPurchaseCouponsUser = {
|
69
|
+
sub: `auth0|${nanoid()}`,
|
56
70
|
scope: 'purchase:coupons',
|
57
|
-
|
71
|
+
[VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
|
58
72
|
};
|
59
73
|
|
60
|
-
const
|
61
|
-
sub:
|
74
|
+
const testAdminPayMethodsUser = {
|
75
|
+
sub: `auth0|${nanoid()}`,
|
62
76
|
scope: 'admin:pay_methods',
|
63
77
|
};
|
64
78
|
|
65
79
|
module.exports = {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
testRegistrarUser,
|
81
|
+
testRegistrarSuperUser,
|
82
|
+
testNoGroupRegistrarUser,
|
83
|
+
testWriteOrganizationsUser,
|
84
|
+
testPurchaseCouponsUser,
|
85
|
+
testIAMSuperUser,
|
86
|
+
testWriteIAMUser,
|
87
|
+
testReadIAMUser,
|
88
|
+
testReadOrganizationsUser,
|
89
|
+
testAdminPayMethodsUser,
|
90
|
+
DEFAULT_GROUP_ID,
|
75
91
|
};
|