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