@getjones/test-infra 2.10.6 → 2.10.8

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": "@getjones/test-infra",
3
- "version": "2.10.6",
3
+ "version": "2.10.8",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,9 @@
1
+ const { expect } = require('chai');
1
2
  const env = require('../../../../../env');
2
3
  const accountsAPI = require('./accounts.core.api');
3
4
  const CreateAccountModel = require('../../models/core/create.account.model');
4
5
  const { validateType } = require('../../../../../common/validations/typeValidations');
6
+ const httpResponseStatusCodes = require('../../../../../../../../packages/test-infra/src/common/httpResponseStatusCodes.json');
5
7
 
6
8
  const { accountCreationSecret } = env.getEnv();
7
9
 
@@ -18,16 +20,19 @@ const createAccount = async (createAccountModel, context) => {
18
20
 
19
21
  const getAccount = async (accountName, context) => {
20
22
  const response = await accountsAPI.getByName(accountName, context);
23
+ expect(response.status, 'Failed to get accounts by name').to.equal(httpResponseStatusCodes.OK);
21
24
 
22
- if (!response.data || !response.data.length) {
25
+ const existingAccounts = response.data;
26
+
27
+ if (!existingAccounts || !existingAccounts.length) {
23
28
  return null;
24
29
  }
25
30
 
26
- if (response.data.length > 1) {
31
+ if (existingAccounts.length > 1) {
27
32
  throw new Error(`Got more than one account with the name: ${accountName}. IDs: ${existingAccounts.map(item => item.userId).join(', ')}`);
28
33
  }
29
34
 
30
- return response.data[0];
35
+ return existingAccounts[0];
31
36
  };
32
37
 
33
38
  const getOrCreateAccount = async (createAccountModel, context) => {
@@ -4,6 +4,10 @@ const { UpdateRequirementModel } = require('../models/update.requirement.model')
4
4
  const { AttributeModel, PolicyModel, AttributeTypes } = require('../models/policy.model');
5
5
  const { CreateRequirementModel } = require('../models/create.requirement.model');
6
6
 
7
+ const customAttributes = {
8
+ Including: 'multiple'
9
+ };
10
+
7
11
  const convertNumericValuesToNumberType = function(value) {
8
12
  if (dataTypeUtils.isString(value) && value.startsWith('$')) {
9
13
  return Number(value.replace(/[$,]/g, ''));
@@ -46,10 +50,12 @@ const parseRequirementConfig = function(config) {
46
50
 
47
51
  if (dataTypeUtils.isObject(config[policy])) {
48
52
  for (const attribute in config[policy]) {
53
+ const attributeName = customAttributes[attribute] || attribute;
54
+
49
55
  attributes.push({
50
- name: attribute,
56
+ name: attributeName,
51
57
  type: preparePolicyAttributesTypes(config[policy][attribute]),
52
- values: attribute === 'Including' ?
58
+ values: attributeName === customAttributes.Including ?
53
59
  config[policy][attribute].split(', ') :
54
60
  [convertNumericValuesToNumberType(config[policy][attribute])]
55
61
  });
@@ -89,7 +89,7 @@ const removeAllUserTraceFromDb = (userId, context) => {
89
89
 
90
90
  const deleteUserByEmail = async (userEmail, context) => {
91
91
  const { data: user } = await getUserByEmail(userEmail, context);
92
- return deleteUser(user.subuserId, context);
92
+ return user ? deleteUser(user.subuserId, context) : null;
93
93
  };
94
94
 
95
95
  const reinviteUser = (userId, context) => {