@zohodesk/testinglibrary 0.0.66-n20-experimental → 0.0.68-n20-experimental
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/build/common/data-generator/steps/DataGenerator.spec.js +4 -8
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +2 -2
- package/build/core/dataGenerator/DataGenerator.js +4 -9
- package/build/core/playwright/builtInFixtures/caseTimeout.js +20 -0
- package/build/core/playwright/builtInFixtures/index.js +3 -1
- package/build/core/playwright/helpers/browserTimeoutFactor.js +16 -0
- package/build/core/playwright/helpers/caseTimeoutResolver.js +37 -0
- package/build/core/playwright/readConfigFile.js +1 -1
- package/build/core/playwright/setup/config-utils.js +7 -4
- package/build/core/playwright/types.js +1 -1
- package/build/setup-folder-structure/samples/uat-config-sample.js +1 -1
- package/build/test/core/playwright/buildInFixtures/__tests__/caseTimeout.test.js +96 -0
- package/jest.config.js +1 -1
- package/npm-shrinkwrap.json +1726 -2785
- package/package.json +1 -1
- package/unit_reports/unit-report.html +1 -1
- package/build/core/dataGenerator/authenticator/Authenticator.js +0 -35
- package/build/core/dataGenerator/authenticator/CookieAuthenticator.js +0 -41
- package/build/core/dataGenerator/authenticator/JWTauthenticator.js +0 -71
- package/build/core/dataGenerator/authenticator/OAuthAuthenticator.js +0 -31
- package/build/core/dataGenerator/authenticator/OrgOAuthAuthenticator.js +0 -29
- package/build/test/core/dataGenerator/authenticator/__test__/Authenticator.test.js +0 -89
- package/build/test/core/dataGenerator/authenticator/__test__/JWTauthenticator.test.js +0 -134
- package/build/test/core/dataGenerator/authenticator/__test__/OAuthAuthenticator.test.js +0 -46
- package/build/test/core/dataGenerator/authenticator/__test__/OrgOAuthAuthenticator.test.js +0 -46
- package/build/test/core/dataGenerator/authenticator/__tests__/JWTauthenticator.test.js +0 -165
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _JWTauthenticator = _interopRequireDefault(require("../../../../../core/dataGenerator/authenticator/JWTauthenticator.js"));
|
|
5
|
-
const MOCK_ACCESS_TOKEN = '1026812030.abc123.def456';
|
|
6
|
-
const makeActorInfo = (overrides = {}) => ({
|
|
7
|
-
email: 'anitha.m+uatagent@zohotest.com',
|
|
8
|
-
'data-generator': {
|
|
9
|
-
account: {
|
|
10
|
-
authentications: ['jwt-auth'],
|
|
11
|
-
'jwt-oauth': {
|
|
12
|
-
jwt_secret: 'PZkhUzx0ruJQNU4QRagh0u13uuKk9s0m5EU1pUbD',
|
|
13
|
-
response_type: 'remote_token',
|
|
14
|
-
client_id: '1026812030.WKK443JMM12S4ZVR23C3HUK66PFUSG',
|
|
15
|
-
token_url: 'https://accounts-portal.csez.zohocorpin.com/clientoauth/v2/1026812030/remote/auth',
|
|
16
|
-
domain_url: 'https://zdesk-devops08.csez.zohocorpin.com:31000'
|
|
17
|
-
},
|
|
18
|
-
...overrides
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const makeApiPayload = (overrides = {}) => ({
|
|
23
|
-
scenario_name: 'verify the Department page is loaded',
|
|
24
|
-
account: {
|
|
25
|
-
storeVariables: {
|
|
26
|
-
orgId: '20408511'
|
|
27
|
-
},
|
|
28
|
-
authentications: ['jwt-auth']
|
|
29
|
-
},
|
|
30
|
-
...overrides
|
|
31
|
-
});
|
|
32
|
-
const mockFetchSuccess = () => {
|
|
33
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
34
|
-
ok: true,
|
|
35
|
-
json: jest.fn().mockResolvedValue({
|
|
36
|
-
access_token: MOCK_ACCESS_TOKEN
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
describe('JWTauthenticator.constructPayload', () => {
|
|
41
|
-
let authenticator;
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
authenticator = new _JWTauthenticator.default();
|
|
44
|
-
process.env.DG_JWT_AUTHENTICATOR_API = 'https://authenticator.zdesk.csez.zohocorpin.com/jwtToken';
|
|
45
|
-
process.env.DG_JWT_AUTH_URL = 'https://jwt.zdesk.csez.zohocorpin.com/JWTAuth';
|
|
46
|
-
delete process.env.DG_JWT_TOKEN_URL;
|
|
47
|
-
delete process.env.DG_DOMAIN_URL;
|
|
48
|
-
jest.clearAllMocks();
|
|
49
|
-
});
|
|
50
|
-
describe('no-op cases', () => {
|
|
51
|
-
it('returns apiPayload unchanged when jwt-oauth config is absent in actorInfo', async () => {
|
|
52
|
-
const actorInfo = {
|
|
53
|
-
email: 'anitha.m+uatagent@zohotest.com',
|
|
54
|
-
'data-generator': {
|
|
55
|
-
account: {
|
|
56
|
-
authentications: ['jwt-auth']
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const apiPayload = makeApiPayload();
|
|
61
|
-
const result = await authenticator.constructPayload(apiPayload, actorInfo);
|
|
62
|
-
expect(result).toBe(apiPayload);
|
|
63
|
-
expect(result.account.authHeaders).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
it('returns apiPayload unchanged when actorInfo has no data-generator', async () => {
|
|
66
|
-
const apiPayload = makeApiPayload();
|
|
67
|
-
const result = await authenticator.constructPayload(apiPayload, {});
|
|
68
|
-
expect(result).toBe(apiPayload);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('successful token fetch', () => {
|
|
72
|
-
it('sets authHeaders.Authorization with Zoho-oauthtoken prefix', async () => {
|
|
73
|
-
mockFetchSuccess();
|
|
74
|
-
const result = await authenticator.constructPayload(makeApiPayload(), makeActorInfo());
|
|
75
|
-
expect(result.account.authHeaders.Authorization).toBe(`Zoho-oauthtoken ${MOCK_ACCESS_TOKEN}`);
|
|
76
|
-
});
|
|
77
|
-
it('URL-encodes email with + and @ characters as user_token', async () => {
|
|
78
|
-
mockFetchSuccess();
|
|
79
|
-
await authenticator.constructPayload(makeApiPayload(), makeActorInfo());
|
|
80
|
-
const body = JSON.parse(global.fetch.mock.calls[0][1].body);
|
|
81
|
-
expect(body.user_token).toBe('anitha.m%2Buatagent%40zohotest.com');
|
|
82
|
-
});
|
|
83
|
-
it('posts to DG_JWT_AUTHENTICATOR_API with correct payload fields', async () => {
|
|
84
|
-
mockFetchSuccess();
|
|
85
|
-
await authenticator.constructPayload(makeApiPayload(), makeActorInfo());
|
|
86
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
87
|
-
const body = JSON.parse(options.body);
|
|
88
|
-
expect(url).toBe(process.env.DG_JWT_AUTHENTICATOR_API);
|
|
89
|
-
expect(options.method).toBe('POST');
|
|
90
|
-
expect(options.headers['Content-Type']).toBe('application/json');
|
|
91
|
-
expect(body.jwt_secret).toBe('PZkhUzx0ruJQNU4QRagh0u13uuKk9s0m5EU1pUbD');
|
|
92
|
-
expect(body.response_type).toBe('remote_token');
|
|
93
|
-
expect(body.client_id).toBe('1026812030.WKK443JMM12S4ZVR23C3HUK66PFUSG');
|
|
94
|
-
expect(body.jwt_auth_url).toBe(process.env.DG_JWT_AUTH_URL);
|
|
95
|
-
expect(body.token_url).toBe('https://accounts-portal.csez.zohocorpin.com/clientoauth/v2/1026812030/remote/auth');
|
|
96
|
-
expect(body.domain_url).toBe('https://zdesk-devops08.csez.zohocorpin.com:31000');
|
|
97
|
-
});
|
|
98
|
-
it('does not overwrite existing authHeaders fields other than Authorization', async () => {
|
|
99
|
-
mockFetchSuccess();
|
|
100
|
-
const apiPayload = makeApiPayload();
|
|
101
|
-
apiPayload.account.authHeaders = {
|
|
102
|
-
'X-Custom-Header': 'custom-value'
|
|
103
|
-
};
|
|
104
|
-
const result = await authenticator.constructPayload(apiPayload, makeActorInfo());
|
|
105
|
-
expect(result.account.authHeaders['X-Custom-Header']).toBe('custom-value');
|
|
106
|
-
expect(result.account.authHeaders.Authorization).toBe(`Zoho-oauthtoken ${MOCK_ACCESS_TOKEN}`);
|
|
107
|
-
});
|
|
108
|
-
it('resolves token_url from DG_JWT_TOKEN_URL env when not in config', async () => {
|
|
109
|
-
mockFetchSuccess();
|
|
110
|
-
process.env.DG_JWT_TOKEN_URL = 'https://accounts-portal.csez.zohocorpin.com/clientoauth/v2/{ZSOID}/remote/auth';
|
|
111
|
-
const actorInfo = makeActorInfo({
|
|
112
|
-
'jwt-oauth': {
|
|
113
|
-
...makeActorInfo()['data-generator'].account['jwt-oauth'],
|
|
114
|
-
token_url: undefined
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
await authenticator.constructPayload(makeApiPayload(), actorInfo);
|
|
118
|
-
const body = JSON.parse(global.fetch.mock.calls[0][1].body);
|
|
119
|
-
expect(body.token_url).toBe('https://accounts-portal.csez.zohocorpin.com/clientoauth/v2/1026812030/remote/auth');
|
|
120
|
-
});
|
|
121
|
-
it('resolves domain_url from DG_DOMAIN_URL env when not in config', async () => {
|
|
122
|
-
mockFetchSuccess();
|
|
123
|
-
process.env.DG_DOMAIN_URL = 'https://zdesk-env-domain.csez.zohocorpin.com:31000';
|
|
124
|
-
const jwtOauth = {
|
|
125
|
-
...makeActorInfo()['data-generator'].account['jwt-oauth'],
|
|
126
|
-
domain_url: undefined
|
|
127
|
-
};
|
|
128
|
-
const actorInfo = {
|
|
129
|
-
...makeActorInfo(),
|
|
130
|
-
'data-generator': {
|
|
131
|
-
account: {
|
|
132
|
-
authentications: ['jwt-auth'],
|
|
133
|
-
'jwt-oauth': jwtOauth
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
await authenticator.constructPayload(makeApiPayload(), actorInfo);
|
|
138
|
-
const body = JSON.parse(global.fetch.mock.calls[0][1].body);
|
|
139
|
-
expect(body.domain_url).toBe('https://zdesk-env-domain.csez.zohocorpin.com:31000');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe('authenticator service errors', () => {
|
|
143
|
-
it('throws when authenticator responds with non-ok status', async () => {
|
|
144
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
145
|
-
ok: false,
|
|
146
|
-
status: 401,
|
|
147
|
-
text: jest.fn().mockResolvedValue('Unauthorized')
|
|
148
|
-
});
|
|
149
|
-
await expect(authenticator.constructPayload(makeApiPayload(), makeActorInfo())).rejects.toThrow('status: 401');
|
|
150
|
-
});
|
|
151
|
-
it('throws when authenticator response has no access_token', async () => {
|
|
152
|
-
global.fetch = jest.fn().mockResolvedValue({
|
|
153
|
-
ok: true,
|
|
154
|
-
json: jest.fn().mockResolvedValue({
|
|
155
|
-
error: 'invalid_grant'
|
|
156
|
-
})
|
|
157
|
-
});
|
|
158
|
-
await expect(authenticator.constructPayload(makeApiPayload(), makeActorInfo())).rejects.toThrow('access_token');
|
|
159
|
-
});
|
|
160
|
-
it('throws when fetch fails due to network error', async () => {
|
|
161
|
-
global.fetch = jest.fn().mockRejectedValue(new Error('ECONNREFUSED'));
|
|
162
|
-
await expect(authenticator.constructPayload(makeApiPayload(), makeActorInfo())).rejects.toThrow('ECONNREFUSED');
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
});
|