@velocitycareerlabs/tests-helpers 1.21.0-dev-build.15d87fefa → 1.21.0-dev-build.1589ad1d2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/tests-helpers",
3
- "version": "1.21.0-dev-build.15d87fefa",
3
+ "version": "1.21.0-dev-build.1589ad1d2",
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.15d87fefa",
25
- "@velocitycareerlabs/common-schemas": "1.21.0-dev-build.15d87fefa",
26
- "@velocitycareerlabs/crypto": "1.21.0-dev-build.15d87fefa",
27
- "@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.15d87fefa",
28
- "@velocitycareerlabs/jwt": "1.21.0-dev-build.15d87fefa",
29
- "@velocitycareerlabs/logger": "1.21.0-dev-build.15d87fefa",
30
- "@velocitycareerlabs/rest-queries": "1.21.0-dev-build.15d87fefa",
24
+ "@velocitycareerlabs/common-functions": "1.21.0-dev-build.1589ad1d2",
25
+ "@velocitycareerlabs/common-schemas": "1.21.0-dev-build.1589ad1d2",
26
+ "@velocitycareerlabs/crypto": "1.21.0-dev-build.1589ad1d2",
27
+ "@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.1589ad1d2",
28
+ "@velocitycareerlabs/jwt": "1.21.0-dev-build.1589ad1d2",
29
+ "@velocitycareerlabs/logger": "1.21.0-dev-build.1589ad1d2",
30
+ "@velocitycareerlabs/rest-queries": "1.21.0-dev-build.1589ad1d2",
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": "e40f737ea80879c734f86e47881d62d49572cbec"
57
+ "gitHead": "c104255081c09023e3686a99e0bdba3ee90799c4"
58
58
  }
@@ -45,7 +45,9 @@ const {
45
45
  customFastifyQueryStringParser,
46
46
  } = require('@velocitycareerlabs/rest-queries');
47
47
 
48
- const { testAuth0User } = require('./test-oauth-user');
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 = testAuth0User;
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
- const response = await server.inject({
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
@@ -31,4 +31,5 @@ module.exports = {
31
31
  DID_FORMAT: /^did:[a-z]+:[a-zA-Z0-9_#;?&=\\.-]+$/,
32
32
  ETHEREUM_ADDRESS_FORMAT: /^0x[a-fA-F0-9]{40}$/,
33
33
  REQUEST_ID: /req-\w+/,
34
+ AUTH0_USER_ID_FORMAT: /auth0|[A-Za-z0-9_-]+/,
34
35
  };
@@ -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 baseAuth0User = {
18
- sub: 'auth0|123654',
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 auth0AdminOrganization = {
23
- sub: 'auth0|236541',
24
- scope: 'admin:organizations',
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 testAuth0User = {
28
- ...baseAuth0User,
29
- 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
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 testAuth0UserAdminUserScope = {
33
- sub: 'auth0|123654',
39
+ const testIAMSuperUser = {
40
+ sub: `auth0|${nanoid()}`,
34
41
  scope: 'admin:users',
35
42
  };
36
43
 
37
- const testAuth0UserWriteUserScope = {
38
- sub: 'auth0|123654',
44
+ const testWriteIAMUser = {
45
+ sub: `auth0|${nanoid()}`,
39
46
  scope: 'write:users',
40
- 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
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 testAuth0UserWriteOrganizationsScope = {
44
- sub: 'auth0|123654',
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 testAuth0ReadOrganizationScope = {
49
- sub: 'auth0|123654',
62
+ const testReadOrganizationsUser = {
63
+ sub: `auth0|${nanoid()}`,
50
64
  scope: 'read:organizations',
51
- 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
65
+ [VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
52
66
  };
53
67
 
54
- const testAuth0UserPurchaseCouponScope = {
55
- sub: 'auth0|123654',
68
+ const testPurchaseCouponsUser = {
69
+ sub: `auth0|${nanoid()}`,
56
70
  scope: 'purchase:coupons',
57
- 'http://velocitynetwork.foundation/groupId': 'did:ion:1234',
71
+ [VNF_GROUP_ID_CLAIM]: DEFAULT_GROUP_ID,
58
72
  };
59
73
 
60
- const testAuth0UserAdminPayMethodsScope = {
61
- sub: 'auth0|123654',
74
+ const testAdminPayMethodsUser = {
75
+ sub: `auth0|${nanoid()}`,
62
76
  scope: 'admin:pay_methods',
63
77
  };
64
78
 
65
79
  module.exports = {
66
- testAuth0User,
67
- baseAuth0User,
68
- testAuth0UserWriteOrganizationsScope,
69
- testAuth0UserPurchaseCouponScope,
70
- testAuth0UserAdminUserScope,
71
- testAuth0UserWriteUserScope,
72
- testAuth0ReadOrganizationScope,
73
- testAuth0UserAdminPayMethodsScope,
74
- auth0AdminOrganization,
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
  };