@itentialopensource/adapter-azure_devops 0.1.1
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/.eslintignore +5 -0
- package/.eslintrc.js +18 -0
- package/.jshintrc +3 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +158 -0
- package/LICENSE +201 -0
- package/README.md +687 -0
- package/adapter.js +1606 -0
- package/adapterBase.js +1028 -0
- package/entities/.generic/action.json +109 -0
- package/entities/.generic/schema.json +23 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +53 -0
- package/entities/.system/schemaTokenResp.json +53 -0
- package/entities/Artifacts/action.json +25 -0
- package/entities/Artifacts/mockdatafiles/artifactsGet-default.json +5 -0
- package/entities/Artifacts/schema.json +41 -0
- package/entities/Logs/action.json +46 -0
- package/entities/Logs/mockdatafiles/logsGet-default.json +11 -0
- package/entities/Logs/mockdatafiles/logsList-default.json +119 -0
- package/entities/Logs/schema.json +42 -0
- package/entities/Pipelines/action.json +66 -0
- package/entities/Pipelines/mockdatafiles/pipelinesCreate-default.json +6 -0
- package/entities/Pipelines/mockdatafiles/pipelinesGet-default.json +6 -0
- package/entities/Pipelines/mockdatafiles/pipelinesList-default.json +26 -0
- package/entities/Pipelines/schema.json +43 -0
- package/entities/Preview/action.json +24 -0
- package/entities/Preview/mockdatafiles/previewPreview-default.json +3 -0
- package/entities/Preview/schema.json +30 -0
- package/entities/Runs/action.json +66 -0
- package/entities/Runs/mockdatafiles/runsGet-default.json +4 -0
- package/entities/Runs/mockdatafiles/runsList-default.json +18 -0
- package/entities/Runs/mockdatafiles/runsRunPipeline-default.json +4 -0
- package/entities/Runs/schema.json +32 -0
- package/error.json +184 -0
- package/package.json +85 -0
- package/pronghorn.json +2488 -0
- package/propertiesSchema.json +840 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/ado.json +1382 -0
- package/report/creationReport.json +228 -0
- package/report/updateReport1639421539710.json +95 -0
- package/sampleProperties.json +106 -0
- package/test/integration/adapterTestBasicGet.js +85 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +751 -0
- package/test/unit/adapterBaseTestUnit.js +944 -0
- package/test/unit/adapterTestUnit.js +2192 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +224 -0
- package/utils/findPath.js +74 -0
- package/utils/modify.js +154 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/pre-commit.sh +27 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +169 -0
- package/utils/tbUtils.js +445 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +190 -0
- package/workflows/README.md +3 -0
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2019 (pre-modifications) */
|
|
2
|
+
|
|
3
|
+
// Set globals
|
|
4
|
+
/* global describe it log pronghornProps */
|
|
5
|
+
/* eslint no-unused-vars: warn */
|
|
6
|
+
|
|
7
|
+
// include required items for testing & logging
|
|
8
|
+
const assert = require('assert');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const mocha = require('mocha');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const winston = require('winston');
|
|
13
|
+
const { expect } = require('chai');
|
|
14
|
+
const { use } = require('chai');
|
|
15
|
+
const td = require('testdouble');
|
|
16
|
+
|
|
17
|
+
const anything = td.matchers.anything();
|
|
18
|
+
|
|
19
|
+
// stub and attemptTimeout are used throughout the code so set them here
|
|
20
|
+
let logLevel = 'none';
|
|
21
|
+
const stub = true;
|
|
22
|
+
const isRapidFail = false;
|
|
23
|
+
const isSaveMockData = false;
|
|
24
|
+
const attemptTimeout = 5000;
|
|
25
|
+
|
|
26
|
+
// these variables can be changed to run in integrated mode so easier to set them here
|
|
27
|
+
// always check these in with bogus data!!!
|
|
28
|
+
const host = 'replace.hostorip.here';
|
|
29
|
+
const username = 'username';
|
|
30
|
+
const password = 'password';
|
|
31
|
+
const protocol = 'http';
|
|
32
|
+
const port = 80;
|
|
33
|
+
const sslenable = false;
|
|
34
|
+
const sslinvalid = false;
|
|
35
|
+
|
|
36
|
+
// these are the adapter properties. You generally should not need to alter
|
|
37
|
+
// any of these after they are initially set up
|
|
38
|
+
global.pronghornProps = {
|
|
39
|
+
pathProps: {
|
|
40
|
+
encrypted: false
|
|
41
|
+
},
|
|
42
|
+
adapterProps: {
|
|
43
|
+
adapters: [{
|
|
44
|
+
id: 'Test-azure_devops',
|
|
45
|
+
type: 'AzureDevops',
|
|
46
|
+
properties: {
|
|
47
|
+
host,
|
|
48
|
+
port,
|
|
49
|
+
base_path: '/',
|
|
50
|
+
version: '',
|
|
51
|
+
cache_location: 'none',
|
|
52
|
+
encode_pathvars: true,
|
|
53
|
+
save_metric: false,
|
|
54
|
+
stub,
|
|
55
|
+
protocol,
|
|
56
|
+
authentication: {
|
|
57
|
+
auth_method: 'static_token',
|
|
58
|
+
username,
|
|
59
|
+
password,
|
|
60
|
+
token: '',
|
|
61
|
+
invalid_token_error: 401,
|
|
62
|
+
token_timeout: -1,
|
|
63
|
+
token_cache: 'local',
|
|
64
|
+
auth_field: 'header.headers.Authorization',
|
|
65
|
+
auth_field_format: 'Basic {b64}Basic:{token}{/b64}',
|
|
66
|
+
auth_logging: false,
|
|
67
|
+
client_id: '',
|
|
68
|
+
client_secret: '',
|
|
69
|
+
grant_type: ''
|
|
70
|
+
},
|
|
71
|
+
healthcheck: {
|
|
72
|
+
type: 'none',
|
|
73
|
+
frequency: 60000,
|
|
74
|
+
query_object: {}
|
|
75
|
+
},
|
|
76
|
+
throttle: {
|
|
77
|
+
throttle_enabled: false,
|
|
78
|
+
number_pronghorns: 1,
|
|
79
|
+
sync_async: 'sync',
|
|
80
|
+
max_in_queue: 1000,
|
|
81
|
+
concurrent_max: 1,
|
|
82
|
+
expire_timeout: 0,
|
|
83
|
+
avg_runtime: 200,
|
|
84
|
+
priorities: [
|
|
85
|
+
{
|
|
86
|
+
value: 0,
|
|
87
|
+
percent: 100
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
request: {
|
|
92
|
+
number_redirects: 0,
|
|
93
|
+
number_retries: 3,
|
|
94
|
+
limit_retry_error: [0],
|
|
95
|
+
failover_codes: [],
|
|
96
|
+
attempt_timeout: attemptTimeout,
|
|
97
|
+
global_request: {
|
|
98
|
+
payload: {},
|
|
99
|
+
uriOptions: {},
|
|
100
|
+
addlHeaders: {},
|
|
101
|
+
authData: {}
|
|
102
|
+
},
|
|
103
|
+
healthcheck_on_timeout: true,
|
|
104
|
+
return_raw: true,
|
|
105
|
+
archiving: false,
|
|
106
|
+
return_request: false
|
|
107
|
+
},
|
|
108
|
+
proxy: {
|
|
109
|
+
enabled: false,
|
|
110
|
+
host: '',
|
|
111
|
+
port: 1,
|
|
112
|
+
protocol: 'http',
|
|
113
|
+
username: '',
|
|
114
|
+
password: ''
|
|
115
|
+
},
|
|
116
|
+
ssl: {
|
|
117
|
+
ecdhCurve: '',
|
|
118
|
+
enabled: sslenable,
|
|
119
|
+
accept_invalid_cert: sslinvalid,
|
|
120
|
+
ca_file: '',
|
|
121
|
+
key_file: '',
|
|
122
|
+
cert_file: '',
|
|
123
|
+
secure_protocol: '',
|
|
124
|
+
ciphers: ''
|
|
125
|
+
},
|
|
126
|
+
mongo: {
|
|
127
|
+
host: '',
|
|
128
|
+
port: 0,
|
|
129
|
+
database: '',
|
|
130
|
+
username: '',
|
|
131
|
+
password: '',
|
|
132
|
+
replSet: '',
|
|
133
|
+
db_ssl: {
|
|
134
|
+
enabled: false,
|
|
135
|
+
accept_invalid_cert: false,
|
|
136
|
+
ca_file: '',
|
|
137
|
+
key_file: '',
|
|
138
|
+
cert_file: ''
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}]
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
global.$HOME = `${__dirname}/../..`;
|
|
147
|
+
|
|
148
|
+
// set the log levels that Pronghorn uses, spam and trace are not defaulted in so without
|
|
149
|
+
// this you may error on log.trace calls.
|
|
150
|
+
const myCustomLevels = {
|
|
151
|
+
levels: {
|
|
152
|
+
spam: 6,
|
|
153
|
+
trace: 5,
|
|
154
|
+
debug: 4,
|
|
155
|
+
info: 3,
|
|
156
|
+
warn: 2,
|
|
157
|
+
error: 1,
|
|
158
|
+
none: 0
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// need to see if there is a log level passed in
|
|
163
|
+
process.argv.forEach((val) => {
|
|
164
|
+
// is there a log level defined to be passed in?
|
|
165
|
+
if (val.indexOf('--LOG') === 0) {
|
|
166
|
+
// get the desired log level
|
|
167
|
+
const inputVal = val.split('=')[1];
|
|
168
|
+
|
|
169
|
+
// validate the log level is supported, if so set it
|
|
170
|
+
if (Object.hasOwnProperty.call(myCustomLevels.levels, inputVal)) {
|
|
171
|
+
logLevel = inputVal;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// need to set global logging
|
|
177
|
+
global.log = winston.createLogger({
|
|
178
|
+
level: logLevel,
|
|
179
|
+
levels: myCustomLevels.levels,
|
|
180
|
+
transports: [
|
|
181
|
+
new winston.transports.Console()
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Runs the common asserts for test
|
|
187
|
+
*/
|
|
188
|
+
function runCommonAsserts(data, error) {
|
|
189
|
+
assert.equal(undefined, error);
|
|
190
|
+
assert.notEqual(undefined, data);
|
|
191
|
+
assert.notEqual(null, data);
|
|
192
|
+
assert.notEqual(undefined, data.response);
|
|
193
|
+
assert.notEqual(null, data.response);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Runs the error asserts for the test
|
|
198
|
+
*/
|
|
199
|
+
function runErrorAsserts(data, error, code, origin, displayStr) {
|
|
200
|
+
assert.equal(null, data);
|
|
201
|
+
assert.notEqual(undefined, error);
|
|
202
|
+
assert.notEqual(null, error);
|
|
203
|
+
assert.notEqual(undefined, error.IAPerror);
|
|
204
|
+
assert.notEqual(null, error.IAPerror);
|
|
205
|
+
assert.notEqual(undefined, error.IAPerror.displayString);
|
|
206
|
+
assert.notEqual(null, error.IAPerror.displayString);
|
|
207
|
+
assert.equal(code, error.icode);
|
|
208
|
+
assert.equal(origin, error.IAPerror.origin);
|
|
209
|
+
assert.equal(displayStr, error.IAPerror.displayString);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @function saveMockData
|
|
214
|
+
* Attempts to take data from responses and place them in MockDataFiles to help create Mockdata.
|
|
215
|
+
* Note, this was built based on entity file structure for Adapter-Engine 1.6.x
|
|
216
|
+
* @param {string} entityName - Name of the entity saving mock data for
|
|
217
|
+
* @param {string} actionName - Name of the action saving mock data for
|
|
218
|
+
* @param {string} descriptor - Something to describe this test (used as a type)
|
|
219
|
+
* @param {string or object} responseData - The data to put in the mock file.
|
|
220
|
+
*/
|
|
221
|
+
function saveMockData(entityName, actionName, descriptor, responseData) {
|
|
222
|
+
// do not need to save mockdata if we are running in stub mode (already has mock data) or if told not to save
|
|
223
|
+
if (stub || !isSaveMockData) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// must have a response in order to store the response
|
|
228
|
+
if (responseData && responseData.response) {
|
|
229
|
+
let data = responseData.response;
|
|
230
|
+
|
|
231
|
+
// if there was a raw response that one is better as it is untranslated
|
|
232
|
+
if (responseData.raw) {
|
|
233
|
+
data = responseData.raw;
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
const temp = JSON.parse(data);
|
|
237
|
+
data = temp;
|
|
238
|
+
} catch (pex) {
|
|
239
|
+
// do not care if it did not parse as we will just use data
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
const base = path.join(__dirname, `../../entities/${entityName}/`);
|
|
245
|
+
const mockdatafolder = 'mockdatafiles';
|
|
246
|
+
const filename = `mockdatafiles/${actionName}-${descriptor}.json`;
|
|
247
|
+
|
|
248
|
+
if (!fs.existsSync(base + mockdatafolder)) {
|
|
249
|
+
fs.mkdirSync(base + mockdatafolder);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// write the data we retrieved
|
|
253
|
+
fs.writeFile(base + filename, JSON.stringify(data, null, 2), 'utf8', (errWritingMock) => {
|
|
254
|
+
if (errWritingMock) throw errWritingMock;
|
|
255
|
+
|
|
256
|
+
// update the action file to reflect the changes. Note: We're replacing the default object for now!
|
|
257
|
+
fs.readFile(`${base}action.json`, (errRead, content) => {
|
|
258
|
+
if (errRead) throw errRead;
|
|
259
|
+
|
|
260
|
+
// parse the action file into JSON
|
|
261
|
+
const parsedJson = JSON.parse(content);
|
|
262
|
+
|
|
263
|
+
// The object update we'll write in.
|
|
264
|
+
const responseObj = {
|
|
265
|
+
type: descriptor,
|
|
266
|
+
key: '',
|
|
267
|
+
mockFile: filename
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// get the object for method we're trying to change.
|
|
271
|
+
const currentMethodAction = parsedJson.actions.find((obj) => obj.name === actionName);
|
|
272
|
+
|
|
273
|
+
// if the method was not found - should never happen but...
|
|
274
|
+
if (!currentMethodAction) {
|
|
275
|
+
throw Error('Can\'t find an action for this method in the provided entity.');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// if there is a response object, we want to replace the Response object. Otherwise we'll create one.
|
|
279
|
+
const actionResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === descriptor);
|
|
280
|
+
|
|
281
|
+
// Add the action responseObj back into the array of response objects.
|
|
282
|
+
if (!actionResponseObj) {
|
|
283
|
+
// if there is a default response object, we want to get the key.
|
|
284
|
+
const defaultResponseObj = currentMethodAction.responseObjects.find((obj) => obj.type === 'default');
|
|
285
|
+
|
|
286
|
+
// save the default key into the new response object
|
|
287
|
+
if (defaultResponseObj) {
|
|
288
|
+
responseObj.key = defaultResponseObj.key;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// save the new response object
|
|
292
|
+
currentMethodAction.responseObjects = [responseObj];
|
|
293
|
+
} else {
|
|
294
|
+
// update the location of the mock data file
|
|
295
|
+
actionResponseObj.mockFile = responseObj.mockFile;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Save results
|
|
299
|
+
fs.writeFile(`${base}action.json`, JSON.stringify(parsedJson, null, 2), (err) => {
|
|
300
|
+
if (err) throw err;
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
} catch (e) {
|
|
305
|
+
log.debug(`Failed to save mock data for ${actionName}. ${e.message}`);
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// no response to save
|
|
311
|
+
log.debug(`No data passed to save into mockdata for ${actionName}`);
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// require the adapter that we are going to be using
|
|
316
|
+
const AzureDevops = require('../../adapter');
|
|
317
|
+
|
|
318
|
+
// begin the testing - these should be pretty well defined between the describe and the it!
|
|
319
|
+
describe('[integration] Azure_devops Adapter Test', () => {
|
|
320
|
+
describe('AzureDevops Class Tests', () => {
|
|
321
|
+
const a = new AzureDevops(
|
|
322
|
+
pronghornProps.adapterProps.adapters[0].id,
|
|
323
|
+
pronghornProps.adapterProps.adapters[0].properties
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
if (isRapidFail) {
|
|
327
|
+
const state = {};
|
|
328
|
+
state.passed = true;
|
|
329
|
+
|
|
330
|
+
mocha.afterEach(function x() {
|
|
331
|
+
state.passed = state.passed
|
|
332
|
+
&& (this.currentTest.state === 'passed');
|
|
333
|
+
});
|
|
334
|
+
mocha.beforeEach(function x() {
|
|
335
|
+
if (!state.passed) {
|
|
336
|
+
return this.currentTest.skip();
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
describe('#class instance created', () => {
|
|
343
|
+
it('should be a class with properties', (done) => {
|
|
344
|
+
try {
|
|
345
|
+
assert.notEqual(null, a);
|
|
346
|
+
assert.notEqual(undefined, a);
|
|
347
|
+
const checkId = global.pronghornProps.adapterProps.adapters[0].id;
|
|
348
|
+
assert.equal(checkId, a.id);
|
|
349
|
+
assert.notEqual(null, a.allProps);
|
|
350
|
+
const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type;
|
|
351
|
+
assert.equal(check, a.healthcheckType);
|
|
352
|
+
done();
|
|
353
|
+
} catch (error) {
|
|
354
|
+
log.error(`Test Failure: ${error}`);
|
|
355
|
+
done(error);
|
|
356
|
+
}
|
|
357
|
+
}).timeout(attemptTimeout);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe('#connect', () => {
|
|
361
|
+
it('should get connected - no healthcheck', (done) => {
|
|
362
|
+
try {
|
|
363
|
+
a.healthcheckType = 'none';
|
|
364
|
+
a.connect();
|
|
365
|
+
|
|
366
|
+
try {
|
|
367
|
+
assert.equal(true, a.alive);
|
|
368
|
+
done();
|
|
369
|
+
} catch (error) {
|
|
370
|
+
log.error(`Test Failure: ${error}`);
|
|
371
|
+
done(error);
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
log.error(`Adapter Exception: ${error}`);
|
|
375
|
+
done(error);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
it('should get connected - startup healthcheck', (done) => {
|
|
379
|
+
try {
|
|
380
|
+
a.healthcheckType = 'startup';
|
|
381
|
+
a.connect();
|
|
382
|
+
|
|
383
|
+
try {
|
|
384
|
+
assert.equal(true, a.alive);
|
|
385
|
+
done();
|
|
386
|
+
} catch (error) {
|
|
387
|
+
log.error(`Test Failure: ${error}`);
|
|
388
|
+
done(error);
|
|
389
|
+
}
|
|
390
|
+
} catch (error) {
|
|
391
|
+
log.error(`Adapter Exception: ${error}`);
|
|
392
|
+
done(error);
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
describe('#healthCheck', () => {
|
|
398
|
+
it('should be healthy', (done) => {
|
|
399
|
+
try {
|
|
400
|
+
a.healthCheck(null, (data) => {
|
|
401
|
+
try {
|
|
402
|
+
assert.equal(true, a.healthy);
|
|
403
|
+
saveMockData('system', 'healthcheck', 'default', data);
|
|
404
|
+
done();
|
|
405
|
+
} catch (err) {
|
|
406
|
+
log.error(`Test Failure: ${err}`);
|
|
407
|
+
done(err);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
} catch (error) {
|
|
411
|
+
log.error(`Adapter Exception: ${error}`);
|
|
412
|
+
done(error);
|
|
413
|
+
}
|
|
414
|
+
}).timeout(attemptTimeout);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
/*
|
|
418
|
+
-----------------------------------------------------------------------
|
|
419
|
+
-----------------------------------------------------------------------
|
|
420
|
+
*** All code above this comment will be replaced during a migration ***
|
|
421
|
+
******************* DO NOT REMOVE THIS COMMENT BLOCK ******************
|
|
422
|
+
-----------------------------------------------------------------------
|
|
423
|
+
-----------------------------------------------------------------------
|
|
424
|
+
*/
|
|
425
|
+
|
|
426
|
+
const pipelinesOrganization = 'fakedata';
|
|
427
|
+
const pipelinesProject = 'fakedata';
|
|
428
|
+
const pipelinesApiVersion = 'fakedata';
|
|
429
|
+
let pipelinesPipelineId = 555;
|
|
430
|
+
const pipelinesPipelinesCreateBodyParam = {
|
|
431
|
+
configuration: null,
|
|
432
|
+
folder: 'string',
|
|
433
|
+
name: 'string'
|
|
434
|
+
};
|
|
435
|
+
describe('#pipelinesCreate - errors', () => {
|
|
436
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
437
|
+
try {
|
|
438
|
+
a.pipelinesCreate(pipelinesOrganization, pipelinesPipelinesCreateBodyParam, pipelinesProject, pipelinesApiVersion, (data, error) => {
|
|
439
|
+
try {
|
|
440
|
+
if (stub) {
|
|
441
|
+
runCommonAsserts(data, error);
|
|
442
|
+
assert.equal('string', data.response.folder);
|
|
443
|
+
assert.equal(7, data.response.id);
|
|
444
|
+
assert.equal('string', data.response.name);
|
|
445
|
+
assert.equal(7, data.response.revision);
|
|
446
|
+
} else {
|
|
447
|
+
runCommonAsserts(data, error);
|
|
448
|
+
}
|
|
449
|
+
pipelinesPipelineId = data.response.id;
|
|
450
|
+
saveMockData('Pipelines', 'pipelinesCreate', 'default', data);
|
|
451
|
+
done();
|
|
452
|
+
} catch (err) {
|
|
453
|
+
log.error(`Test Failure: ${err}`);
|
|
454
|
+
done(err);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
} catch (error) {
|
|
458
|
+
log.error(`Adapter Exception: ${error}`);
|
|
459
|
+
done(error);
|
|
460
|
+
}
|
|
461
|
+
}).timeout(attemptTimeout);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('#pipelinesList - errors', () => {
|
|
465
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
466
|
+
try {
|
|
467
|
+
a.pipelinesList(pipelinesOrganization, pipelinesProject, null, null, null, pipelinesApiVersion, (data, error) => {
|
|
468
|
+
try {
|
|
469
|
+
if (stub) {
|
|
470
|
+
runCommonAsserts(data, error);
|
|
471
|
+
assert.equal('object', typeof data.response[0]);
|
|
472
|
+
assert.equal('object', typeof data.response[1]);
|
|
473
|
+
assert.equal('object', typeof data.response[2]);
|
|
474
|
+
assert.equal('object', typeof data.response[3]);
|
|
475
|
+
} else {
|
|
476
|
+
runCommonAsserts(data, error);
|
|
477
|
+
}
|
|
478
|
+
saveMockData('Pipelines', 'pipelinesList', 'default', data);
|
|
479
|
+
done();
|
|
480
|
+
} catch (err) {
|
|
481
|
+
log.error(`Test Failure: ${err}`);
|
|
482
|
+
done(err);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
} catch (error) {
|
|
486
|
+
log.error(`Adapter Exception: ${error}`);
|
|
487
|
+
done(error);
|
|
488
|
+
}
|
|
489
|
+
}).timeout(attemptTimeout);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
describe('#pipelinesGet - errors', () => {
|
|
493
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
494
|
+
try {
|
|
495
|
+
a.pipelinesGet(pipelinesOrganization, pipelinesProject, pipelinesPipelineId, null, pipelinesApiVersion, (data, error) => {
|
|
496
|
+
try {
|
|
497
|
+
if (stub) {
|
|
498
|
+
runCommonAsserts(data, error);
|
|
499
|
+
assert.equal('string', data.response.folder);
|
|
500
|
+
assert.equal(10, data.response.id);
|
|
501
|
+
assert.equal('string', data.response.name);
|
|
502
|
+
assert.equal(6, data.response.revision);
|
|
503
|
+
} else {
|
|
504
|
+
runCommonAsserts(data, error);
|
|
505
|
+
}
|
|
506
|
+
saveMockData('Pipelines', 'pipelinesGet', 'default', data);
|
|
507
|
+
done();
|
|
508
|
+
} catch (err) {
|
|
509
|
+
log.error(`Test Failure: ${err}`);
|
|
510
|
+
done(err);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
} catch (error) {
|
|
514
|
+
log.error(`Adapter Exception: ${error}`);
|
|
515
|
+
done(error);
|
|
516
|
+
}
|
|
517
|
+
}).timeout(attemptTimeout);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
const previewOrganization = 'fakedata';
|
|
521
|
+
const previewProject = 'fakedata';
|
|
522
|
+
const previewPipelineId = 555;
|
|
523
|
+
const previewApiVersion = 'fakedata';
|
|
524
|
+
const previewPreviewPreviewBodyParam = {
|
|
525
|
+
previewRun: false,
|
|
526
|
+
resources: null,
|
|
527
|
+
stagesToSkip: [
|
|
528
|
+
'string'
|
|
529
|
+
],
|
|
530
|
+
templateParameters: {},
|
|
531
|
+
variables: {},
|
|
532
|
+
yamlOverride: 'string'
|
|
533
|
+
};
|
|
534
|
+
describe('#previewPreview - errors', () => {
|
|
535
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
536
|
+
try {
|
|
537
|
+
a.previewPreview(previewOrganization, previewPreviewPreviewBodyParam, previewProject, previewPipelineId, null, previewApiVersion, (data, error) => {
|
|
538
|
+
try {
|
|
539
|
+
if (stub) {
|
|
540
|
+
runCommonAsserts(data, error);
|
|
541
|
+
assert.equal('string', data.response.finalYaml);
|
|
542
|
+
} else {
|
|
543
|
+
runCommonAsserts(data, error);
|
|
544
|
+
}
|
|
545
|
+
saveMockData('Preview', 'previewPreview', 'default', data);
|
|
546
|
+
done();
|
|
547
|
+
} catch (err) {
|
|
548
|
+
log.error(`Test Failure: ${err}`);
|
|
549
|
+
done(err);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
} catch (error) {
|
|
553
|
+
log.error(`Adapter Exception: ${error}`);
|
|
554
|
+
done(error);
|
|
555
|
+
}
|
|
556
|
+
}).timeout(attemptTimeout);
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
const runsOrganization = 'fakedata';
|
|
560
|
+
const runsProject = 'fakedata';
|
|
561
|
+
let runsPipelineId = 555;
|
|
562
|
+
const runsApiVersion = 'fakedata';
|
|
563
|
+
let runsRunId = 555;
|
|
564
|
+
const runsRunsRunPipelineBodyParam = {
|
|
565
|
+
previewRun: false,
|
|
566
|
+
resources: null,
|
|
567
|
+
stagesToSkip: [
|
|
568
|
+
'string'
|
|
569
|
+
],
|
|
570
|
+
templateParameters: {},
|
|
571
|
+
variables: {},
|
|
572
|
+
yamlOverride: 'string'
|
|
573
|
+
};
|
|
574
|
+
describe('#runsRunPipeline - errors', () => {
|
|
575
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
576
|
+
try {
|
|
577
|
+
a.runsRunPipeline(runsOrganization, runsRunsRunPipelineBodyParam, runsProject, runsPipelineId, null, runsApiVersion, (data, error) => {
|
|
578
|
+
try {
|
|
579
|
+
if (stub) {
|
|
580
|
+
runCommonAsserts(data, error);
|
|
581
|
+
assert.equal(2, data.response.id);
|
|
582
|
+
assert.equal('string', data.response.name);
|
|
583
|
+
} else {
|
|
584
|
+
runCommonAsserts(data, error);
|
|
585
|
+
}
|
|
586
|
+
runsPipelineId = data.response.id;
|
|
587
|
+
runsRunId = data.response.id;
|
|
588
|
+
saveMockData('Runs', 'runsRunPipeline', 'default', data);
|
|
589
|
+
done();
|
|
590
|
+
} catch (err) {
|
|
591
|
+
log.error(`Test Failure: ${err}`);
|
|
592
|
+
done(err);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
} catch (error) {
|
|
596
|
+
log.error(`Adapter Exception: ${error}`);
|
|
597
|
+
done(error);
|
|
598
|
+
}
|
|
599
|
+
}).timeout(attemptTimeout);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
describe('#runsList - errors', () => {
|
|
603
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
604
|
+
try {
|
|
605
|
+
a.runsList(runsOrganization, runsProject, runsPipelineId, runsApiVersion, (data, error) => {
|
|
606
|
+
try {
|
|
607
|
+
if (stub) {
|
|
608
|
+
runCommonAsserts(data, error);
|
|
609
|
+
assert.equal('object', typeof data.response[0]);
|
|
610
|
+
assert.equal('object', typeof data.response[1]);
|
|
611
|
+
assert.equal('object', typeof data.response[2]);
|
|
612
|
+
assert.equal('object', typeof data.response[3]);
|
|
613
|
+
} else {
|
|
614
|
+
runCommonAsserts(data, error);
|
|
615
|
+
}
|
|
616
|
+
saveMockData('Runs', 'runsList', 'default', data);
|
|
617
|
+
done();
|
|
618
|
+
} catch (err) {
|
|
619
|
+
log.error(`Test Failure: ${err}`);
|
|
620
|
+
done(err);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
} catch (error) {
|
|
624
|
+
log.error(`Adapter Exception: ${error}`);
|
|
625
|
+
done(error);
|
|
626
|
+
}
|
|
627
|
+
}).timeout(attemptTimeout);
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
describe('#runsGet - errors', () => {
|
|
631
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
632
|
+
try {
|
|
633
|
+
a.runsGet(runsOrganization, runsProject, runsPipelineId, runsRunId, runsApiVersion, (data, error) => {
|
|
634
|
+
try {
|
|
635
|
+
if (stub) {
|
|
636
|
+
runCommonAsserts(data, error);
|
|
637
|
+
assert.equal(5, data.response.id);
|
|
638
|
+
assert.equal('string', data.response.name);
|
|
639
|
+
} else {
|
|
640
|
+
runCommonAsserts(data, error);
|
|
641
|
+
}
|
|
642
|
+
saveMockData('Runs', 'runsGet', 'default', data);
|
|
643
|
+
done();
|
|
644
|
+
} catch (err) {
|
|
645
|
+
log.error(`Test Failure: ${err}`);
|
|
646
|
+
done(err);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
} catch (error) {
|
|
650
|
+
log.error(`Adapter Exception: ${error}`);
|
|
651
|
+
done(error);
|
|
652
|
+
}
|
|
653
|
+
}).timeout(attemptTimeout);
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
const artifactsOrganization = 'fakedata';
|
|
657
|
+
const artifactsProject = 'fakedata';
|
|
658
|
+
const artifactsPipelineId = 555;
|
|
659
|
+
const artifactsRunId = 555;
|
|
660
|
+
const artifactsArtifactName = 'fakedata';
|
|
661
|
+
const artifactsApiVersion = 'fakedata';
|
|
662
|
+
describe('#artifactsGet - errors', () => {
|
|
663
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
664
|
+
try {
|
|
665
|
+
a.artifactsGet(artifactsOrganization, artifactsProject, artifactsPipelineId, artifactsRunId, artifactsArtifactName, null, artifactsApiVersion, (data, error) => {
|
|
666
|
+
try {
|
|
667
|
+
if (stub) {
|
|
668
|
+
runCommonAsserts(data, error);
|
|
669
|
+
assert.equal('string', data.response.name);
|
|
670
|
+
assert.equal('string', data.response.url);
|
|
671
|
+
} else {
|
|
672
|
+
runCommonAsserts(data, error);
|
|
673
|
+
}
|
|
674
|
+
saveMockData('Artifacts', 'artifactsGet', 'default', data);
|
|
675
|
+
done();
|
|
676
|
+
} catch (err) {
|
|
677
|
+
log.error(`Test Failure: ${err}`);
|
|
678
|
+
done(err);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
} catch (error) {
|
|
682
|
+
log.error(`Adapter Exception: ${error}`);
|
|
683
|
+
done(error);
|
|
684
|
+
}
|
|
685
|
+
}).timeout(attemptTimeout);
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
const logsOrganization = 'fakedata';
|
|
689
|
+
const logsProject = 'fakedata';
|
|
690
|
+
const logsPipelineId = 555;
|
|
691
|
+
const logsRunId = 555;
|
|
692
|
+
const logsApiVersion = 'fakedata';
|
|
693
|
+
describe('#logsList - errors', () => {
|
|
694
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
695
|
+
try {
|
|
696
|
+
a.logsList(logsOrganization, logsProject, logsPipelineId, logsRunId, null, logsApiVersion, (data, error) => {
|
|
697
|
+
try {
|
|
698
|
+
if (stub) {
|
|
699
|
+
runCommonAsserts(data, error);
|
|
700
|
+
assert.equal(true, Array.isArray(data.response.logs));
|
|
701
|
+
assert.equal('object', typeof data.response.signedContent);
|
|
702
|
+
assert.equal('string', data.response.url);
|
|
703
|
+
} else {
|
|
704
|
+
runCommonAsserts(data, error);
|
|
705
|
+
}
|
|
706
|
+
saveMockData('Logs', 'logsList', 'default', data);
|
|
707
|
+
done();
|
|
708
|
+
} catch (err) {
|
|
709
|
+
log.error(`Test Failure: ${err}`);
|
|
710
|
+
done(err);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
} catch (error) {
|
|
714
|
+
log.error(`Adapter Exception: ${error}`);
|
|
715
|
+
done(error);
|
|
716
|
+
}
|
|
717
|
+
}).timeout(attemptTimeout);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
const logsLogId = 555;
|
|
721
|
+
describe('#logsGet - errors', () => {
|
|
722
|
+
it('should work if integrated or standalone with mockdata', (done) => {
|
|
723
|
+
try {
|
|
724
|
+
a.logsGet(logsOrganization, logsProject, logsPipelineId, logsRunId, logsLogId, null, logsApiVersion, (data, error) => {
|
|
725
|
+
try {
|
|
726
|
+
if (stub) {
|
|
727
|
+
runCommonAsserts(data, error);
|
|
728
|
+
assert.equal('string', data.response.createdOn);
|
|
729
|
+
assert.equal(4, data.response.id);
|
|
730
|
+
assert.equal('string', data.response.lastChangedOn);
|
|
731
|
+
assert.equal(5, data.response.lineCount);
|
|
732
|
+
assert.equal('object', typeof data.response.signedContent);
|
|
733
|
+
assert.equal('string', data.response.url);
|
|
734
|
+
} else {
|
|
735
|
+
runCommonAsserts(data, error);
|
|
736
|
+
}
|
|
737
|
+
saveMockData('Logs', 'logsGet', 'default', data);
|
|
738
|
+
done();
|
|
739
|
+
} catch (err) {
|
|
740
|
+
log.error(`Test Failure: ${err}`);
|
|
741
|
+
done(err);
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
} catch (error) {
|
|
745
|
+
log.error(`Adapter Exception: ${error}`);
|
|
746
|
+
done(error);
|
|
747
|
+
}
|
|
748
|
+
}).timeout(attemptTimeout);
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
});
|