Compare commits

...

1 Commits

Author SHA1 Message Date
Nicolas Humbert a26ce5f5a8 CLDSRV-554 Allow backbeat/metadata API to be tested E2E 2024-07-05 12:51:58 +02:00
5 changed files with 38 additions and 16 deletions

View File

@ -1,7 +1,7 @@
const https = require('https'); const https = require('https');
const AWS = require('aws-sdk'); const AWS = require('aws-sdk');
const memCredentials = require('../../lib/json/mem_credentials.json'); const { getCredentials } = require('./credentials');
const { getAwsCredentials } = require('./awsConfig'); const { getAwsCredentials } = require('./awsConfig');
const conf = require('../../../../../lib/Config').config; const conf = require('../../../../../lib/Config').config;
@ -29,16 +29,8 @@ const DEFAULT_MEM_OPTIONS = {
}; };
const DEFAULT_AWS_OPTIONS = {}; const DEFAULT_AWS_OPTIONS = {};
if (!memCredentials || Object.is(memCredentials, {})) {
throw new Error('Credential info is missing in mem_credentials.json');
}
function _getMemCredentials(profile) { function _getMemCredentials(profile) {
const credentials = memCredentials[profile] || memCredentials.default; const { accessKeyId, secretAccessKey } = getCredentials(profile);
const accessKeyId = credentials.accessKey;
const secretAccessKey = credentials.secretKey;
return new AWS.Credentials(accessKeyId, secretAccessKey); return new AWS.Credentials(accessKeyId, secretAccessKey);
} }

View File

@ -0,0 +1,21 @@
const memCredentials = require('../../lib/json/mem_credentials.json');
if (!memCredentials || Object.is(memCredentials, {})) {
throw new Error('Credential info is missing in mem_credentials.json');
}
function getCredentials(profile = 'default') {
const credentials = memCredentials[profile] || memCredentials.default;
const accessKeyId = credentials.accessKey;
const secretAccessKey = credentials.secretKey;
return {
accessKeyId,
secretAccessKey,
};
}
module.exports = {
getCredentials,
};

View File

@ -6,14 +6,17 @@ const versionIdUtils = versioning.VersionID;
const { makeRequest, makeBackbeatRequest } = require('../../utils/makeRequest'); const { makeRequest, makeBackbeatRequest } = require('../../utils/makeRequest');
const BucketUtility = require('../../../aws-node-sdk/lib/utility/bucket-util'); const BucketUtility = require('../../../aws-node-sdk/lib/utility/bucket-util');
const { getCredentials } = require('../../../aws-node-sdk/test/support/credentials');
const ipAddress = process.env.IP ? process.env.IP : '127.0.0.1'; const ipAddress = process.env.IP ? process.env.IP : '127.0.0.1';
const describeSkipIfAWS = process.env.AWS_ON_AIR ? describe.skip : describe; const describeSkipIfAWS = process.env.AWS_ON_AIR ? describe.skip : describe;
const isNullVersionCompatMode = process.env.ENABLE_NULL_VERSION_COMPAT_MODE === 'true'; const isNullVersionCompatMode = process.env.ENABLE_NULL_VERSION_COMPAT_MODE === 'true';
const { accessKeyId, secretAccessKey } = getCredentials();
const backbeatAuthCredentials = { const backbeatAuthCredentials = {
accessKey: 'accessKey1', accessKey: accessKeyId,
secretKey: 'verySecretKey1', secretKey: secretAccessKey,
}; };
const TEST_BUCKET = 'backbeatbucket'; const TEST_BUCKET = 'backbeatbucket';

View File

@ -5,12 +5,15 @@ const { ObjectMD } = models;
const { makeBackbeatRequest } = require('../../utils/makeRequest'); const { makeBackbeatRequest } = require('../../utils/makeRequest');
const BucketUtility = require('../../../aws-node-sdk/lib/utility/bucket-util'); const BucketUtility = require('../../../aws-node-sdk/lib/utility/bucket-util');
const { getCredentials } = require('../../../aws-node-sdk/test/support/credentials');
const describeSkipIfAWS = process.env.AWS_ON_AIR ? describe.skip : describe; const describeSkipIfAWS = process.env.AWS_ON_AIR ? describe.skip : describe;
const { accessKeyId, secretAccessKey } = getCredentials();
const backbeatAuthCredentials = { const backbeatAuthCredentials = {
accessKey: 'accessKey1', accessKey: accessKeyId,
secretKey: 'verySecretKey1', secretKey: secretAccessKey,
}; };
const testData = 'testkey data'; const testData = 'testkey data';

View File

@ -3,13 +3,16 @@ const http = require('http');
const { makeRequest } = require('../../utils/makeRequest'); const { makeRequest } = require('../../utils/makeRequest');
const MetadataMock = require('../../utils/MetadataMock'); const MetadataMock = require('../../utils/MetadataMock');
const { getCredentials } = require('../../../aws-node-sdk/test/support/credentials');
const ipAddress = process.env.IP ? process.env.IP : 'localhost'; const ipAddress = process.env.IP ? process.env.IP : 'localhost';
const metadataMock = new MetadataMock(); const metadataMock = new MetadataMock();
const { accessKeyId, secretAccessKey } = getCredentials();
const metadataAuthCredentials = { const metadataAuthCredentials = {
accessKey: 'accessKey1', accessKey: accessKeyId,
secretKey: 'verySecretKey1', secretKey: secretAccessKey,
}; };
function makeMetadataRequest(params, callback) { function makeMetadataRequest(params, callback) {