@unito/integration-cli 0.60.1 → 0.60.3

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.
@@ -13,7 +13,7 @@ describe('OAuth2Helper', () => {
13
13
  let openSpy;
14
14
  let fetchStub;
15
15
  describe('constructor', () => {
16
- it('should throw an error if the request content type is not supported', async () => {
16
+ it('throws an error if the request content type is not supported', async () => {
17
17
  try {
18
18
  new oauth2_1.default({ scopes: [], requestContentType: 'random' });
19
19
  }
@@ -51,18 +51,18 @@ describe('OAuth2Helper', () => {
51
51
  sinon_1.default.restore();
52
52
  });
53
53
  describe('authorize', () => {
54
- it('should open the authorization URL', async () => {
54
+ it('opens the authorization URL', async () => {
55
55
  await oauth2Helper.authorize();
56
56
  sinon_1.default.assert.calledOnce(openSpy);
57
57
  sinon_1.default.assert.calledWith(openSpy, 'https://provider.com/oauth/authorize?client_id=your-client-id&scope=scope1+scope2&state=eyJjbGlDYWxsYmFja1VybCI6Ii9vYXV0aDIvY2FsbGJhY2sifQ%3D%3D&response_type=code&redirect_uri=https%3A%2F%2Fintegrations-platform.unito.io%2Fcredentials%2Fnew%2Foauth2%2Fcallback-cli');
58
58
  });
59
- it('should maintain the pre-existing query parameters in authorization URL', async () => {
59
+ it('maintains the pre-existing query parameters in authorization URL', async () => {
60
60
  oauth2Helper['providerAuthorizationUrl'] = 'https://provider.com/oauth/authorize?query1=value1&query2=value2';
61
61
  await oauth2Helper.authorize();
62
62
  sinon_1.default.assert.calledOnce(openSpy);
63
63
  sinon_1.default.assert.calledWith(openSpy, 'https://provider.com/oauth/authorize?query1=value1&query2=value2&client_id=your-client-id&scope=scope1+scope2&state=eyJjbGlDYWxsYmFja1VybCI6Ii9vYXV0aDIvY2FsbGJhY2sifQ%3D%3D&response_type=code&redirect_uri=https%3A%2F%2Fintegrations-platform.unito.io%2Fcredentials%2Fnew%2Foauth2%2Fcallback-cli');
64
64
  });
65
- it('should support dynamic params', async () => {
65
+ it('supports dynamic params', async () => {
66
66
  oauth2Helper['providerAuthorizationUrl'] = 'https://pro-{+foo}-der.com/oauth/authorize?query1={+bar}';
67
67
  await oauth2Helper.authorize();
68
68
  sinon_1.default.assert.calledOnce(openSpy);
@@ -70,7 +70,7 @@ describe('OAuth2Helper', () => {
70
70
  });
71
71
  });
72
72
  describe('handleCallback', () => {
73
- it('should retrieve the access token and return it in the response', async () => {
73
+ it('retrieves the access token and return it in the response', async () => {
74
74
  const code = 'test-code';
75
75
  const req = { query: { code } };
76
76
  const res = { send: sinon_1.default.stub(), setHeader: sinon_1.default.stub() };
@@ -87,7 +87,7 @@ describe('OAuth2Helper', () => {
87
87
  sinon_1.default.assert.calledOnce(res.send);
88
88
  sinon_1.default.assert.calledWith(res.send, oauth2Namespace.HTML_SUCCESS_MSG);
89
89
  });
90
- it('should handle dynamic variables with values from provider response and credential payload', async () => {
90
+ it('handles dynamic variables with values from provider response and credential payload', async () => {
91
91
  oauth2Helper['tokenUrl'] = 'https://{+foo}.com/oauth/token?specialParam={+authorizationResponse.responseValue}';
92
92
  const code = 'test-code';
93
93
  const req = { query: { code, responseValue: 'DynamicValue' } };
@@ -105,7 +105,7 @@ describe('OAuth2Helper', () => {
105
105
  sinon_1.default.assert.calledOnce(res.send);
106
106
  sinon_1.default.assert.calledWith(res.send, oauth2Namespace.HTML_SUCCESS_MSG);
107
107
  });
108
- it('should handle errors and return 500 status', async () => {
108
+ it('handles errors - fetch exception', async () => {
109
109
  const code = 'test-code';
110
110
  const req = { query: { code } };
111
111
  const res = { send: sinon_1.default.stub(), setHeader: sinon_1.default.stub() };
@@ -114,9 +114,18 @@ describe('OAuth2Helper', () => {
114
114
  sinon_1.default.assert.calledOnce(res.send);
115
115
  sinon_1.default.assert.calledWith(res.send, oauth2Namespace.HTML_ERROR_MSG);
116
116
  });
117
+ it('handles errors - response', async () => {
118
+ const code = 'test-code';
119
+ const req = { query: { code } };
120
+ const res = { send: sinon_1.default.stub(), setHeader: sinon_1.default.stub() };
121
+ fetchStub.resolves({ status: 500 });
122
+ await oauth2Helper['handleCallback'](req, res);
123
+ sinon_1.default.assert.calledOnce(res.send);
124
+ sinon_1.default.assert.calledWith(res.send, oauth2Namespace.HTML_ERROR_MSG);
125
+ });
117
126
  });
118
127
  describe('updateToken', () => {
119
- it('should retrieve the access token when a refresh token is available', async () => {
128
+ it('retrieves the access token when a refresh token is available', async () => {
120
129
  const refreshToken = 'test-refresh-token';
121
130
  const accessToken = 'test-access-token';
122
131
  const fetchResponse = { access_token: accessToken, refresh_token: refreshToken };
@@ -125,14 +134,14 @@ describe('OAuth2Helper', () => {
125
134
  strict_1.default.deepEqual(result, { accessToken, refreshToken });
126
135
  sinon_1.default.assert.calledOnce(fetchStub);
127
136
  });
128
- it('should throw an error when failing to refresh the access token', async () => {
137
+ it('throws an error when failing to refresh the access token', async () => {
129
138
  const refreshToken = 'test-refresh-token';
130
139
  fetchStub.rejects(new Error('Failed to retrieve access token'));
131
140
  const response = oauth2Helper.updateToken(refreshToken);
132
141
  await strict_1.default.rejects(response, errors_1.FailedToRetrieveAccessTokenError);
133
142
  sinon_1.default.assert.calledOnce(fetchStub);
134
143
  });
135
- it("should throw an error if we don't support the request content type", async () => {
144
+ it("throws an error if we don't support the request content type", async () => {
136
145
  const refreshToken = 'test-refresh-token';
137
146
  oauth2Helper['requestContentType'] = 'random';
138
147
  const response = oauth2Helper.updateToken(refreshToken);
@@ -140,14 +149,14 @@ describe('OAuth2Helper', () => {
140
149
  });
141
150
  });
142
151
  describe('encodeBody', () => {
143
- it('should encode body data as URL-encoded when content type is URL_ENCODED', () => {
152
+ it('encodes body data as URL-encoded when content type is URL_ENCODED', () => {
144
153
  const bodyData = { key1: 'value1', key2: 'value2' };
145
154
  const contentType = configurationTypes_1.RequestContentType.URL_ENCODED;
146
155
  const expectedEncodedBody = 'key1=value1&key2=value2';
147
156
  const encodedBody = oauth2Helper['encodeBody'](bodyData, contentType);
148
157
  strict_1.default.equal(encodedBody, expectedEncodedBody);
149
158
  });
150
- it('should encode body data as JSON when content type is JSON', () => {
159
+ it('encodes body data as JSON when content type is JSON', () => {
151
160
  const bodyData = { key1: 'value1', key2: 'value2' };
152
161
  const contentType = configurationTypes_1.RequestContentType.JSON;
153
162
  const expectedEncodedBody = JSON.stringify(bodyData);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.60.1",
2
+ "version": "0.60.3",
3
3
  "commands": {
4
4
  "activity": {
5
5
  "id": "activity",
@@ -9,6 +9,7 @@
9
9
  "pluginAlias": "@unito/integration-cli",
10
10
  "pluginType": "core",
11
11
  "aliases": [],
12
+ "hiddenAliases": [],
12
13
  "examples": [
13
14
  "<%= config.bin %> <%= command.id %>"
14
15
  ],
@@ -52,6 +53,7 @@
52
53
  "pluginAlias": "@unito/integration-cli",
53
54
  "pluginType": "core",
54
55
  "aliases": [],
56
+ "hiddenAliases": [],
55
57
  "examples": [
56
58
  "<%= config.bin %> <%= command.id %>"
57
59
  ],
@@ -146,6 +148,7 @@
146
148
  "pluginAlias": "@unito/integration-cli",
147
149
  "pluginType": "core",
148
150
  "aliases": [],
151
+ "hiddenAliases": [],
149
152
  "examples": [
150
153
  "<%= config.bin %> <%= command.id %>"
151
154
  ],
@@ -179,6 +182,7 @@
179
182
  "pluginAlias": "@unito/integration-cli",
180
183
  "pluginType": "core",
181
184
  "aliases": [],
185
+ "hiddenAliases": [],
182
186
  "examples": [
183
187
  "<%= config.bin %> <%= command.id %>",
184
188
  "<%= config.bin %> <%= command.id %> --name pokemon"
@@ -202,6 +206,7 @@
202
206
  "pluginAlias": "@unito/integration-cli",
203
207
  "pluginType": "core",
204
208
  "aliases": [],
209
+ "hiddenAliases": [],
205
210
  "examples": [
206
211
  "<%= config.bin %> <%= command.id %>"
207
212
  ],
@@ -229,6 +234,7 @@
229
234
  "pluginAlias": "@unito/integration-cli",
230
235
  "pluginType": "core",
231
236
  "aliases": [],
237
+ "hiddenAliases": [],
232
238
  "examples": [
233
239
  "<%= config.bin %> <%= command.id %>"
234
240
  ],
@@ -257,6 +263,7 @@
257
263
  "pluginAlias": "@unito/integration-cli",
258
264
  "pluginType": "core",
259
265
  "aliases": [],
266
+ "hiddenAliases": [],
260
267
  "examples": [
261
268
  "<%= config.bin %> <%= command.id %>",
262
269
  "<%= config.bin %> <%= command.id %> --reauth --test-account=compliance"
@@ -310,6 +317,7 @@
310
317
  "pluginAlias": "@unito/integration-cli",
311
318
  "pluginType": "core",
312
319
  "aliases": [],
320
+ "hiddenAliases": [],
313
321
  "examples": [
314
322
  "<%= config.bin %> <%= command.id %>"
315
323
  ],
@@ -382,6 +390,7 @@
382
390
  "pluginAlias": "@unito/integration-cli",
383
391
  "pluginType": "core",
384
392
  "aliases": [],
393
+ "hiddenAliases": [],
385
394
  "examples": [
386
395
  "<%= config.bin %> <%= command.id %>"
387
396
  ],
@@ -513,6 +522,7 @@
513
522
  "pluginAlias": "@unito/integration-cli",
514
523
  "pluginType": "core",
515
524
  "aliases": [],
525
+ "hiddenAliases": [],
516
526
  "examples": [
517
527
  "<%= config.bin %> <%= command.id %>"
518
528
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-cli",
3
- "version": "0.60.1",
3
+ "version": "0.60.3",
4
4
  "description": "Integration CLI",
5
5
  "bin": {
6
6
  "integration-cli": "./bin/run"
@@ -36,8 +36,8 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@oclif/core": "3.x",
39
- "@unito/integration-debugger": "0.25.1",
40
- "@unito/integrations-platform-client": "0.48.2",
39
+ "@unito/integration-debugger": "0.26.0",
40
+ "@oazapfts/runtime": "1.x",
41
41
  "ajv": "8.x",
42
42
  "ajv-formats": "2.x",
43
43
  "better-ajv-errors": "1.x",