Compare commits
2 Commits
developmen
...
tests/othe
Author | SHA1 | Date |
---|---|---|
Alexander Chan | cc17e42e91 | |
Alexander Chan | 7d990dd201 |
|
@ -1,6 +1,6 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const glob = require('simple-glob');
|
const glob = require('simple-glob');
|
||||||
const joi = require('@hapi/joi');
|
const joi = require('joi');
|
||||||
const werelogs = require('werelogs');
|
const werelogs = require('werelogs');
|
||||||
|
|
||||||
const ARN = require('../../models/ARN');
|
const ARN = require('../../models/ARN');
|
||||||
|
@ -135,15 +135,19 @@ class AuthLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
_validateData(authData, filePath) {
|
_validateData(authData, filePath) {
|
||||||
const res = joi.validate(authData, this._joiValidator,
|
let res = {};
|
||||||
{ abortEarly: false });
|
|
||||||
if (res.error) {
|
try {
|
||||||
this._dumpJoiErrors(res.error.details, filePath);
|
res = joi.attempt(authData, this._joiValidator,
|
||||||
|
{ abortEarly: false });
|
||||||
|
} catch (err) {
|
||||||
|
this._dumpJoiErrors(error.details, filePath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let allKeys = [];
|
let allKeys = [];
|
||||||
let arnError = false;
|
let arnError = false;
|
||||||
const validatedAuth = res.value;
|
const validatedAuth = res;
|
||||||
validatedAuth.accounts.forEach(account => {
|
validatedAuth.accounts.forEach(account => {
|
||||||
// backward-compat: ignore arn if starts with 'aws:' and log a
|
// backward-compat: ignore arn if starts with 'aws:' and log a
|
||||||
// warning
|
// warning
|
||||||
|
@ -195,12 +199,17 @@ class AuthLoader {
|
||||||
if (arnError) {
|
if (arnError) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const uniqueKeysRes = joi.validate(
|
|
||||||
allKeys, this._joiKeysValidator.unique('access'));
|
let uniqueKeysRes = {};
|
||||||
if (uniqueKeysRes.error) {
|
|
||||||
|
try {
|
||||||
|
uniqueKeysRes = joi.attempt(
|
||||||
|
allKeys, this._joiKeysValidator.unique('access'));
|
||||||
|
} catch (err) {
|
||||||
this._dumpJoiErrors(uniqueKeysRes.error.details, filePath);
|
this._dumpJoiErrors(uniqueKeysRes.error.details, filePath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const errors = require('../errors');
|
||||||
* handle errors.
|
* handle errors.
|
||||||
*
|
*
|
||||||
* @param {stream.Readable} s - Readable stream
|
* @param {stream.Readable} s - Readable stream
|
||||||
* @param {@hapi/joi} [joiSchema] - optional validation schema for the JSON object
|
* @param {joi} [joiSchema] - optional validation schema for the JSON object
|
||||||
* @return {Promise} a Promise resolved with the parsed JSON object as a result
|
* @return {Promise} a Promise resolved with the parsed JSON object as a result
|
||||||
*/
|
*/
|
||||||
async function readJSONStreamObject(s, joiSchema) {
|
async function readJSONStreamObject(s, joiSchema) {
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
"agentkeepalive": "^4.1.3",
|
"agentkeepalive": "^4.1.3",
|
||||||
"ajv": "6.12.2",
|
"ajv": "6.12.2",
|
||||||
"async": "~2.1.5",
|
"async": "~2.1.5",
|
||||||
"base62": "2.0.1",
|
|
||||||
"base-x": "3.0.8",
|
"base-x": "3.0.8",
|
||||||
|
"base62": "2.0.1",
|
||||||
"debug": "~2.6.9",
|
"debug": "~2.6.9",
|
||||||
"diskusage": "^1.1.1",
|
"diskusage": "^1.1.1",
|
||||||
"ioredis": "4.9.5",
|
"ioredis": "4.9.5",
|
||||||
"ipaddr.js": "1.9.1",
|
"ipaddr.js": "1.9.1",
|
||||||
|
"joi": "^17.4.2",
|
||||||
"level": "~5.0.1",
|
"level": "~5.0.1",
|
||||||
"level-sublevel": "~6.6.5",
|
"level-sublevel": "~6.6.5",
|
||||||
"node-forge": "^0.7.1",
|
"node-forge": "^0.7.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const joi = require('@hapi/joi');
|
const joi = require('joi');
|
||||||
const readJSONStreamObject = require('../../../lib/stream/readJSONStreamObject');
|
const readJSONStreamObject = require('../../../lib/stream/readJSONStreamObject');
|
||||||
|
|
||||||
class ReqStream extends stream.Readable {
|
class ReqStream extends stream.Readable {
|
||||||
|
|
Loading…
Reference in New Issue