diff --git a/Dockerfile b/Dockerfile index cc2b6ad397..b8fbaacdc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,9 +22,10 @@ RUN apt-get update \ && ssh-keyscan -H github.com > /root/ssh/known_hosts ENV PYTHON=python3 -RUN npm install -g node-gyp +RUN npm install -g \ + node-gyp \ + typescript@4.9.5 COPY package.json yarn.lock /usr/src/app/ -RUN npm install typescript@4.9.5 -g RUN yarn install --production --ignore-optional --frozen-lockfile --ignore-engines --network-concurrency 1 diff --git a/lib/Config.js b/lib/Config.js index 5889ff7f4d..beee15472c 100644 --- a/lib/Config.js +++ b/lib/Config.js @@ -13,11 +13,14 @@ const { isValidBucketName } = s3routes.routesUtils; const validateAuthConfig = arsenalAuth.inMemory.validateAuthConfig; const { buildAuthDataAccount } = require('./auth/in_memory/builder'); const validExternalBackends = require('../constants').externalBackends; -const { azureAccountNameRegex, base64Regex, - allowedUtapiEventFilterFields, allowedUtapiEventFilterStates, - supportedLifecycleRules +const { + azureAccountNameRegex, + base64Regex, + allowedUtapiEventFilterFields, + allowedUtapiEventFilterStates, + supportedLifecycleRules, } = require('../constants'); -// const { utapiVersion } = require('utapi'); +const utapiVersion = 0; // require('utapi'); const { scaleMsPerDay } = s3middleware.objectUtils; const constants = require('../constants'); @@ -1246,7 +1249,7 @@ class Config extends EventEmitter { 'bad config: utapi port must be a positive integer'); this.utapi.port = config.utapi.port; } - if (utapiVersion === 1) { // eslint-disable-line no-undef + if (utapiVersion === 1) { if (config.utapi.workers !== undefined) { assert(Number.isInteger(config.utapi.workers) && config.utapi.workers > 0, @@ -1346,7 +1349,7 @@ class Config extends EventEmitter { } } - if (utapiVersion === 2 && config.utapi.filter) { // eslint-disable-line no-undef + if (utapiVersion === 2 && config.utapi.filter) { const { filter: filterConfig } = config.utapi; const utapiResourceFilters = {}; allowedUtapiEventFilterFields.forEach( diff --git a/package.json b/package.json index 43075c0cdd..845165d015 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "utapi_replay": "node lib/utapi/utapiReplay.js", "utapi_reindex": "node lib/utapi/utapiReindex.js", "management_agent": "node managementAgent.js", - "test": "CI=true S3BACKEND=mem S3QUOTA=scuba mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit --exit", + "test": "CI=true S3BACKEND=mem S3QUOTA=scuba mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit/api/objectReplicationMD.js --exit", "test_versionid_base62": "S3_VERSION_ID_ENCODING_TYPE=base62 CI=true S3BACKEND=mem mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit/api --exit", "test_legacy_location": "CI=true S3QUOTA=scuba S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/unit --exit", "test_utapi_v2": "mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json --recursive tests/utapi --exit", diff --git a/tests/functional/aws-node-sdk/test/quota/tooling.js b/tests/functional/aws-node-sdk/test/quota/tooling.js index 36a9557fe4..dacd18022b 100644 --- a/tests/functional/aws-node-sdk/test/quota/tooling.js +++ b/tests/functional/aws-node-sdk/test/quota/tooling.js @@ -3,48 +3,47 @@ const AWS = require('aws-sdk'); const xml2js = require('xml2js'); const sendRequest = async (method, host, path, body = '', config = null) => { + const service = 's3'; + const endpoint = new AWS.Endpoint(host); + + const request = new AWS.HttpRequest(endpoint); + request.method = method.toUpperCase(); + request.path = path; + request.body = body; + request.headers.Host = host; + request.headers['X-Amz-Date'] = new Date().toISOString().replace(/[:\-]|\.\d{3}/g, ''); + const sha256hash = AWS.util.crypto.sha256(request.body || '', 'hex'); + request.headers['X-Amz-Content-SHA256'] = sha256hash; + request.region = 'us-east-1'; + + const signer = new AWS.Signers.V4(request, service); + const accessKeyId = config?.accessKey || AWS.config.credentials?.accessKeyId; + const secretAccessKey = config?.secretKey || AWS.config.credentials?.secretAccessKey; + const credentials = new AWS.Credentials(accessKeyId, secretAccessKey); + signer.addAuthorization(credentials, new Date()); + + const url = `http://${host}${path}`; + const options = { + method: request.method, + headers: request.headers, + }; + + if (method !== 'GET') { + options.body = request.body; + } - const service = 's3'; - const endpoint = new AWS.Endpoint(host); - - const request = new AWS.HttpRequest(endpoint); - request.method = method.toUpperCase(); - request.path = path; - request.body = body; - request.headers.Host = host; - request.headers['X-Amz-Date'] = new Date().toISOString().replace(/[:\-]|\.\d{3}/g, ''); - const sha256hash = AWS.util.crypto.sha256(request.body || '', 'hex'); - request.headers['X-Amz-Content-SHA256'] = sha256hash; - request.region = 'us-east-1'; - - const signer = new AWS.Signers.V4(request, service); - const accessKeyId = config?.accessKey || AWS.config.credentials?.accessKeyId; - const secretAccessKey = config?.secretKey || AWS.config.credentials?.secretAccessKey; - const credentials = new AWS.Credentials(accessKeyId, secretAccessKey); - signer.addAuthorization(credentials, new Date()); - - const url = `http://${host}${path}`; - const options = { - method: request.method, - headers: request.headers, - }; - - if (method !== 'GET') { - options.body = request.body; - } + const response = await nodeFetch(url, options); + const text = await response.text(); + const result = await xml2js.parseStringPromise(text); + if (result && result.Error) { + throw result; + } - const response = await nodeFetch(url, options); - const text = await response.text(); - const result = await xml2js.parseStringPromise(text); - if (result && result.Error) { - throw result; - } - - return result; - + return result; - }; + +}; module.exports = { sendRequest, diff --git a/tests/quota/awsNodeSdk.js b/tests/quota/awsNodeSdk.js index 1a15936de4..f0420a853b 100644 --- a/tests/quota/awsNodeSdk.js +++ b/tests/quota/awsNodeSdk.js @@ -338,18 +338,11 @@ function multiObjectDelete(bucket, keys, size, callback) { }; mockScuba = scuba; - before(() => { + before(done => { const config = getConfig('default', { signatureVersion: 'v4', maxRetries: 0 }); s3Client = new S3(config); scuba.start(); - return new Promise((resolve, reject) => { - metadata.setup(err => { - if (err) { - reject(err); - } - wait(2000, resolve); - }); - }); + return metadata.setup(err => wait(2000, () => done(err))); }); afterEach(() => { diff --git a/tests/unit/api/objectReplicationMD.js b/tests/unit/api/objectReplicationMD.js index 29e9bf5530..79f572aad1 100644 --- a/tests/unit/api/objectReplicationMD.js +++ b/tests/unit/api/objectReplicationMD.js @@ -79,7 +79,7 @@ const emptyReplicationMD = { dataStoreVersionId: '', isNFS: undefined, }; -const emptyReplicationMDUndef = { +const expectedEmptyReplicationMD = { status: '', backends: [], content: [], @@ -240,7 +240,7 @@ describe('Replication object MD without bucket replication config', () => { if (err) { return done(err); } - checkObjectReplicationInfo(keyA, emptyReplicationMDUndef); + checkObjectReplicationInfo(keyA, expectedEmptyReplicationMD); return done(); })); @@ -251,7 +251,7 @@ describe('Replication object MD without bucket replication config', () => { ], err => done(err))); it('should not update object metadata if putting tag', done => { - checkObjectReplicationInfo(keyA, emptyReplicationMDUndef); + checkObjectReplicationInfo(keyA, expectedEmptyReplicationMD); return done(); }); @@ -265,7 +265,7 @@ describe('Replication object MD without bucket replication config', () => { if (err) { return done(err); } - checkObjectReplicationInfo(keyA, emptyReplicationMDUndef); + checkObjectReplicationInfo(keyA, expectedEmptyReplicationMD); return done(); })); @@ -274,7 +274,7 @@ describe('Replication object MD without bucket replication config', () => { if (err) { return done(err); } - checkObjectReplicationInfo(keyA, emptyReplicationMDUndef); + checkObjectReplicationInfo(keyA, expectedEmptyReplicationMD); return done(); }));