@getjones/test-infra 2.1.3 → 2.1.4

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.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -2,11 +2,17 @@ const requests = require('../../../../common/requests/cookieAuth/requests');
2
2
  const { backendUrl } = require('../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
- login: `${backendUrl}/logincontroller`
5
+ login: `${backendUrl}/logincontroller`,
6
+ isHubUser: email => `${backendUrl}/vendor-app/is-hub-user?email=${email}`
7
+
6
8
  };
7
9
 
8
10
  const login = (email, password) => {
9
11
  return requests.postRequestHandler(Endpoints.login, { email, password });
10
12
  };
11
13
 
12
- module.exports = { login };
14
+ const vendorHubLogin = email => {
15
+ return requests.postRequestHandler(Endpoints.isHubUser(email), { email });
16
+ };
17
+
18
+ module.exports = { login, vendorHubLogin };
@@ -13,6 +13,17 @@ const getAuthCookie = async (email, password) => {
13
13
  }
14
14
  };
15
15
 
16
+ const getVendorHubAuthCookie = async email => {
17
+ try {
18
+ const response = await authApi.vendorHubLogin(email);
19
+ const authCookie = response.headers['set-cookie'].find(item => item.startsWith('JonesToken2='));
20
+
21
+ return authCookie;
22
+ } catch (error) {
23
+ throw new Error(`Failed to login to vendor hub by email:${email}`, error);
24
+ }
25
+ };
26
+
16
27
  const getIcsCookie = () => {
17
28
  requiredValidation({
18
29
  'credentials.superUser': credentials.superUser,
@@ -56,6 +67,7 @@ const getAuditorId = async () => {
56
67
 
57
68
  module.exports = {
58
69
  getAuthCookie,
70
+ getVendorHubAuthCookie,
59
71
  getIcsCookie,
60
72
  getAuditorCookie,
61
73
  getOperatorCookie,
@@ -1,7 +1,6 @@
1
1
  const auditApi = require('./audit.api');
2
2
  const { AuditRequestModel, AuditListParametersModel, AuditDatesModel } = require('../../models/audit/audit.model');
3
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
4
- const env = require('../../../../../../../../src/env');
5
4
  const util = require('../../utils/util');
6
5
  const dataTypeUtils = require('../../../../../common/utils/dataTypeUtils');
7
6
 
@@ -61,7 +60,7 @@ const getAuditMetadata = async (
61
60
  contractCreateDate: vendorDetails.contractCreateDate
62
61
  };
63
62
 
64
- metadata.auditorId = await util.getAuditorId(env);
63
+ metadata.auditorId = await util.getAuditorId();
65
64
 
66
65
  return metadata;
67
66
  };