}
+ /**
+ * Valid response statuses.
+ * Allow 401 as a workaround for one specific client which return such on
+ * its client identifier endpoint when not yet authenticated.
+ * @param {Number} status
+ * @returns {Boolean}
+ */
+ static _validateStatus(status) {
+ return (status >= 200 && status < 300) || status == 401;
+ }
+
/**
* A request config skeleton.
* @param {String} method
responseType: 'text',
// So force the matter by eliding all response transformations
transformResponse: [ (res) => res ],
+
+ validateStatus: Communication._validateStatus,
};
Object.entries(params).map(([k, v]) => config.params.set(k, v));
return config;
},
params: expectedUrlObj.searchParams,
responseType: 'text',
+ validateStatus: Communication._validateStatus,
};
const result = Communication._axiosConfig(method, urlObj, body, params, {
'Content-Type': contentType,
headers: {},
params: expectedUrlObj.searchParams,
responseType: 'text',
+ validateStatus: Communication._validateStatus,
};
const result = Communication._axiosConfig(method, urlObj);
delete result.transformResponse;
headers: {},
params: urlObj.searchParams,
responseType: 'text',
+ validateStatus: Communication._validateStatus,
};
const result = Communication._axiosConfig(method, urlObj, body, params, {});
delete result.transformResponse;
assert.deepStrictEqual(result, expected);
-
});
it('covers null response transform', function () {
const urlObj = new URL(requestUrl);
const result = Communication._axiosConfig('GET', urlObj, undefined, {}, {});
result.transformResponse[0]();
});
+
+ describe('_validateStatus', function () {
+ it('allows normal valid', function () {
+ const result = Communication._validateStatus(200);
+ assert.strictEqual(result, true);
+ });
+ it('allows unauthorized', function () {
+ const result = Communication._validateStatus(401);
+ assert.strictEqual(result, true);
+ });
+ it('rejects invalid', function () {
+ const result = Communication._validateStatus(400);
+ assert.strictEqual(result, false);
+ });
+ }); // _validateStatus
}); // Axios Configurations
describe('_baseUrlString', function () {