@adobe/aio-lib-cloudmanager
Advanced tools
Comparing version 0.3.5 to 1.0.0
@@ -10,4 +10,5 @@ { | ||
"functions": "always-multiline" | ||
}] | ||
}], | ||
"aio-lib-cloudmanager-error-codes": "error" | ||
} | ||
} |
{ | ||
"jest.pathToConfig": "test/jest.config.js", | ||
"editor.tabSize": 2 | ||
"editor.tabSize": 2, | ||
"eslint.options" : { | ||
"rulePaths" : "eslint_rules" | ||
} | ||
} |
# Changelog | ||
# [1.0.0](https://github.com/adobe/aio-lib-cloudmanager/compare/0.3.5...1.0.0) (2021-06-25) | ||
### Features | ||
* require node 12 as minimum version. fixes [#163](https://github.com/adobe/aio-lib-cloudmanager/issues/163) ([#164](https://github.com/adobe/aio-lib-cloudmanager/issues/164)) ([7a7aa46](https://github.com/adobe/aio-lib-cloudmanager/commit/7a7aa46de54a67d06b79fff031551795bdbc8adc)) | ||
### BREAKING CHANGES | ||
* Support for TLS 1.0 and 1.1 is being retired by Adobe in mid-July. | ||
## [0.3.5](https://github.com/adobe/aio-lib-cloudmanager/compare/0.3.4...0.3.5) (2021-04-30) | ||
@@ -4,0 +16,0 @@ |
{ | ||
"name": "@adobe/aio-lib-cloudmanager", | ||
"version": "0.3.5", | ||
"version": "1.0.0", | ||
"description": "Adobe I/O Cloud Manager Library", | ||
@@ -15,4 +15,4 @@ "repository": { | ||
"jscpd": "jscpd --pattern 'src/**/*.js'", | ||
"lint": "eslint src test e2e", | ||
"lint-fix": "eslint src test e2e --fix", | ||
"lint": "eslint src test e2e --rulesdir eslint_rules", | ||
"lint-fix": "eslint src test e2e --fix --rulesdir eslint_rules", | ||
"unit-tests": "jest --config test/jest.config.js --maxWorkers=2", | ||
@@ -40,15 +40,15 @@ "e2e": "jest --config e2e/jest.config.js", | ||
"@adobe/eslint-config-aio-lib-config": "1.2.1", | ||
"@commitlint/cli": "12.1.1", | ||
"@commitlint/config-conventional": "12.1.1", | ||
"@commitlint/cli": "12.1.4", | ||
"@commitlint/config-conventional": "12.1.4", | ||
"@semantic-release/changelog": "5.0.1", | ||
"@semantic-release/git": "9.0.0", | ||
"codecov": "3.8.1", | ||
"codecov": "3.8.2", | ||
"del": "6.0.0", | ||
"dotenv": "8.2.0", | ||
"dotenv": "10.0.0", | ||
"eol": "0.9.1", | ||
"eslint": "7.25.0", | ||
"eslint-config-standard": "16.0.2", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint": "7.29.0", | ||
"eslint-config-standard": "16.0.3", | ||
"eslint-plugin-import": "2.23.4", | ||
"eslint-plugin-jest": "24.3.6", | ||
"eslint-plugin-jsdoc": "33.0.0", | ||
"eslint-plugin-jsdoc": "33.3.0", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -59,11 +59,11 @@ "eslint-plugin-promise": "5.1.0", | ||
"husky": "5.2.0", | ||
"jest": "26.6.3", | ||
"jest-junit": "12.0.0", | ||
"jest": "27.0.5", | ||
"jest-junit": "12.2.0", | ||
"js-yaml": "4.1.0", | ||
"jscpd": "3.3.25", | ||
"jsdoc": "3.6.6", | ||
"jscpd": "3.3.26", | ||
"jsdoc": "3.6.7", | ||
"jsdoc-to-markdown": "7.0.1", | ||
"pinst": "2.1.6", | ||
"semantic-release": "17.4.2", | ||
"sinon": "10.0.0", | ||
"semantic-release": "17.4.4", | ||
"sinon": "11.1.1", | ||
"stdout-stderr": "0.1.13", | ||
@@ -73,3 +73,3 @@ "tsd-jsdoc": "2.5.0" | ||
"engines": { | ||
"node": ">=10.22.0" | ||
"node": ">=12" | ||
}, | ||
@@ -76,0 +76,0 @@ "commitlint": { |
@@ -800,5 +800,6 @@ <!-- | ||
| name | <code>string</code> | Name of the variable. Of a-z, A-Z, _ and 0-9 Cannot begin with a number. | | ||
| value | <code>string</code> | Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. | | ||
| value | <code>string</code> | Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. An empty value causes a variable to be deleted. | | ||
| type | <code>string</code> | Type of the variable. Default `string` if missing. `secretString` variables are encrypted at rest. The type of a variable be changed after creation; the variable must be deleted and recreated. | | ||
| service | <code>string</code> | Service of the variable. When not provided, the variable applies to all services. Currently only the values 'author' and 'publish' are supported. Note - this value is case-sensitive. | | ||
| service | <code>string</code> | Service of the variable. When not provided, the variable applies to all services. Currently the values 'author', 'publish', and 'preview' are supported. Note - this value is case-sensitive. | | ||
| status | <code>string</code> | Status of the variable | | ||
@@ -805,0 +806,0 @@ <a name="LogOptionRepresentation"></a> |
@@ -18,4 +18,8 @@ { | ||
"automerge": true | ||
}, | ||
{ | ||
"packageNames": ["eslint-plugin-jsdoc"], | ||
"allowedVersions": "<33.3.0" | ||
} | ||
] | ||
} |
@@ -43,3 +43,3 @@ /* | ||
gates = execution.embeddedArray('stepStates').filter(stepState => stepState.action === 'loadTest' || stepState.action === 'assetsTest' || stepState.action === 'reportPerformanceTest') | ||
if (gates) { | ||
if (gates && gates.length > 0) { | ||
return gates[gates.length - 1] | ||
@@ -46,0 +46,0 @@ } else { |
@@ -661,3 +661,3 @@ /* | ||
throw new codes.ERROR_LOG_DOWNLOAD({ | ||
messageValues: [logRes.url, outputPath, logRes.status, logRes.statusText], | ||
messageValues: [redirectUrl, outputPath, logRes.status, logRes.statusText], | ||
}) | ||
@@ -669,3 +669,3 @@ } | ||
if (error.errno !== -5 || error.code !== 'Z_BUF_ERROR') { | ||
throw new codes.ERROR_LOG_UNZIP({ messageValues: [logRes.url, outputPath] }) | ||
throw new codes.ERROR_LOG_UNZIP({ messageValues: [redirectUrl, outputPath] }) | ||
} | ||
@@ -753,2 +753,9 @@ }, | ||
_pipeBody (body, writeStream) { | ||
return new Promise((resolve) => { | ||
body.pipe(writeStream, { end: false }) | ||
body.on('end', () => resolve({})) | ||
}) | ||
} | ||
async _getLiveStream (programId, environment, service, name, tailingSasUrl, currentStartLimit, writeStream) { | ||
@@ -764,3 +771,3 @@ for (;;) { | ||
const contentLength = res.headers.get('content-length') | ||
res.body.pipe(writeStream) | ||
await this._pipeBody(res.body, writeStream) | ||
currentStartLimit = parseInt(currentStartLimit) + parseInt(contentLength) | ||
@@ -773,3 +780,3 @@ } else if (res.status === 416) { | ||
*/ | ||
if (isWithinFiveMinutesOfUTCMidnight(new Date())) { | ||
if (isWithinFiveMinutesOfUTCMidnight(new Date(Date.now()))) { | ||
tailingSasUrl = await this._getTailingSasUrl(programId, environment, service, name) | ||
@@ -776,0 +783,0 @@ const startLimit = await this._getLogFileSizeInitialSize(tailingSasUrl) |
@@ -138,5 +138,6 @@ /* | ||
* @property {string} name - Name of the variable. Of a-z, A-Z, _ and 0-9 Cannot begin with a number. | ||
* @property {string} value - Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. | ||
* @property {string} value - Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. An empty value causes a variable to be deleted. | ||
* @property {string} type - Type of the variable. Default `string` if missing. `secretString` variables are encrypted at rest. The type of a variable be changed after creation; the variable must be deleted and recreated. | ||
* @property {string} service - Service of the variable. When not provided, the variable applies to all services. Currently only the values 'author' and 'publish' are supported. Note - this value is case-sensitive. | ||
* @property {string} service - Service of the variable. When not provided, the variable applies to all services. Currently the values 'author', 'publish', and 'preview' are supported. Note - this value is case-sensitive. | ||
* @property {string} status - Status of the variable | ||
*/ | ||
@@ -143,0 +144,0 @@ |
@@ -17,2 +17,6 @@ | ||
beforeEach(() => { | ||
fetchMock.resetProgram4EmbeddedEnvironments() | ||
}) | ||
test('listEnvironments - failure', async () => { | ||
@@ -40,2 +44,15 @@ expect.assertions(2) | ||
test('listEnvironments - no embedded list', async () => { | ||
fetchMock.setProgram4EmbeddedEnvironmentsToEmptyObject() | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.listEnvironments('4') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_FIND_ENVIRONMENTS({ messageValues: '4' }), | ||
) | ||
}) | ||
test('listEnvironments - success', async () => { | ||
@@ -42,0 +59,0 @@ expect.assertions(2) |
@@ -92,3 +92,3 @@ /* | ||
test('getQualityGateResults - failure', async () => { | ||
test('getQualityGateResults - execution not found', async () => { | ||
expect.assertions(2) | ||
@@ -105,2 +105,14 @@ | ||
test('getQualityGateResults - metrics not found', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.getQualityGateResults('5', '7', '1001', 'reportPerformanceTest') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_GET_METRICS({ messageValues: 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1001/phase/4597/step/8495/metrics (404 Not Found)' }), | ||
) | ||
}) | ||
test('getQualityGateResults - success', async () => { | ||
@@ -193,2 +205,14 @@ expect.assertions(3) | ||
test('cancelCurrentExecution - managed pipeline', async () => { | ||
fetchMock.setPipeline7Execution('1013') | ||
expect.assertions(3) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.cancelCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toEqual({}) | ||
await expect(fetchMock.called('cancel-1013')).toBe(true) | ||
}) | ||
test('cancelCurrentExecution - deploy waiting', async () => { | ||
@@ -221,2 +245,30 @@ fetchMock.setPipeline7Execution('1008') | ||
test('cancelCurrentExecution - all finished (error state)', async () => { | ||
fetchMock.setPipeline7Execution('1012') | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.cancelCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_FIND_CURRENT_STEP({ messageValues: '7' }), | ||
) | ||
}) | ||
test('cancelCurrentExecution - approval failed', async () => { | ||
fetchMock.setPipeline7Execution('1014') | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.cancelCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_CANCEL_EXECUTION({ messageValues: 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1014/phase/8567/step/15490/cancel (500 Internal Server Error)' }), | ||
) | ||
}) | ||
test('advanceCurrentExecution - bad pipeline', async () => { | ||
@@ -288,2 +340,55 @@ expect.assertions(2) | ||
test('advanceCurrentExecution - managed pipeline', async () => { | ||
fetchMock.setPipeline7Execution('1013') | ||
expect.assertions(3) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.advanceCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toEqual({}) | ||
await expect(fetchMock.called('advance-1013')).toBe(true) | ||
}) | ||
test('advanceCurrentExecution - no advance link (edge case)', async () => { | ||
fetchMock.setPipeline7Execution('1015') | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.advanceCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_FIND_ADVANCE_LINK({ messageValues: 'approval' }), | ||
) | ||
}) | ||
test('advanceCurrentExecution - advance failed', async () => { | ||
fetchMock.setPipeline7Execution('1016') | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.advanceCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_ADVANCE_EXECUTION({ messageValues: 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1016/phase/8567/step/15490/advance (500 Internal Server Error)' }), | ||
) | ||
}) | ||
test('advanceCurrentExecution - deploy waiting', async () => { | ||
fetchMock.setPipeline7Execution('1008') | ||
expect.assertions(3) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.advanceCurrentExecution('5', '7') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toEqual({}) | ||
await expect(fetchMock.called('advance-1008')).toBe(true) | ||
}) | ||
test('getExecutionStepLog - failure', async () => { | ||
@@ -290,0 +395,0 @@ expect.assertions(2) |
@@ -12,4 +12,11 @@ /* | ||
const { isWithinFiveMinutesOfUTCMidnight } = require('../src/helpers') | ||
const halfred = require('halfred') | ||
const { isWithinFiveMinutesOfUTCMidnight, sleep, findStepState } = require('../src/helpers') | ||
const execution1007 = halfred.parse(require('./jest/data/execution1007.json')) | ||
const executionWithoutPerformanceTesting = halfred.parse(require('./jest/data/execution-no-performance.json')) | ||
afterEach(() => { | ||
jest.useRealTimers() | ||
}) | ||
test('isWithinFiveMinutesOfUTCMidnight', async () => { | ||
@@ -25,1 +32,30 @@ const utcDate1 = new Date(Date.UTC(2019, 9, 12, 23, 55, 14)) | ||
}) | ||
test('sleep', async () => { | ||
jest.useFakeTimers('legacy') | ||
const result = sleep(500) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
expect(setTimeout).toHaveBeenCalledTimes(1) | ||
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 500) | ||
jest.runAllTimers() | ||
await expect(result).resolves.toBeUndefined() | ||
}) | ||
test('findStepState -- security', () => { | ||
const result = findStepState(execution1007, 'security') | ||
expect(result).toBeTruthy() | ||
}) | ||
test('findStepState -- performance', () => { | ||
const result = findStepState(execution1007, 'performance') | ||
expect(result).toBeTruthy() | ||
}) | ||
test('findStepState -- performance not found', () => { | ||
const result = findStepState(executionWithoutPerformanceTesting, 'performance') | ||
expect(result).toBeUndefined() | ||
}) |
@@ -32,2 +32,3 @@ /* | ||
'<rootDir>/test/jest/jest.setup.js', | ||
'<rootDir>/test/jest/jest.zlib.setup.js', | ||
// remove any of the lines below if you don't want to use any of the mocks | ||
@@ -34,0 +35,0 @@ '<rootDir>/test/jest/jest.fetch.setup.js', |
@@ -228,2 +228,6 @@ { | ||
"templated": false | ||
}, | ||
"http://ns.adobe.com/adobecloud/rel/pipeline/logs": { | ||
"href": "/api/program/5/pipeline/7/execution/1001/phase/4598/step/8500/logs", | ||
"templated": false | ||
} | ||
@@ -251,9 +255,3 @@ }, | ||
}, | ||
"status": "NOT_STARTED", | ||
"_links": { | ||
"http://ns.adobe.com/adobecloud/rel/pipeline/logs": { | ||
"href": "/api/program/5/pipeline/7/execution/1001/phase/4598/step/8500/logs", | ||
"templated": false | ||
} | ||
} | ||
"status": "NOT_STARTED" | ||
} | ||
@@ -260,0 +258,0 @@ ] |
@@ -139,154 +139,278 @@ /* | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environments', { | ||
_embedded: { | ||
environments: [ | ||
{ | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs': { | ||
href: '/api/program/4/environment/1/logs?service={service}&name={name}&days={days}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/1/variables', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/developerConsole': { | ||
href: 'https://github.com/adobe/aio-cli-plugin-cloudmanager', | ||
}, | ||
}, | ||
id: '1', | ||
programId: '4', | ||
name: 'TestProgram_prod', | ||
description: 'description for TestProgram_prod', | ||
type: 'prod', | ||
availableLogOptions: [ | ||
let useEmptyEmbeddedObjectForProgram4Environments = false | ||
fetchMock.resetProgram4EmbeddedEnvironments = () => { | ||
useEmptyEmbeddedObjectForProgram4Environments = false | ||
} | ||
fetchMock.setProgram4EmbeddedEnvironmentsToEmptyObject = () => { | ||
useEmptyEmbeddedObjectForProgram4Environments = true | ||
} | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environments', () => { | ||
if (useEmptyEmbeddedObjectForProgram4Environments) { | ||
return { | ||
_embedded: {}, | ||
} | ||
} else { | ||
return { | ||
_embedded: { | ||
environments: [ | ||
{ | ||
service: 'author', | ||
name: 'aemerror', | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs': { | ||
href: '/api/program/4/environment/1/logs?service={service}&name={name}&days={days}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/1/variables', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/developerConsole': { | ||
href: 'https://github.com/adobe/aio-cli-plugin-cloudmanager', | ||
}, | ||
}, | ||
id: '1', | ||
programId: '4', | ||
name: 'TestProgram_prod', | ||
description: 'description for TestProgram_prod', | ||
type: 'prod', | ||
availableLogOptions: [ | ||
{ | ||
service: 'author', | ||
name: 'aemerror', | ||
}, | ||
{ | ||
service: 'author', | ||
name: 'aemrequest', | ||
}, | ||
{ | ||
service: 'author', | ||
name: 'aemaccess', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemerror', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemrequest', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemaccess', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'httpdaccess', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'httpderror', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'aemdispatcher', | ||
}, | ||
], | ||
}, | ||
{ | ||
service: 'author', | ||
name: 'aemrequest', | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/2', | ||
templated: false, | ||
}, | ||
}, | ||
id: '2', | ||
programId: '4', | ||
name: 'TestProgram_stage', | ||
description: 'description for TestProgram_stage', | ||
type: 'stage', | ||
availableLogs: [], | ||
namespace: 'ns', | ||
cluster: 'cs', | ||
}, | ||
{ | ||
service: 'author', | ||
name: 'aemaccess', | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/3', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/3/variables', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs': { | ||
href: '/api/program/4/environment/3/logs?service={service}&name={name}&days={days}', | ||
templated: true, | ||
}, | ||
}, | ||
id: '3', | ||
programId: '4', | ||
name: 'TestProgram_dev', | ||
description: 'description for TestProgram_dev', | ||
type: 'dev', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemerror', | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/10', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/10/variables', | ||
}, | ||
}, | ||
id: '10', | ||
programId: '4', | ||
name: 'TestProgram_dev2', | ||
description: 'description for TestProgram_dev2', | ||
type: 'dev', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemrequest', | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/11', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/11/variables', | ||
}, | ||
}, | ||
id: '11', | ||
programId: '4', | ||
name: 'TestProgram_dev3', | ||
description: 'description for TestProgram_dev3', | ||
type: 'dev', | ||
}, | ||
{ | ||
service: 'publish', | ||
name: 'aemaccess', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'httpdaccess', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'httpderror', | ||
}, | ||
{ | ||
service: 'dispatcher', | ||
name: 'aemdispatcher', | ||
}, | ||
], | ||
}, | ||
_totalNumberOfItems: 3, | ||
} | ||
} | ||
}, | ||
) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/4/environment/3', 'DELETE', { | ||
status: 400, | ||
headers: { | ||
'content-type': 'application/problem+json', | ||
}, | ||
body: { | ||
type: 'http://ns.adobe.com/adobecloud/random-exception-with-no-title', | ||
errors: [ | ||
'some error', | ||
], | ||
}, | ||
}) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/4/environment/11', 'DELETE', 204) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=author&name=aemerror&days=1', { | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1/logs?service=author&type=aemerror&days=1', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/program': { | ||
href: '/api/program/4', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/environment': { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
}, | ||
service: ['author'], | ||
name: ['aemerror'], | ||
days: 1, | ||
_embedded: { | ||
downloads: [ | ||
{ | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/2', | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=author&name=aemerror&date=2019-09-8', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs/tail': { | ||
href: 'https://filestore/logs/author_aemerror_2019-09-8.log', | ||
}, | ||
}, | ||
id: '2', | ||
programId: '4', | ||
name: 'TestProgram_stage', | ||
description: 'description for TestProgram_stage', | ||
type: 'stage', | ||
availableLogs: [], | ||
namespace: 'ns', | ||
cluster: 'cs', | ||
service: 'author', | ||
name: 'aemerror', | ||
date: '2019-09-8', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
{ | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/3', | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=author&name=aemerror&date=2019-09-7', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/3/variables', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs': { | ||
href: '/api/program/4/environment/3/logs?service={service}&name={name}&days={days}', | ||
templated: true, | ||
}, | ||
}, | ||
id: '3', | ||
programId: '4', | ||
name: 'TestProgram_dev', | ||
description: 'description for TestProgram_dev', | ||
type: 'dev', | ||
service: 'author', | ||
name: 'aemerror', | ||
date: '2019-09-7', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
], | ||
}, | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=publish&name=aemerror&days=1', { | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1/logs?service=publish&type=aemerror&days=1', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/program': { | ||
href: '/api/program/4', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/environment': { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
}, | ||
service: ['author'], | ||
name: ['aemerror'], | ||
days: 1, | ||
_embedded: { | ||
downloads: [ | ||
{ | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/10', | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=publish&name=aemerror&date=2019-09-8', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/10/variables', | ||
'http://ns.adobe.com/adobecloud/rel/logs/tail': { | ||
href: 'https://filestore/logs/publish_aemerror_2019-09-8.log', | ||
}, | ||
}, | ||
id: '10', | ||
programId: '4', | ||
name: 'TestProgram_dev2', | ||
description: 'description for TestProgram_dev2', | ||
type: 'dev', | ||
service: 'publish', | ||
name: 'aemerror', | ||
date: '2019-09-8', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
{ | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/11', | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=publish&name=aemerror&date=2019-09-7', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/4/environment/11/variables', | ||
}, | ||
}, | ||
id: '11', | ||
programId: '4', | ||
name: 'TestProgram_dev3', | ||
description: 'description for TestProgram_dev3', | ||
type: 'dev', | ||
service: 'publish', | ||
name: 'aemerror', | ||
date: '2019-09-7', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
], | ||
}, | ||
_totalNumberOfItems: 3, | ||
}) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/4/environment/3', 'DELETE', { | ||
status: 400, | ||
headers: { | ||
'content-type': 'application/problem+json', | ||
}, | ||
body: { | ||
type: 'http://ns.adobe.com/adobecloud/random-exception-with-no-title', | ||
errors: [ | ||
'some error', | ||
], | ||
}, | ||
}) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/4/environment/11', 'DELETE', 204) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=author&name=aemerror&days=1', { | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=preview&name=aemerror&days=1', { | ||
_links: { | ||
@@ -305,3 +429,3 @@ self: { | ||
}, | ||
service: ['author'], | ||
service: ['preview'], | ||
name: ['aemerror'], | ||
@@ -313,6 +437,9 @@ days: 1, | ||
_links: { | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=author&name=aemerror&date=2019-09-8', | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': [{ | ||
href: '/api/program/4/environment/1/logs/download?service=preview&name=aemerror&date=2019-09-8&index=1', | ||
templated: false, | ||
}, | ||
}, { | ||
href: '/api/program/4/environment/1/logs/download?service=preview&name=aemerror&date=2019-09-8&index=2', | ||
templated: false, | ||
}], | ||
'http://ns.adobe.com/adobecloud/rel/logs/tail': { | ||
@@ -345,2 +472,53 @@ href: 'https://filestore/logs/author_aemerror_2019-09-8.log', | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=preview&name=aemaccess&days=1', { | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1/logs?service=preview&type=aemaccess&days=1', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/program': { | ||
href: '/api/program/4', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/environment': { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
}, | ||
service: ['preview'], | ||
name: ['aemaccess'], | ||
days: 1, | ||
_embedded: { | ||
downloads: [ | ||
{ | ||
service: 'preview', | ||
name: 'aemaccess', | ||
date: '2019-09-8', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
], | ||
}, | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=author&name=aemaccess&days=1', { | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1/logs?service=author&type=aemaccess&days=1', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/program': { | ||
href: '/api/program/4', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/environment': { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
}, | ||
service: ['author'], | ||
name: ['aemaccess'], | ||
days: 1, | ||
_embedded: { | ||
}, | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs/download?service=author&name=aemerror&date=2019-09-8', { | ||
@@ -352,2 +530,8 @@ redirect: 'https://filestore/logs/author_aemerror_2019-09-8.log.gz', | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs/download?service=preview&name=aemerror&date=2019-09-8&index=1', { | ||
redirect: 'https://filestore/logs/author_aemerror_2019-09-7.log.gz', | ||
}) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs/download?service=preview&name=aemerror&date=2019-09-8&index=2', { | ||
redirect: 'https://filestore/logs/author_aemerror_2019-09-7.log.gz', | ||
}) | ||
@@ -524,2 +708,194 @@ fetchMock.mock('https://filestore/logs/author_aemerror_2019-09-8.log.gz', () => { | ||
fetchMock.mock({ url: 'https://filestore/logs/author_aemerror_2019-09-8.log', method: 'HEAD', name: 'tail-log-head' }, { | ||
headers: { | ||
'content-length': '500', | ||
}, | ||
}) | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemerror_2019-09-8.log', | ||
headers: { range: 'bytes=500-' }, | ||
name: 'tail-log-first', | ||
}, () => { | ||
const logResponse = new Readable() | ||
logResponse.push('some log message\n') | ||
logResponse.push(null) | ||
return { | ||
status: 206, | ||
headers: { | ||
'content-length': '1000', | ||
}, | ||
body: logResponse, | ||
} | ||
}, { sendAsJson: false }) | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemerror_2019-09-8.log', | ||
headers: { range: 'bytes=1500-' }, | ||
name: 'tail-log-second', | ||
}, () => { | ||
const logResponse = new Readable() | ||
logResponse.push('some second log message\n') | ||
logResponse.push(null) | ||
return { | ||
status: 206, | ||
headers: { | ||
'content-length': '1000', | ||
}, | ||
body: logResponse, | ||
} | ||
}, { sendAsJson: false }) | ||
let tailLogAuthorAemerrorThirdCalled = false | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemerror_2019-09-8.log', | ||
headers: { range: 'bytes=2500-' }, | ||
name: 'tail-log-third', | ||
}, () => { | ||
if (!tailLogAuthorAemerrorThirdCalled) { | ||
tailLogAuthorAemerrorThirdCalled = true | ||
return { | ||
status: 416, | ||
} | ||
} else { | ||
const logResponse = new Readable() | ||
logResponse.push('this will fail\n') | ||
logResponse.push(null) | ||
return { | ||
status: 200, | ||
headers: { | ||
'content-length': '1000', | ||
}, | ||
body: logResponse, | ||
} | ||
} | ||
}, { sendAsJson: false }) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/logs?service=author&name=aemrequest&days=1', { | ||
_links: { | ||
self: { | ||
href: '/api/program/4/environment/1/logs?service=author&type=aemrequest&days=1', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/program': { | ||
href: '/api/program/4', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/environment': { | ||
href: '/api/program/4/environment/1', | ||
templated: false, | ||
}, | ||
}, | ||
service: ['author'], | ||
name: ['aemrequest'], | ||
days: 1, | ||
_embedded: { | ||
downloads: [ | ||
{ | ||
_links: { | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=author&name=aemrequest&date=2019-09-8', | ||
templated: false, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/logs/tail': { | ||
href: 'https://filestore/logs/author_aemrequest_2019-09-8.log', | ||
}, | ||
}, | ||
service: 'author', | ||
name: 'aemrequest', | ||
date: '2019-09-8', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
{ | ||
_links: { | ||
'http://ns.adobe.com/adobecloud/rel/logs/download': { | ||
href: '/api/program/4/environment/1/logs/download?service=author&name=aemrequest&date=2019-09-7', | ||
templated: false, | ||
}, | ||
}, | ||
service: 'author', | ||
name: 'aemrequest', | ||
date: '2019-09-7', | ||
programId: 4, | ||
environmentId: 1, | ||
}, | ||
], | ||
}, | ||
}) | ||
let tailLogRequestHeadCallCount = 0 | ||
fetchMock.mock({ url: 'https://filestore/logs/author_aemrequest_2019-09-8.log', method: 'HEAD', name: 'tail-log-aemrequest-head' }, () => { | ||
tailLogRequestHeadCallCount++ | ||
return { | ||
headers: { | ||
'content-length': tailLogRequestHeadCallCount === 2 ? '3500' : '500', | ||
}, | ||
} | ||
}) | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemrequest_2019-09-8.log', | ||
headers: { range: 'bytes=500-' }, | ||
name: 'tail-log-aemrequest-first', | ||
}, () => { | ||
const logResponse = new Readable() | ||
logResponse.push('some request log message\n') | ||
logResponse.push(null) | ||
return { | ||
status: 206, | ||
headers: { | ||
'content-length': '200', | ||
}, | ||
body: logResponse, | ||
} | ||
}, { sendAsJson: false }) | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemrequest_2019-09-8.log', | ||
headers: { range: 'bytes=700-' }, | ||
name: 'tail-log-aemrequest-second', | ||
}, () => { | ||
const logResponse = new Readable() | ||
logResponse.push('some second request log message\n') | ||
logResponse.push(null) | ||
return { | ||
status: 206, | ||
headers: { | ||
'content-length': '1000', | ||
}, | ||
body: logResponse, | ||
} | ||
}, { sendAsJson: false }) | ||
let tailLogAemrequestThirdCallCount = 0 | ||
fetchMock.mock({ | ||
url: 'https://filestore/logs/author_aemrequest_2019-09-8.log', | ||
headers: { range: 'bytes=1700-' }, | ||
name: 'tail-log-aemrequest-third', | ||
}, () => { | ||
tailLogAemrequestThirdCallCount++ | ||
if (tailLogAemrequestThirdCallCount < 3) { | ||
return { | ||
status: 416, | ||
} | ||
} else { | ||
const logResponse = new Readable() | ||
logResponse.push('this will fail\n') | ||
logResponse.push(null) | ||
return { | ||
status: 200, | ||
headers: { | ||
'content-length': '1000', | ||
}, | ||
body: logResponse, | ||
} | ||
} | ||
}, { sendAsJson: false }) | ||
mockResponseWithMethod('https://filestore/logs/publish_aemerror_2019-09-8.log', 'HEAD', { | ||
headers: { | ||
'content-length': 500, | ||
}, | ||
}) | ||
mockResponseWithMethod('https://filestore/logs/publish_aemerror_2019-09-8.log', 'GET', 404) | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/3/logs?service=author&name=aemerror&days=1', 404) | ||
@@ -730,78 +1106,128 @@ fetchMock.mock('https://cloudmanager.adobe.io/api/program/4/environment/1/variables', { | ||
} | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/5/pipelines', { | ||
_embedded: { | ||
pipelines: [ | ||
pipeline5, | ||
{ | ||
id: '6', | ||
name: 'test2', | ||
status: 'BUSY', | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/6', | ||
let useEmptyEmbeddedObjectForProgram5Pipelines = false | ||
fetchMock.resetProgram5EmbeddedPipelines = () => { | ||
useEmptyEmbeddedObjectForProgram5Pipelines = false | ||
} | ||
fetchMock.setProgram5EmbeddedPipelinesToEmptyObject = () => { | ||
useEmptyEmbeddedObjectForProgram5Pipelines = true | ||
} | ||
fetchMock.mock('https://cloudmanager.adobe.io/api/program/5/pipelines', () => { | ||
if (useEmptyEmbeddedObjectForProgram5Pipelines) { | ||
return { | ||
_embedded: {}, | ||
} | ||
} else { | ||
return { | ||
_embedded: { | ||
pipelines: [ | ||
pipeline5, | ||
{ | ||
id: '6', | ||
name: 'test2', | ||
status: 'BUSY', | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/6', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/6/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/6/execution/{executionId}', | ||
templated: true, | ||
}, | ||
}, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/6/execution', | ||
{ | ||
id: '7', | ||
name: 'test3', | ||
status: 'BUSY', | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/7', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/7/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/7/execution/{executionId}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/5/pipeline/7/variables', | ||
}, | ||
}, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/6/execution/{executionId}', | ||
templated: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '7', | ||
name: 'test3', | ||
status: 'BUSY', | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/7', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/7/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/7/execution/{executionId}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/5/pipeline/7/variables', | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: '8', | ||
name: 'test4', | ||
status: 'IDLE', | ||
phases: [ | ||
{ | ||
name: 'VALIDATE', | ||
type: 'VALIDATE', | ||
id: '8', | ||
name: 'test4', | ||
status: 'IDLE', | ||
phases: [ | ||
{ | ||
name: 'VALIDATE', | ||
type: 'VALIDATE', | ||
}, | ||
{ | ||
name: 'BUILD_1', | ||
type: 'BUILD', | ||
repositoryId: '1', | ||
branch: 'yellow', | ||
}, | ||
], | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/8', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/8/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/8/execution/{executionId}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/5/pipeline/8/variables', | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'BUILD_1', | ||
type: 'BUILD', | ||
repositoryId: '1', | ||
branch: 'yellow', | ||
id: '9', | ||
name: 'test5', | ||
status: 'IDLE', | ||
phases: [ | ||
{ | ||
name: 'VALIDATE', | ||
type: 'VALIDATE', | ||
}, | ||
{ | ||
name: 'DEPLOY_1', | ||
type: 'DEPLOY', | ||
}, | ||
], | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/8', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/8/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/8/execution/{executionId}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/5/pipeline/8/variables', | ||
}, | ||
}, | ||
}, | ||
], | ||
_links: { | ||
self: { | ||
href: '/api/program/5/pipeline/8', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution': { | ||
href: '/api/program/5/pipeline/8/execution', | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/execution/id': { | ||
href: '/api/program/5/pipeline/8/execution/{executionId}', | ||
templated: true, | ||
}, | ||
'http://ns.adobe.com/adobecloud/rel/variables': { | ||
href: '/api/program/5/pipeline/8/variables', | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
} | ||
} | ||
}) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/5/execution', 'GET', 404) | ||
@@ -833,2 +1259,15 @@ mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/5/execution', 'PUT', { | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/8', 'PATCH', 405) | ||
mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/8', 'DELETE', { | ||
status: 400, | ||
headers: { | ||
'content-type': 'application/problem+json', | ||
}, | ||
body: { | ||
type: 'http://ns.adobe.com/adobecloud/random-exception-with-a-message', | ||
title: 'Test Exception', | ||
errors: { | ||
something: { message: 'some error message' }, | ||
}, | ||
}, | ||
}) | ||
@@ -993,2 +1432,7 @@ mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/6/execution', 'GET', require('./data/execution1000.json')) | ||
1011: require('./data/execution1011.json'), | ||
1012: require('./data/execution1012.json'), | ||
1013: require('./data/execution1013.json'), | ||
1014: require('./data/execution1014.json'), | ||
1015: require('./data/execution1015.json'), | ||
1016: require('./data/execution1016.json'), | ||
} | ||
@@ -1031,2 +1475,27 @@ mockResponseWithMethod('https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution', 'GET', () => pipeline7Executions[executionForPipeline7]) | ||
}) | ||
fetchMock.mock((url, opts) => url === 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1007/phase/8567/step/15492/advance' && | ||
opts.method === 'PUT' && opts.body === JSON.stringify({ resume: true }), | ||
202, { | ||
name: 'advance-1008', | ||
}) | ||
fetchMock.mock((url, opts) => url === 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1013/phase/8567/step/15492/cancel' && | ||
opts.method === 'PUT' && opts.body === JSON.stringify({ start: false }), | ||
202, { | ||
name: 'cancel-1013', | ||
}) | ||
fetchMock.mock((url, opts) => url === 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1013/phase/8567/step/15492/advance' && | ||
opts.method === 'PUT' && opts.body === JSON.stringify({ start: true }), | ||
202, { | ||
name: 'advance-1013', | ||
}) | ||
fetchMock.mock((url, opts) => url === 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1014/phase/8567/step/15490/cancel' && | ||
opts.method === 'PUT' && opts.body === JSON.stringify({ approved: false }), | ||
500, { | ||
name: 'cancel-1014', | ||
}) | ||
fetchMock.mock((url, opts) => url === 'https://cloudmanager.adobe.io/api/program/5/pipeline/7/execution/1016/phase/8567/step/15490/advance' && | ||
opts.method === 'PUT' && opts.body === JSON.stringify({ approved: true }), | ||
500, { | ||
name: 'advance-1016', | ||
}) | ||
@@ -1033,0 +1502,0 @@ fetchMock.mock('https://cloudmanager.adobe.io/api/program/7', 404) |
@@ -1,2 +0,1 @@ | ||
/* | ||
@@ -15,2 +14,4 @@ Copyright 2020 Adobe. All rights reserved. | ||
const del = require('del') | ||
const zlib = require('zlib') | ||
const actualZlib = jest.requireActual('zlib') | ||
const { codes } = require('../src/SDKErrors') | ||
@@ -26,2 +27,3 @@ | ||
} | ||
zlib.createGunzip.mockImplementation(actualZlib.createGunzip) | ||
}) | ||
@@ -31,2 +33,3 @@ | ||
del.sync(outputDirectory) | ||
zlib.createGunzip.mockReset() | ||
}) | ||
@@ -86,2 +89,39 @@ | ||
test('download-logs - uncaught unzip error', async () => { | ||
zlib.createGunzip.mockImplementation(() => { | ||
const error = new Error() // eslint-disable-line aio-lib-cloudmanager-error-codes | ||
error.errno = 6 | ||
throw error | ||
}) | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.downloadLogs('4', '1', 'author', 'aemerror', '1', outputDirectory) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_LOG_UNZIP({ messageValues: ['https://filestore/logs/author_aemerror_2019-09-8.log.gz', './log-output/1-author-aemerror-2019-09-8.log'] }), | ||
) | ||
}) | ||
test('download-logs - success - multiple', async () => { | ||
expect.assertions(3) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.downloadLogs('4', '1', 'preview', 'aemerror', '1', outputDirectory) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toHaveLength(3) | ||
await expect(result).resolves.toMatchObject([{ | ||
path: outputDirectory + '/1-author-aemerror-2019-09-8-0.log', | ||
}, | ||
{ | ||
path: outputDirectory + '/1-author-aemerror-2019-09-8-1.log', | ||
}, | ||
{ | ||
path: outputDirectory + '/1-author-aemerror-2019-09-7.log', | ||
}]) | ||
}) | ||
test('download-logs - failure - download url is empty object', async () => { | ||
@@ -88,0 +128,0 @@ expect.assertions(2) |
@@ -15,2 +15,7 @@ /* | ||
/* global createSdkClient, fetchMock, mockFetchResponseWithMethod */ // for linter | ||
beforeEach(() => { | ||
fetchMock.resetProgram5EmbeddedPipelines() | ||
}) | ||
test('listPipelines - success empty', async () => { | ||
@@ -52,5 +57,44 @@ expect.assertions(2) | ||
status: 'IDLE', | ||
}, | ||
{ | ||
id: '9', | ||
name: 'test5', | ||
status: 'IDLE', | ||
}]) | ||
}) | ||
test('listPipelines - busy -- success', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.listPipelines('5', { busy: true }) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).resolves.toMatchObject([ | ||
{ | ||
id: '6', | ||
name: 'test2', | ||
status: 'BUSY', | ||
}, | ||
{ | ||
id: '7', | ||
name: 'test3', | ||
status: 'BUSY', | ||
}, | ||
]) | ||
}) | ||
test('listPipelines - no embedded list', async () => { | ||
fetchMock.setProgram5EmbeddedPipelinesToEmptyObject() | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.listPipelines('5') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_FIND_PIPELINES({ messageValues: '5' }), | ||
) | ||
}) | ||
test('listPipelines - program in programs list but not found', async () => { | ||
@@ -92,2 +136,14 @@ expect.assertions(2) | ||
test('deletePipeline - delete pipeline returns 400 -- different error cases', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.deletePipeline('5', '8') | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_DELETE_PIPELINE({ messageValues: 'https://cloudmanager.adobe.io/api/program/5/pipeline/8 (400 Bad Request) - Test Exception(s): some error message' }), | ||
) | ||
}) | ||
test('deletePipeline - bad pipeline', async () => { | ||
@@ -160,2 +216,16 @@ expect.assertions(2) | ||
test('updatePipeline - no build phase', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient() | ||
const result = sdkClient.updatePipeline('5', '9', { | ||
branch: 'develop', | ||
}) | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_NO_BUILD_PHASE({ messageValues: '9' }), | ||
) | ||
}) | ||
test('updatePipeline - repository and branch success', async () => { | ||
@@ -162,0 +232,0 @@ expect.assertions(2) |
@@ -440,5 +440,6 @@ /** | ||
* @property name - Name of the variable. Of a-z, A-Z, _ and 0-9 Cannot begin with a number. | ||
* @property value - Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. | ||
* @property value - Value of the variable. Read-Write for non-secrets, write-only for secrets. The length of `secretString` values must be less than 500 characters. An empty value causes a variable to be deleted. | ||
* @property type - Type of the variable. Default `string` if missing. `secretString` variables are encrypted at rest. The type of a variable be changed after creation; the variable must be deleted and recreated. | ||
* @property service - Service of the variable. When not provided, the variable applies to all services. Currently only the values 'author' and 'publish' are supported. Note - this value is case-sensitive. | ||
* @property service - Service of the variable. When not provided, the variable applies to all services. Currently the values 'author', 'publish', and 'preview' are supported. Note - this value is case-sensitive. | ||
* @property status - Status of the variable | ||
*/ | ||
@@ -450,2 +451,3 @@ declare type Variable = { | ||
service: string; | ||
status: string; | ||
}; | ||
@@ -452,0 +454,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1841115
72
10013
1
899