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 AWS = require('aws-sdk');
const memCredentials = require('../../lib/json/mem_credentials.json');
const { getCredentials } = require('./credentials');
const { getAwsCredentials } = require('./awsConfig');
const conf = require('../../../../../lib/Config').config;
@ -29,16 +29,8 @@ const DEFAULT_MEM_OPTIONS = {
};
const DEFAULT_AWS_OPTIONS = {};
if (!memCredentials || Object.is(memCredentials, {})) {
throw new Error('Credential info is missing in mem_credentials.json');
}
function _getMemCredentials(profile) {
const credentials = memCredentials[profile] || memCredentials.default;
const accessKeyId = credentials.accessKey;
const secretAccessKey = credentials.secretKey;
const { accessKeyId, secretAccessKey } = getCredentials(profile);
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 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 describeSkipIfAWS = process.env.AWS_ON_AIR ? describe.skip : describe;
const isNullVersionCompatMode = process.env.ENABLE_NULL_VERSION_COMPAT_MODE === 'true';
const { accessKeyId, secretAccessKey } = getCredentials();
const backbeatAuthCredentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: accessKeyId,
secretKey: secretAccessKey,
};
const TEST_BUCKET = 'backbeatbucket';

View File

@ -5,12 +5,15 @@ const { ObjectMD } = models;
const { makeBackbeatRequest } = require('../../utils/makeRequest');
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 { accessKeyId, secretAccessKey } = getCredentials();
const backbeatAuthCredentials = {
accessKey: 'accessKey1',
secretKey: 'verySecretKey1',
accessKey: accessKeyId,
secretKey: secretAccessKey,
};
const testData = 'testkey data';

View File

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