@adobe/aio-lib-cloudmanager
Advanced tools
Comparing version 0.2.0 to 0.2.1
# Changelog | ||
## [0.2.1](https://github.com/adobe/aio-lib-cloudmanager/compare/0.2.0...0.2.1) (2021-01-20) | ||
### Bug Fixes | ||
* **auth:** some response bodies were not correctly handled. fixes [#53](https://github.com/adobe/aio-lib-cloudmanager/issues/53) ([#54](https://github.com/adobe/aio-lib-cloudmanager/issues/54)) ([5ee68ee](https://github.com/adobe/aio-lib-cloudmanager/commit/5ee68ee0dd8b2294dae877d9ef3a50eec459d0f0)) | ||
# [0.2.0](https://github.com/adobe/aio-lib-cloudmanager/compare/0.1.6...0.2.0) (2021-01-12) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@adobe/aio-lib-cloudmanager", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Adobe I/O Cloud Manager Library", | ||
@@ -44,7 +44,7 @@ "repository": { | ||
"eol": "0.9.1", | ||
"eslint": "7.17.0", | ||
"eslint": "7.18.0", | ||
"eslint-config-standard": "16.0.2", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-jest": "24.1.3", | ||
"eslint-plugin-jsdoc": "31.0.3", | ||
"eslint-plugin-jsdoc": "31.0.6", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -55,3 +55,3 @@ "eslint-plugin-promise": "4.2.1", | ||
"handlebars": "4.7.6", | ||
"husky": "4.3.7", | ||
"husky": "4.3.8", | ||
"jest": "26.6.3", | ||
@@ -63,3 +63,3 @@ "jest-junit": "12.0.0", | ||
"jsdoc-to-markdown": "6.0.1", | ||
"semantic-release": "17.3.1", | ||
"semantic-release": "17.3.3", | ||
"sinon": "9.2.3", | ||
@@ -66,0 +66,0 @@ "stdout-stderr": "0.1.13", |
@@ -147,22 +147,26 @@ /* | ||
if (resContentType) { | ||
if (resContentType.indexOf('application/problem+json') === 0) { | ||
const problem = JSON.parse(text) | ||
if (problem.errors && problem.errors.length > 0) { | ||
const errors = problem.errors.map(error => error.message || error).join(', ') | ||
const handler = problemTypes[problem.type] || problemTypes.other | ||
sdkDetails.errors = problem.errors | ||
if (handler.extraDetailsKey) { | ||
sdkDetails[handler.extraDetailsKey] = problem.errors | ||
try { | ||
if (resContentType.indexOf('application/problem+json') === 0) { | ||
const problem = JSON.parse(text) | ||
if (problem.errors && problem.errors.length > 0) { | ||
const errors = problem.errors.map(error => error.message || error).join(', ') | ||
const handler = problemTypes[problem.type] || problemTypes.other | ||
sdkDetails.errors = problem.errors | ||
if (handler.extraDetailsKey) { | ||
sdkDetails[handler.extraDetailsKey] = problem.errors | ||
} | ||
messageValues = `${messageValues} - ${handler.prefix(problem)}: ${errors}` | ||
} | ||
messageValues = `${messageValues} - ${handler.prefix(problem)}: ${errors}` | ||
} | ||
} else if (resContentType === 'application/json') { | ||
const parsedBody = JSON.parse(text) | ||
sdkDetails.errorDetails = parsedBody | ||
if (parsedBody.message) { | ||
messageValues = messageValues + ` - Detail: ${parsedBody.message}` | ||
if (parsedBody.error_code) { | ||
messageValues = messageValues + ` (Code: ${parsedBody.error_code})` | ||
} else if (resContentType === 'application/json') { | ||
const parsedBody = JSON.parse(text) | ||
sdkDetails.errorDetails = parsedBody | ||
if (parsedBody.message) { | ||
messageValues = messageValues + ` - Detail: ${parsedBody.message}` | ||
if (parsedBody.error_code) { | ||
messageValues = messageValues + ` (Code: ${parsedBody.error_code})` | ||
} | ||
} | ||
} | ||
} catch (e) { | ||
// presumably in this case the response body is not helpful and need not be included in the error message | ||
} | ||
@@ -169,0 +173,0 @@ } |
@@ -49,2 +49,9 @@ /* | ||
mockResponseWithOrgId('https://cloudmanager.adobe.io/api/programs', 'empty', {}) | ||
mockResponseWithOrgId('https://cloudmanager.adobe.io/api/programs', 'unauthorized', { | ||
status: 401, | ||
headers: { | ||
'content-type': 'application/problem+json', | ||
}, | ||
body: 'Unauthorized', | ||
}) | ||
mockResponseWithOrgId('https://cloudmanager.adobe.io/api/programs', 'good', { | ||
@@ -51,0 +58,0 @@ _embedded: { |
@@ -39,2 +39,14 @@ /* | ||
test('listPrograms - unauthorized', async () => { | ||
expect.assertions(2) | ||
const sdkClient = await createSdkClient('unauthorized') | ||
const result = sdkClient.listPrograms() | ||
await expect(result instanceof Promise).toBeTruthy() | ||
await expect(result).rejects.toEqual( | ||
new codes.ERROR_LIST_PROGRAMS({ messageValues: 'https://cloudmanager.adobe.io/api/programs (401 Unauthorized)' }), | ||
) | ||
}) | ||
test('listPrograms - success empty', async () => { | ||
@@ -41,0 +53,0 @@ expect.assertions(2) |
1689385
6604