Compare commits
5 Commits
developmen
...
feature/mi
Author | SHA1 | Date |
---|---|---|
Rahul Padigela | d3cbff8207 | |
Rahul Padigela | fef2e25f31 | |
Rahul Padigela | 2fa4568c78 | |
Rahul Padigela | b6e823f006 | |
Rahul Padigela | e563c9fb8a |
|
@ -0,0 +1,186 @@
|
|||
// For a detailed explanation regarding each configuration property, visit:
|
||||
// https://jestjs.io/docs/en/configuration.html
|
||||
|
||||
module.exports = {
|
||||
// All imported modules in your tests should be mocked automatically
|
||||
// automock: false,
|
||||
|
||||
// Stop running tests after `n` failures
|
||||
// bail: 0,
|
||||
|
||||
// Respect "browser" field in package.json when resolving modules
|
||||
// browser: false,
|
||||
|
||||
// The directory where Jest should store its cached dependency information
|
||||
// cacheDirectory: "/private/var/folders/3k/pc7s4l115n984kmtypkgfyf40000gn/T/jest_dx",
|
||||
|
||||
// Automatically clear mock calls and instances between every test
|
||||
clearMocks: true,
|
||||
|
||||
// Indicates whether the coverage information should be collected while executing the test
|
||||
// collectCoverage: false,
|
||||
|
||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
||||
// collectCoverageFrom: null,
|
||||
|
||||
// The directory where Jest should output its coverage files
|
||||
coverageDirectory: "coverage",
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
// coveragePathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
// "json",
|
||||
// "text",
|
||||
// "lcov",
|
||||
// "clover"
|
||||
// ],
|
||||
|
||||
// An object that configures minimum threshold enforcement for coverage results
|
||||
// coverageThreshold: null,
|
||||
|
||||
// A path to a custom dependency extractor
|
||||
// dependencyExtractor: null,
|
||||
|
||||
// Make calling deprecated APIs throw helpful error messages
|
||||
// errorOnDeprecated: false,
|
||||
|
||||
// Force coverage collection from ignored files using an array of glob patterns
|
||||
// forceCoverageMatch: [],
|
||||
|
||||
// A path to a module which exports an async function that is triggered once before all test suites
|
||||
// globalSetup: null,
|
||||
|
||||
// A path to a module which exports an async function that is triggered once after all test suites
|
||||
// globalTeardown: null,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
// "js",
|
||||
// "json",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "tsx",
|
||||
// "node"
|
||||
// ],
|
||||
|
||||
// A map from regular expressions to module names that allow to stub out resources with a single module
|
||||
// moduleNameMapper: {},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
// An enum that specifies notification mode. Requires { notify: true }
|
||||
// notifyMode: "failure-change",
|
||||
|
||||
// A preset that is used as a base for Jest's configuration
|
||||
// preset: null,
|
||||
|
||||
// Run tests from one or more projects
|
||||
// projects: null,
|
||||
|
||||
// Use this configuration option to add custom reporters to Jest
|
||||
// reporters: undefined,
|
||||
|
||||
// Automatically reset mock state between every test
|
||||
// resetMocks: false,
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: null,
|
||||
|
||||
// Automatically restore mock state between every test
|
||||
// restoreMocks: false,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
// rootDir: null,
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// Allows you to use a custom runner instead of Jest's default test runner
|
||||
// runner: "jest-runner",
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
// setupFiles: [],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
// setupFilesAfterEnv: [],
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
testMatch: [
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
"**/tests/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
||||
],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
// testPathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: null,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jasmine2",
|
||||
|
||||
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
||||
// testURL: "http://localhost",
|
||||
|
||||
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
||||
// timers: "real",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
// transform: null,
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
// verbose: null,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
|
@ -56,6 +56,7 @@
|
|||
"ioredis": "2.4.0",
|
||||
"istanbul": "1.0.0-alpha.2",
|
||||
"istanbul-api": "1.0.0-alpha.13",
|
||||
"jest": "^24.5.0",
|
||||
"lolex": "^1.4.0",
|
||||
"mocha": "^2.3.4",
|
||||
"mocha-junit-reporter": "1.11.1",
|
||||
|
@ -68,23 +69,23 @@
|
|||
},
|
||||
"scripts": {
|
||||
"cloudserver": "S3METADATA=mongodb npm-run-all --parallel start_dataserver start_s3server",
|
||||
"ft_awssdk": "cd tests/functional/aws-node-sdk && mocha test/",
|
||||
"ft_awssdk": "cd tests/functional/aws-node-sdk && jest test/",
|
||||
"ft_awssdk_aws": "cd tests/functional/aws-node-sdk && AWS_ON_AIR=true mocha test/",
|
||||
"ft_awssdk_buckets": "cd tests/functional/aws-node-sdk && mocha test/bucket",
|
||||
"ft_awssdk_objects_misc": "cd tests/functional/aws-node-sdk && mocha test/legacy test/object test/service test/support",
|
||||
"ft_awssdk_versioning": "cd tests/functional/aws-node-sdk && mocha test/versioning/",
|
||||
"ft_awssdk_external_backends": "cd tests/functional/aws-node-sdk && mocha test/multipleBackend",
|
||||
"ft_awssdk_buckets": "cd tests/functional/aws-node-sdk && jest test/bucket",
|
||||
"ft_awssdk_objects_misc": "cd tests/functional/aws-node-sdk && jest test/legacy test/object test/service test/support",
|
||||
"ft_awssdk_versioning": "cd tests/functional/aws-node-sdk && jest test/versioning/",
|
||||
"ft_awssdk_external_backends": "cd tests/functional/aws-node-sdk && jest test/multipleBackend",
|
||||
"ft_management": "cd tests/functional/report && npm test",
|
||||
"ft_node": "cd tests/functional/raw-node && npm test",
|
||||
"ft_node_routes": "cd tests/functional/raw-node && npm run test-routes",
|
||||
"ft_gcp": "cd tests/functional/raw-node && npm run test-gcp",
|
||||
"ft_healthchecks": "cd tests/functional/healthchecks && npm test",
|
||||
"ft_s3cmd": "cd tests/functional/s3cmd && mocha -t 40000 *.js",
|
||||
"ft_s3curl": "cd tests/functional/s3curl && mocha -t 40000 *.js",
|
||||
"ft_util": "cd tests/functional/utilities && mocha -t 40000 *.js",
|
||||
"ft_s3cmd": "cd tests/functional/s3cmd && jest -t 40000 *.js",
|
||||
"ft_s3curl": "cd tests/functional/s3curl && jest -t 40000 *.js",
|
||||
"ft_util": "cd tests/functional/utilities && jest -t 40000 *.js",
|
||||
"ft_test": "npm-run-all -s ft_awssdk ft_s3cmd ft_s3curl ft_node ft_healthchecks ft_management ft_util",
|
||||
"ft_search": "cd tests/functional/aws-node-sdk && mocha -t 90000 test/mdSearch",
|
||||
"install_ft_deps": "npm install aws-sdk@2.28.0 bluebird@3.3.1 mocha@2.3.4 mocha-junit-reporter@1.11.1 tv4@1.2.7",
|
||||
"ft_search": "cd tests/functional/aws-node-sdk && jest -t 90000 test/mdSearch",
|
||||
"install_ft_deps": "npm install aws-sdk@2.28.0 bluebird@3.3.1 mocha@2.3.4 mocha-junit-reporter@1.11.1 tv4@1.2.7 jest",
|
||||
"lint": "eslint $(git ls-files '*.js')",
|
||||
"lint_md": "mdlint $(git ls-files '*.md')",
|
||||
"mem_backend": "S3BACKEND=mem node index.js",
|
||||
|
@ -99,10 +100,10 @@
|
|||
"start_utapi": "node lib/utapi/utapi.js",
|
||||
"utapi_replay": "node lib/utapi/utapiReplay.js",
|
||||
"management_agent": "node managementAgent.js",
|
||||
"test": "CI=true S3BACKEND=mem mocha --recursive tests/unit",
|
||||
"test_legacy_location": "CI=true S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem mocha --recursive tests/unit",
|
||||
"multiple_backend_test": "CI=true S3BACKEND=mem S3DATA=multiple mocha -t 20000 --recursive tests/multipleBackend",
|
||||
"unit_coverage": "CI=true mkdir -p coverage/unit/ && S3BACKEND=mem MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/unit.xml istanbul cover --dir coverage/unit _mocha -- --reporter mocha-junit-reporter --recursive tests/unit",
|
||||
"unit_coverage_legacy_location": "CI=true mkdir -p coverage/unitlegacylocation/ && S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/unitlegacylocation.xml istanbul cover --dir coverage/unitlegacylocation _mocha -- --reporter mocha-junit-reporter --recursive tests/unit"
|
||||
"test": "jest",
|
||||
"test_legacy_location": "CI=true S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem jest tests/unit",
|
||||
"multiple_backend_test": "CI=true S3BACKEND=mem S3DATA=multiple jest -t 20000 tests/multipleBackend",
|
||||
"unit_coverage": "CI=true mkdir -p coverage/unit/ && S3BACKEND=mem MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/unit.xml istanbul cover --dir coverage/unit _mocha -- --reporter mocha-junit-reporter tests/unit",
|
||||
"unit_coverage_legacy_location": "CI=true mkdir -p coverage/unitlegacylocation/ && S3_LOCATION_FILE=tests/locationConfig/locationConfigLegacy.json S3BACKEND=mem MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/unitlegacylocation.xml istanbul cover --dir coverage/unitlegacylocation _mocha -- --reporter mocha-junit-reporter tests/unit"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,14 +61,12 @@ function methodRequest(params, callback) {
|
|||
if (code) {
|
||||
const message = Number.isNaN(parseInt(code, 10)) ?
|
||||
`<Code>${code}</Code>` : '';
|
||||
assert(total.indexOf(message) > -1, `Expected ${message}`);
|
||||
assert.deepEqual(res.statusCode, statusCode[code],
|
||||
`status code expected: ${statusCode[code]}`);
|
||||
expect(total.indexOf(message) > -1).toBeTruthy();
|
||||
expect(res.statusCode).toEqual(statusCode[code]);
|
||||
}
|
||||
if (headersResponse) {
|
||||
Object.keys(headersResponse).forEach(key => {
|
||||
assert.deepEqual(res.headers[key], headersResponse[key],
|
||||
`error header: ${key}`);
|
||||
expect(res.headers[key]).toEqual(headersResponse[key]);
|
||||
});
|
||||
} else {
|
||||
// if no headersResponse provided, should not have these headers
|
||||
|
@ -77,14 +75,12 @@ function methodRequest(params, callback) {
|
|||
'access-control-allow-methods',
|
||||
'access-control-allow-credentials',
|
||||
'vary'].forEach(key => {
|
||||
assert.strictEqual(res.headers[key], undefined,
|
||||
`Error: ${key} should not have value`);
|
||||
expect(res.headers[key]).toBe(undefined);
|
||||
});
|
||||
}
|
||||
if (headersOmitted) {
|
||||
headersOmitted.forEach(key => {
|
||||
assert.strictEqual(res.headers[key], undefined,
|
||||
`Error: ${key} should not have value`);
|
||||
expect(res.headers[key]).toBe(undefined);
|
||||
});
|
||||
}
|
||||
return callback();
|
||||
|
|
|
@ -28,11 +28,11 @@ function checkOneVersion(s3, bucket, versionId, callback) {
|
|||
if (err) {
|
||||
callback(err);
|
||||
}
|
||||
assert.strictEqual(data.Versions.length, 1);
|
||||
expect(data.Versions.length).toBe(1);
|
||||
if (versionId) {
|
||||
assert.strictEqual(data.Versions[0].VersionId, versionId);
|
||||
expect(data.Versions[0].VersionId).toBe(versionId);
|
||||
}
|
||||
assert.strictEqual(data.DeleteMarkers.length, 0);
|
||||
expect(data.DeleteMarkers.length).toBe(0);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
@ -100,9 +100,8 @@ function createDualNullVersion(s3, bucketName, keyName, cb) {
|
|||
// putting new version
|
||||
next => s3.putObject({ Bucket: bucketName, Key: keyName },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
'Unexpected err putting new version');
|
||||
assert(data.VersionId);
|
||||
expect(err).toBe(null);
|
||||
expect(data.VersionId).toBeTruthy();
|
||||
next(null, data.VersionId);
|
||||
}),
|
||||
// delete version we just created, master version should be updated
|
||||
|
@ -115,9 +114,8 @@ function createDualNullVersion(s3, bucketName, keyName, cb) {
|
|||
// getting object should return null version now
|
||||
next => s3.getObject({ Bucket: bucketName, Key: keyName },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
'Unexpected err getting latest version');
|
||||
assert.strictEqual(data.VersionId, 'null');
|
||||
expect(err).toBe(null);
|
||||
expect(data.VersionId).toBe('null');
|
||||
next();
|
||||
}),
|
||||
], err => cb(err));
|
||||
|
|
|
@ -69,7 +69,7 @@ function _assertResponseHtml(response, elemtag, content) {
|
|||
const startingTag = '<ul>';
|
||||
const startIndex = response.indexOf(startingTag);
|
||||
const endIndex = response.indexOf('</ul>');
|
||||
assert(startIndex > -1 && endIndex > -1, 'Did not find ul element');
|
||||
expect(startIndex > -1 && endIndex > -1).toBeTruthy();
|
||||
const ulElem = response.slice(startIndex + startingTag.length,
|
||||
endIndex);
|
||||
content.forEach(item => {
|
||||
|
@ -77,36 +77,29 @@ function _assertResponseHtml(response, elemtag, content) {
|
|||
});
|
||||
} else {
|
||||
const elem = `<${elemtag}>${content}</${elemtag}>`;
|
||||
assert(response.includes(elem),
|
||||
`Expected but did not find '${elem}' in html`);
|
||||
expect(response.includes(elem)).toBeTruthy();
|
||||
}
|
||||
}
|
||||
|
||||
function _assertContainsHtml(responseBody) {
|
||||
assert(responseBody.startsWith('<html>') &&
|
||||
responseBody.includes('</html>'), 'Did not find html tags');
|
||||
expect(responseBody.startsWith('<html>') &&
|
||||
responseBody.includes('</html>')).toBeTruthy();
|
||||
}
|
||||
|
||||
function _assertResponseHtml404(method, response, type) {
|
||||
assert.strictEqual(response.statusCode, 404);
|
||||
expect(response.statusCode).toBe(404);
|
||||
if (method === 'HEAD') {
|
||||
if (type === '404-no-such-bucket') {
|
||||
assert.strictEqual(response.headers['x-amz-error-code'],
|
||||
'NoSuchBucket');
|
||||
expect(response.headers['x-amz-error-code']).toBe('NoSuchBucket');
|
||||
// Need arsenal fixed to remove period at the end
|
||||
// so compatible with aws
|
||||
assert.strictEqual(response.headers['x-amz-error-message'],
|
||||
'The specified bucket does not exist.');
|
||||
expect(response.headers['x-amz-error-message']).toBe('The specified bucket does not exist.');
|
||||
} else if (type === '404-no-such-website-configuration') {
|
||||
assert.strictEqual(response.headers['x-amz-error-code'],
|
||||
'NoSuchWebsiteConfiguration');
|
||||
assert.strictEqual(response.headers['x-amz-error-message'],
|
||||
'The specified bucket does not have a website configuration');
|
||||
expect(response.headers['x-amz-error-code']).toBe('NoSuchWebsiteConfiguration');
|
||||
expect(response.headers['x-amz-error-message']).toBe('The specified bucket does not have a website configuration');
|
||||
} else if (type === '404-not-found') {
|
||||
assert.strictEqual(response.headers['x-amz-error-code'],
|
||||
'NoSuchKey');
|
||||
assert.strictEqual(response.headers['x-amz-error-message'],
|
||||
'The specified key does not exist.');
|
||||
expect(response.headers['x-amz-error-code']).toBe('NoSuchKey');
|
||||
expect(response.headers['x-amz-error-message']).toBe('The specified key does not exist.');
|
||||
} else {
|
||||
throw new Error(`'${type}' is not a recognized 404 ` +
|
||||
'error checked in the WebsiteConfigTester.checkHTML function');
|
||||
|
@ -142,13 +135,11 @@ function _assertResponseHtml404(method, response, type) {
|
|||
}
|
||||
|
||||
function _assertResponseHtml403(method, response, type) {
|
||||
assert.strictEqual(response.statusCode, 403);
|
||||
expect(response.statusCode).toBe(403);
|
||||
if (method === 'HEAD') {
|
||||
if (type === '403-access-denied') {
|
||||
assert.strictEqual(response.headers['x-amz-error-code'],
|
||||
'AccessDenied');
|
||||
assert.strictEqual(response.headers['x-amz-error-message'],
|
||||
'Access Denied');
|
||||
expect(response.headers['x-amz-error-code']).toBe('AccessDenied');
|
||||
expect(response.headers['x-amz-error-message']).toBe('Access Denied');
|
||||
} else if (type !== '403-retrieve-error-document') {
|
||||
throw new Error(`'${type}' is not a recognized 403 ` +
|
||||
'error checked in the WebsiteConfigTester.checkHTML function');
|
||||
|
@ -183,9 +174,9 @@ function _assertResponseHtml403(method, response, type) {
|
|||
|
||||
function _assertResponseHtmlErrorUser(response, type) {
|
||||
if (type === 'error-user') {
|
||||
assert.strictEqual(response.statusCode, 403);
|
||||
expect(response.statusCode).toBe(403);
|
||||
} else if (type === 'error-user-404') {
|
||||
assert.strictEqual(response.statusCode, 404);
|
||||
expect(response.statusCode).toBe(404);
|
||||
}
|
||||
_assertResponseHtml(response.body, 'title',
|
||||
'Error!!');
|
||||
|
@ -194,7 +185,7 @@ function _assertResponseHtmlErrorUser(response, type) {
|
|||
}
|
||||
|
||||
function _assertResponseHtmlIndexUser(response) {
|
||||
assert.strictEqual(response.statusCode, 200);
|
||||
expect(response.statusCode).toBe(200);
|
||||
_assertResponseHtml(response.body, 'title',
|
||||
'Best testing website ever');
|
||||
_assertResponseHtml(response.body, 'h1', 'Welcome to my ' +
|
||||
|
@ -203,11 +194,11 @@ function _assertResponseHtmlIndexUser(response) {
|
|||
|
||||
function _assertResponseHtmlRedirect(response, type, redirectUrl, method) {
|
||||
if (type === 'redirect' || type === 'redirect-user') {
|
||||
assert.strictEqual(response.statusCode, 301);
|
||||
assert.strictEqual(response.body, '');
|
||||
assert.strictEqual(response.headers.location, redirectUrl);
|
||||
expect(response.statusCode).toBe(301);
|
||||
expect(response.body).toBe('');
|
||||
expect(response.headers.location).toBe(redirectUrl);
|
||||
} else if (type === 'redirected-user') {
|
||||
assert.strictEqual(response.statusCode, 200);
|
||||
expect(response.statusCode).toBe(200);
|
||||
if (method === 'HEAD') {
|
||||
return;
|
||||
// no need to check HTML
|
||||
|
@ -270,7 +261,7 @@ class WebsiteConfigTester {
|
|||
static checkHTML(params, callback) {
|
||||
const { method, responseType, auth, url, redirectUrl } = params;
|
||||
_makeWebsiteRequest(auth, method, url, (err, res) => {
|
||||
assert.strictEqual(err, null, `Unexpected request err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (responseType) {
|
||||
if (responseType.startsWith('404')) {
|
||||
_assertResponseHtml404(method, res, responseType);
|
||||
|
@ -315,11 +306,10 @@ class WebsiteConfigTester {
|
|||
_makeWebsiteRequest(auth, 'HEAD', url, (err, res) => {
|
||||
// body should be empty
|
||||
assert.deepStrictEqual(res.body, '');
|
||||
assert.strictEqual(res.statusCode, expectedStatusCode);
|
||||
expect(res.statusCode).toBe(expectedStatusCode);
|
||||
const headers = Object.keys(expectedHeaders);
|
||||
headers.forEach(header => {
|
||||
assert.strictEqual(res.headers[header],
|
||||
expectedHeaders[header]);
|
||||
expect(res.headers[header]).toBe(expectedHeaders[header]);
|
||||
});
|
||||
return cb();
|
||||
});
|
||||
|
|
|
@ -18,13 +18,10 @@ const basicRule = {
|
|||
// Check for the expected error response code and status code.
|
||||
function assertError(err, expectedErr, cb) {
|
||||
if (expectedErr === null) {
|
||||
assert.strictEqual(err, null, `expected no error but got '${err}'`);
|
||||
expect(err).toBe(null);
|
||||
} else {
|
||||
assert.strictEqual(err.code, expectedErr, 'incorrect error response ' +
|
||||
`code: should be '${expectedErr}' but got '${err.code}'`);
|
||||
assert.strictEqual(err.statusCode, errors[expectedErr].code,
|
||||
'incorrect error status code: should be 400 but got ' +
|
||||
`'${err.statusCode}'`);
|
||||
expect(err.code).toBe(expectedErr);
|
||||
expect(err.statusCode).toBe(errors[expectedErr].code);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
|
@ -33,14 +30,14 @@ describe('aws-sdk test delete bucket lifecycle', () => {
|
|||
let s3;
|
||||
let otherAccountS3;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
otherAccountS3 = new BucketUtility('lisa', {}).s3;
|
||||
return done();
|
||||
});
|
||||
|
||||
it('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
test('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
s3.deleteBucketLifecycle({ Bucket: bucket }, err =>
|
||||
assertError(err, 'NoSuchBucket', done));
|
||||
});
|
||||
|
@ -50,23 +47,23 @@ describe('aws-sdk test delete bucket lifecycle', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done => {
|
||||
test('should return AccessDenied if user is not bucket owner', done => {
|
||||
otherAccountS3.deleteBucketLifecycle({ Bucket: bucket },
|
||||
err => assertError(err, 'AccessDenied', done));
|
||||
});
|
||||
|
||||
it('should return no error if no lifecycle config on bucket', done => {
|
||||
test('should return no error if no lifecycle config on bucket', done => {
|
||||
s3.deleteBucketLifecycle({ Bucket: bucket }, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should delete lifecycle configuration from bucket', done => {
|
||||
test('should delete lifecycle configuration from bucket', done => {
|
||||
const params = { Bucket: bucket,
|
||||
LifecycleConfiguration: { Rules: [basicRule] } };
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
s3.deleteBucketLifecycle({ Bucket: bucket }, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket },
|
||||
err =>
|
||||
assertError(err, 'NoSuchLifecycleConfiguration', done));
|
||||
|
|
|
@ -41,7 +41,7 @@ describe('aws-node-sdk test deleteBucketReplication', () => {
|
|||
|
||||
function deleteReplicationAndCheckResponse(bucket, cb) {
|
||||
return s3.deleteBucketReplication({ Bucket: bucket }, (err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data, {});
|
||||
return cb();
|
||||
});
|
||||
|
@ -55,17 +55,17 @@ describe('aws-node-sdk test deleteBucketReplication', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return empty object if bucket has no replication config', done =>
|
||||
test('should return empty object if bucket has no replication config', done =>
|
||||
deleteReplicationAndCheckResponse(bucket, done));
|
||||
|
||||
it('should delete a bucket replication config when it has one', done =>
|
||||
test('should delete a bucket replication config when it has one', done =>
|
||||
series([
|
||||
next => putVersioningOnBucket(bucket, next),
|
||||
next => putReplicationOnBucket(bucket, next),
|
||||
next => deleteReplicationAndCheckResponse(bucket, next),
|
||||
], done));
|
||||
|
||||
it('should return ReplicationConfigurationNotFoundError if getting ' +
|
||||
test('should return ReplicationConfigurationNotFoundError if getting ' +
|
||||
'replication config after it has been deleted', done =>
|
||||
series([
|
||||
next => putVersioningOnBucket(bucket, next),
|
||||
|
@ -81,16 +81,16 @@ describe('aws-node-sdk test deleteBucketReplication', () => {
|
|||
}),
|
||||
next => deleteReplicationAndCheckResponse(bucket, next),
|
||||
next => s3.getBucketReplication({ Bucket: bucket }, err => {
|
||||
assert(errors.ReplicationConfigurationNotFoundError[err.code]);
|
||||
expect(errors.ReplicationConfigurationNotFoundError[err.code]).toBeTruthy();
|
||||
return next();
|
||||
}),
|
||||
], done));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done =>
|
||||
test('should return AccessDenied if user is not bucket owner', done =>
|
||||
otherAccountS3.deleteBucketReplication({ Bucket: bucket }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -26,11 +26,11 @@ describe('DELETE bucket cors', () => {
|
|||
const otherAccountS3 = otherAccountBucketUtility.s3;
|
||||
|
||||
describe('without existing bucket', () => {
|
||||
it('should return NoSuchBucket', done => {
|
||||
test('should return NoSuchBucket', done => {
|
||||
s3.deleteBucketCors({ Bucket: bucketName }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'NoSuchBucket');
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('NoSuchBucket');
|
||||
expect(err.statusCode).toBe(404);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -41,14 +41,12 @@ describe('DELETE bucket cors', () => {
|
|||
afterEach(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
describe('without existing cors configuration', () => {
|
||||
it('should return a 204 response', done => {
|
||||
test('should return a 204 response', done => {
|
||||
s3.deleteBucketCors({ Bucket: bucketName },
|
||||
function deleteBucketCors(err) {
|
||||
const statusCode = this.httpResponse.statusCode;
|
||||
assert.strictEqual(statusCode, 204,
|
||||
`Found unexpected statusCode ${statusCode}`);
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(statusCode).toBe(204);
|
||||
expect(err).toBe(null);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -60,18 +58,15 @@ describe('DELETE bucket cors', () => {
|
|||
CORSConfiguration: sampleCors }, done);
|
||||
});
|
||||
|
||||
it('should delete bucket configuration successfully', done => {
|
||||
test('should delete bucket configuration successfully', done => {
|
||||
s3.deleteBucketCors({ Bucket: bucketName },
|
||||
function deleteBucketCors(err) {
|
||||
const statusCode = this.httpResponse.statusCode;
|
||||
assert.strictEqual(statusCode, 204,
|
||||
`Found unexpected statusCode ${statusCode}`);
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(statusCode).toBe(204);
|
||||
expect(err).toBe(null);
|
||||
s3.getBucketCors({ Bucket: bucketName }, err => {
|
||||
assert.strictEqual(err.code,
|
||||
'NoSuchCORSConfiguration');
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err.code).toBe('NoSuchCORSConfiguration');
|
||||
expect(err.statusCode).toBe(404);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -87,9 +82,9 @@ describe('DELETE bucket cors', () => {
|
|||
'owner', done => {
|
||||
otherAccountS3.deleteBucketCors({ Bucket: bucketName },
|
||||
err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,11 +14,11 @@ describe('DELETE bucket website', () => {
|
|||
const otherAccountS3 = otherAccountBucketUtility.s3;
|
||||
|
||||
describe('without existing bucket', () => {
|
||||
it('should return NoSuchBucket', done => {
|
||||
test('should return NoSuchBucket', done => {
|
||||
s3.deleteBucketWebsite({ Bucket: bucketName }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'NoSuchBucket');
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('NoSuchBucket');
|
||||
expect(err.statusCode).toBe(404);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -29,15 +29,13 @@ describe('DELETE bucket website', () => {
|
|||
afterEach(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
describe('without existing configuration', () => {
|
||||
it('should return a 204 response', done => {
|
||||
test('should return a 204 response', done => {
|
||||
const request =
|
||||
s3.deleteBucketWebsite({ Bucket: bucketName }, err => {
|
||||
const statusCode =
|
||||
request.response.httpResponse.statusCode;
|
||||
assert.strictEqual(statusCode, 204,
|
||||
`Found unexpected statusCode ${statusCode}`);
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(statusCode).toBe(204);
|
||||
expect(err).toBe(null);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -50,21 +48,19 @@ describe('DELETE bucket website', () => {
|
|||
WebsiteConfiguration: config }, done);
|
||||
});
|
||||
|
||||
it('should delete bucket configuration successfully', done => {
|
||||
test('should delete bucket configuration successfully', done => {
|
||||
s3.deleteBucketWebsite({ Bucket: bucketName }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner',
|
||||
done => {
|
||||
test('should return AccessDenied if user is not bucket owner', done => {
|
||||
otherAccountS3.deleteBucketWebsite({ Bucket: bucketName },
|
||||
err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,14 +26,14 @@ const tests = [
|
|||
// ETag should include quotes around value
|
||||
const emptyObjectHash =
|
||||
'"d41d8cd98f00b204e9800998ecf8427e"';
|
||||
assert.equal(data.Name, Bucket, 'Bucket name mismatch');
|
||||
assert.deepEqual(keys, [
|
||||
expect(data.Name).toEqual(Bucket);
|
||||
expect(keys).toEqual([
|
||||
'testA/',
|
||||
'testA/test.json',
|
||||
'testA/test/test.json',
|
||||
'testB/',
|
||||
'testB/test.json',
|
||||
], 'Bucket content mismatch');
|
||||
]);
|
||||
assert.deepStrictEqual(data.Contents[0].ETag,
|
||||
emptyObjectHash, 'Object hash mismatch');
|
||||
},
|
||||
|
@ -51,11 +51,11 @@ const tests = [
|
|||
listObjectParams: Bucket => ({ Bucket, Delimiter: '/' }),
|
||||
assertions: (data, Bucket) => {
|
||||
const prefixes = data.CommonPrefixes.map(cp => cp.Prefix);
|
||||
assert.equal(data.Name, Bucket, 'Bucket name mismatch');
|
||||
assert.deepEqual(prefixes, [
|
||||
expect(data.Name).toEqual(Bucket);
|
||||
expect(prefixes).toEqual([
|
||||
'testA/',
|
||||
'testB/',
|
||||
], 'Bucket content mismatch');
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -69,11 +69,11 @@ const tests = [
|
|||
listObjectParams: Bucket => ({ Bucket, Delimiter: '%' }),
|
||||
assertions: data => {
|
||||
const prefixes = data.CommonPrefixes.map(cp => cp.Prefix);
|
||||
assert.deepEqual(prefixes, [
|
||||
expect(prefixes).toEqual([
|
||||
'testA%',
|
||||
'testB%',
|
||||
'testC%',
|
||||
], 'Bucket content mismatch');
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ const tests = [
|
|||
listObjectParams: Bucket => ({ Bucket }),
|
||||
assertions: (data, Bucket) => {
|
||||
const keys = data.Contents.map(object => object.Key);
|
||||
assert.equal(data.Name, Bucket, 'Bucket name mismatch');
|
||||
assert.deepEqual(keys, [
|
||||
expect(data.Name).toEqual(Bucket);
|
||||
expect(keys).toEqual([
|
||||
/* These object names are intentionally listed in a
|
||||
different order than they were created to additionally
|
||||
test that they are listed alphabetically. */
|
||||
|
@ -101,7 +101,7 @@ const tests = [
|
|||
'whiteSpace/',
|
||||
'whiteSpace/one whiteSpace',
|
||||
'whiteSpace/two white spaces',
|
||||
], 'Bucket content mismatch');
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -202,8 +202,8 @@ const tests = [
|
|||
listObjectParams: Bucket => ({ Bucket }),
|
||||
assertions: (data, Bucket) => {
|
||||
const keys = data.Contents.map(object => object.Key);
|
||||
assert.equal(data.Name, Bucket, 'Bucket name mismatch');
|
||||
assert.deepEqual(keys, [
|
||||
expect(data.Name).toEqual(Bucket);
|
||||
expect(keys).toEqual([
|
||||
/* These object names are intentionally listed in a
|
||||
different order than they were created to additionally
|
||||
test that they are listed alphabetically. */
|
||||
|
@ -265,7 +265,7 @@ const tests = [
|
|||
'日japaneseMountainObjTitle',
|
||||
'日japaneseMountainObjTitle/objTitleA',
|
||||
'日japaneseMountainObjTitle/日japaneseMountainObjTitle',
|
||||
], 'Bucket content mismatch');
|
||||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
let bucketUtil;
|
||||
let bucketName;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
bucketUtil = new BucketUtility();
|
||||
bucketUtil.createRandom(1)
|
||||
.then(created => {
|
||||
|
@ -301,19 +301,19 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
.catch(done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
bucketUtil.deleteOne(bucketName)
|
||||
.then(() => done())
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should return 403 and AccessDenied on a private bucket', done => {
|
||||
test('should return 403 and AccessDenied on a private bucket', done => {
|
||||
const params = { Bucket: bucketName };
|
||||
bucketUtil.s3
|
||||
.makeUnauthenticatedRequest('listObjects', params, error => {
|
||||
assert(error);
|
||||
assert.strictEqual(error.statusCode, 403);
|
||||
assert.strictEqual(error.code, 'AccessDenied');
|
||||
expect(error).toBeTruthy();
|
||||
expect(error.statusCode).toBe(403);
|
||||
expect(error.code).toBe('AccessDenied');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -323,7 +323,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
let bucketUtil;
|
||||
let bucketName;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
bucketUtil.createRandom(1)
|
||||
.then(created => {
|
||||
|
@ -333,7 +333,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
.catch(done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
bucketUtil.deleteOne(bucketName).then(() => done()).catch(done);
|
||||
});
|
||||
|
||||
|
@ -342,7 +342,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
tests.forEach(test => {
|
||||
it(`should ${test.name}`, done => {
|
||||
test(`should ${test.name}`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
|
||||
|
@ -367,7 +367,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
tests.forEach(test => {
|
||||
it(`v2 should ${test.name}`, done => {
|
||||
test(`v2 should ${test.name}`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
|
||||
|
@ -392,7 +392,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as Prefix`, done => {
|
||||
test(`should list objects with key ${k} as Prefix`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }];
|
||||
|
@ -416,7 +416,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as Marker`, done => {
|
||||
test(`should list objects with key ${k} as Marker`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }];
|
||||
|
@ -440,7 +440,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as NextMarker`, done => {
|
||||
test(`should list objects with key ${k} as NextMarker`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }, { Bucket, Key: 'zzz' }];
|
||||
|
@ -457,7 +457,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
}
|
||||
return data;
|
||||
}).then(data => {
|
||||
assert.strictEqual(data.NextMarker, k);
|
||||
expect(data.NextMarker).toBe(k);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
|
@ -465,7 +465,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as StartAfter`, done => {
|
||||
test(`should list objects with key ${k} as StartAfter`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }];
|
||||
|
@ -490,8 +490,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as ContinuationToken`,
|
||||
done => {
|
||||
test(`should list objects with key ${k} as ContinuationToken`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }];
|
||||
|
@ -517,8 +516,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
});
|
||||
|
||||
['&', '"quot', '\'apos', '<lt', '>gt'].forEach(k => {
|
||||
it(`should list objects with key ${k} as NextContinuationToken`,
|
||||
done => {
|
||||
test(`should list objects with key ${k} as NextContinuationToken`, done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [{ Bucket, Key: k }, { Bucket, Key: 'zzz' }];
|
||||
|
@ -534,8 +532,7 @@ describe('GET Bucket - AWS.S3.listObjects', () => {
|
|||
}
|
||||
return data;
|
||||
}).then(data => {
|
||||
assert.strictEqual(
|
||||
decryptToken(data.NextContinuationToken), k);
|
||||
expect(decryptToken(data.NextContinuationToken)).toBe(k);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
|
|
|
@ -10,13 +10,10 @@ const bucket = 'lifecycletestbucket';
|
|||
// Check for the expected error response code and status code.
|
||||
function assertError(err, expectedErr, cb) {
|
||||
if (expectedErr === null) {
|
||||
assert.strictEqual(err, null, `expected no error but got '${err}'`);
|
||||
expect(err).toBe(null);
|
||||
} else {
|
||||
assert.strictEqual(err.code, expectedErr, 'incorrect error response ' +
|
||||
`code: should be '${expectedErr}' but got '${err.code}'`);
|
||||
assert.strictEqual(err.statusCode, errors[expectedErr].code,
|
||||
'incorrect error status code: should be 400 but got ' +
|
||||
`'${err.statusCode}'`);
|
||||
expect(err.code).toBe(expectedErr);
|
||||
expect(err.statusCode).toBe(errors[expectedErr].code);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
|
@ -25,14 +22,14 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
let s3;
|
||||
let otherAccountS3;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
otherAccountS3 = new BucketUtility('lisa', {}).s3;
|
||||
return done();
|
||||
});
|
||||
|
||||
it('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
test('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket }, err =>
|
||||
assertError(err, 'NoSuchBucket', done));
|
||||
});
|
||||
|
@ -42,19 +39,19 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done => {
|
||||
test('should return AccessDenied if user is not bucket owner', done => {
|
||||
otherAccountS3.getBucketLifecycleConfiguration({ Bucket: bucket },
|
||||
err => assertError(err, 'AccessDenied', done));
|
||||
});
|
||||
|
||||
it('should return NoSuchLifecycleConfiguration error if no lifecycle ' +
|
||||
test('should return NoSuchLifecycleConfiguration error if no lifecycle ' +
|
||||
'put to bucket', done => {
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket }, err => {
|
||||
assertError(err, 'NoSuchLifecycleConfiguration', done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should get bucket lifecycle config with top-level prefix', done =>
|
||||
test('should get bucket lifecycle config with top-level prefix', done =>
|
||||
s3.putBucketLifecycleConfiguration({
|
||||
Bucket: bucket,
|
||||
LifecycleConfiguration: {
|
||||
|
@ -66,12 +63,11 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
}],
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Err putting lifecycle config: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Error getting lifecycle config: ' +
|
||||
`${err}`);
|
||||
assert.strictEqual(res.Rules.length, 1);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Rules.length).toBe(1);
|
||||
assert.deepStrictEqual(res.Rules[0], {
|
||||
Expiration: { Days: 1 },
|
||||
ID: 'test-id',
|
||||
|
@ -84,7 +80,7 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should get bucket lifecycle config with filter prefix', done =>
|
||||
test('should get bucket lifecycle config with filter prefix', done =>
|
||||
s3.putBucketLifecycleConfiguration({
|
||||
Bucket: bucket,
|
||||
LifecycleConfiguration: {
|
||||
|
@ -96,12 +92,11 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
}],
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Err putting lifecycle config: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Error getting lifecycle config: ' +
|
||||
`${err}`);
|
||||
assert.strictEqual(res.Rules.length, 1);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Rules.length).toBe(1);
|
||||
assert.deepStrictEqual(res.Rules[0], {
|
||||
Expiration: { Days: 1 },
|
||||
ID: 'test-id',
|
||||
|
@ -114,8 +109,7 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should get bucket lifecycle config with filter prefix and tags',
|
||||
done =>
|
||||
test('should get bucket lifecycle config with filter prefix and tags', done =>
|
||||
s3.putBucketLifecycleConfiguration({
|
||||
Bucket: bucket,
|
||||
LifecycleConfiguration: {
|
||||
|
@ -137,12 +131,11 @@ describe('aws-sdk test get bucket lifecycle', () => {
|
|||
}],
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Err putting lifecycle config: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getBucketLifecycleConfiguration({ Bucket: bucket },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Error getting lifecycle config: ' +
|
||||
`${err}`);
|
||||
assert.strictEqual(res.Rules.length, 1);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Rules.length).toBe(1);
|
||||
assert.deepStrictEqual(res.Rules[0], {
|
||||
Expiration: { Days: 1 },
|
||||
ID: 'test-id',
|
||||
|
|
|
@ -42,14 +42,15 @@ describe('aws-node-sdk test getBucketReplication', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it("should return 'ReplicationConfigurationNotFoundError' if bucket does " +
|
||||
test("should return 'ReplicationConfigurationNotFoundError' if bucket does " +
|
||||
'not have a replication configuration', done =>
|
||||
s3.getBucketReplication({ Bucket: bucket }, err => {
|
||||
assert(errors.ReplicationConfigurationNotFoundError[err.code]);
|
||||
expect(errors.ReplicationConfigurationNotFoundError[err.code]).toBeTruthy();
|
||||
return done();
|
||||
}));
|
||||
|
||||
it('should get the replication configuration that was put on a bucket',
|
||||
test(
|
||||
'should get the replication configuration that was put on a bucket',
|
||||
done => s3.putBucketReplication({
|
||||
Bucket: bucket,
|
||||
ReplicationConfiguration: replicationConfig,
|
||||
|
@ -67,13 +68,14 @@ describe('aws-node-sdk test getBucketReplication', () => {
|
|||
assert.deepStrictEqual(data, expectedObj);
|
||||
return done();
|
||||
});
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done =>
|
||||
test('should return AccessDenied if user is not bucket owner', done =>
|
||||
otherAccountS3.getBucketReplication({ Bucket: bucket }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -25,17 +25,16 @@ describe('GET bucket cors', () => {
|
|||
AllowedHeaders: ['*'],
|
||||
MaxAgeSeconds: 3000 },
|
||||
] };
|
||||
before(() =>
|
||||
beforeAll(() =>
|
||||
s3.createBucketAsync({ Bucket: bucketName })
|
||||
.then(() => s3.putBucketCorsAsync({
|
||||
Bucket: bucketName,
|
||||
CORSConfiguration: sampleCors,
|
||||
})));
|
||||
|
||||
it('should return cors configuration successfully', done => {
|
||||
test('should return cors configuration successfully', done => {
|
||||
s3.getBucketCors({ Bucket: bucketName }, (err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.CORSRules,
|
||||
sampleCors.CORSRules);
|
||||
return done();
|
||||
|
@ -50,18 +49,16 @@ describe('GET bucket cors', () => {
|
|||
AllowedOrigins: ['http://www.example.com'],
|
||||
AllowedHeaders: [testValue] },
|
||||
] };
|
||||
before(() =>
|
||||
beforeAll(() =>
|
||||
s3.createBucketAsync({ Bucket: bucketName })
|
||||
.then(() => s3.putBucketCorsAsync({
|
||||
Bucket: bucketName,
|
||||
CORSConfiguration: sampleCors,
|
||||
})));
|
||||
|
||||
it('should be preserved when putting / getting cors resource',
|
||||
done => {
|
||||
test('should be preserved when putting / getting cors resource', done => {
|
||||
s3.getBucketCors({ Bucket: bucketName }, (err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.CORSRules[0].AllowedHeaders,
|
||||
sampleCors.CORSRules[0].AllowedHeaders);
|
||||
return done();
|
||||
|
@ -74,18 +71,16 @@ describe('GET bucket cors', () => {
|
|||
{ AllowedMethods: ['PUT', 'POST', 'DELETE'],
|
||||
AllowedOrigins: ['http://www.example.com'] },
|
||||
] };
|
||||
before(() =>
|
||||
beforeAll(() =>
|
||||
s3.createBucketAsync({ Bucket: bucketName })
|
||||
.then(() => s3.putBucketCorsAsync({
|
||||
Bucket: bucketName,
|
||||
CORSConfiguration: sampleCors,
|
||||
})));
|
||||
|
||||
it('should be preserved when retrieving cors resource',
|
||||
done => {
|
||||
test('should be preserved when retrieving cors resource', done => {
|
||||
s3.getBucketCors({ Bucket: bucketName }, (err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.CORSRules[0].AllowedMethods,
|
||||
sampleCors.CORSRules[0].AllowedMethods);
|
||||
return done();
|
||||
|
@ -94,7 +89,7 @@ describe('GET bucket cors', () => {
|
|||
});
|
||||
|
||||
describe('on bucket without cors configuration', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
process.stdout.write('about to create bucket\n');
|
||||
s3.createBucket({ Bucket: bucketName }, err => {
|
||||
if (err) {
|
||||
|
@ -105,11 +100,11 @@ describe('GET bucket cors', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return NoSuchCORSConfiguration', done => {
|
||||
test('should return NoSuchCORSConfiguration', done => {
|
||||
s3.getBucketCors({ Bucket: bucketName }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'NoSuchCORSConfiguration');
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('NoSuchCORSConfiguration');
|
||||
expect(err.statusCode).toBe(404);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,22 +23,20 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
return;
|
||||
}
|
||||
describe(`with location: ${location}`, () => {
|
||||
before(done => s3.createBucketAsync(
|
||||
beforeAll(done => s3.createBucketAsync(
|
||||
{
|
||||
Bucket: bucketName,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: location,
|
||||
},
|
||||
}, done));
|
||||
after(() => bucketUtil.deleteOne(bucketName));
|
||||
afterAll(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
it(`should return location configuration: ${location} ` +
|
||||
'successfully',
|
||||
done => {
|
||||
test(`should return location configuration: ${location} ` +
|
||||
'successfully', done => {
|
||||
s3.getBucketLocation({ Bucket: bucketName },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.LocationConstraint,
|
||||
location);
|
||||
return done();
|
||||
|
@ -48,7 +46,7 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
});
|
||||
|
||||
describe('with location us-east-1', () => {
|
||||
before(done => s3.createBucketAsync(
|
||||
beforeAll(done => s3.createBucketAsync(
|
||||
{
|
||||
Bucket: bucketName,
|
||||
CreateBucketConfiguration: {
|
||||
|
@ -56,12 +54,10 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
},
|
||||
}, done));
|
||||
afterEach(() => bucketUtil.deleteOne(bucketName));
|
||||
it('should return empty location',
|
||||
done => {
|
||||
test('should return empty location', done => {
|
||||
s3.getBucketLocation({ Bucket: bucketName },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.LocationConstraint, '');
|
||||
return done();
|
||||
});
|
||||
|
@ -69,7 +65,7 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
});
|
||||
|
||||
describe('without location configuration', () => {
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Deleting bucket\n');
|
||||
return bucketUtil.deleteOne(bucketName)
|
||||
.catch(err => {
|
||||
|
@ -78,15 +74,14 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return request endpoint as location', done => {
|
||||
test('should return request endpoint as location', done => {
|
||||
process.stdout.write('Creating bucket');
|
||||
const request = s3.createBucket({ Bucket: bucketName });
|
||||
request.on('build', () => {
|
||||
request.httpRequest.body = '';
|
||||
});
|
||||
request.send(err => {
|
||||
assert.strictEqual(err, null, 'Error creating bucket: ' +
|
||||
`${err}`);
|
||||
expect(err).toBe(null);
|
||||
const host = request.service.endpoint.hostname;
|
||||
let endpoint = config.restEndpoints[host];
|
||||
// s3 actually returns '' for us-east-1
|
||||
|
@ -95,9 +90,8 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
}
|
||||
s3.getBucketLocation({ Bucket: bucketName },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null, 'Expected succes, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.strictEqual(data.LocationConstraint, endpoint);
|
||||
expect(err).toBe(null);
|
||||
expect(data.LocationConstraint).toBe(endpoint);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -105,22 +99,21 @@ describeSkipAWS('GET bucket location ', () => {
|
|||
});
|
||||
|
||||
describe('with location configuration', () => {
|
||||
before(done => s3.createBucketAsync(
|
||||
beforeAll(done => s3.createBucketAsync(
|
||||
{
|
||||
Bucket: bucketName,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: 'us-east-1',
|
||||
},
|
||||
}, done));
|
||||
after(() => bucketUtil.deleteOne(bucketName));
|
||||
afterAll(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner',
|
||||
done => {
|
||||
test('should return AccessDenied if user is not bucket owner', done => {
|
||||
otherAccountS3.getBucketLocation({ Bucket: bucketName },
|
||||
err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -30,17 +30,16 @@ describe('GET bucket website', () => {
|
|||
afterEach(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
describe('with existing bucket configuration', () => {
|
||||
before(() =>
|
||||
beforeAll(() =>
|
||||
s3.createBucketAsync({ Bucket: bucketName })
|
||||
.then(() => s3.putBucketWebsiteAsync({
|
||||
Bucket: bucketName,
|
||||
WebsiteConfiguration: config,
|
||||
})));
|
||||
|
||||
it('should return bucket website xml successfully', done => {
|
||||
test('should return bucket website xml successfully', done => {
|
||||
s3.getBucketWebsite({ Bucket: bucketName }, (err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const configObject = Object.assign({}, config);
|
||||
assert.deepStrictEqual(data, configObject);
|
||||
return done();
|
||||
|
@ -49,7 +48,7 @@ describe('GET bucket website', () => {
|
|||
});
|
||||
|
||||
describe('on bucket without website configuration', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
process.stdout.write('about to create bucket\n');
|
||||
s3.createBucket({ Bucket: bucketName }, err => {
|
||||
if (err) {
|
||||
|
@ -60,11 +59,11 @@ describe('GET bucket website', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return NoSuchWebsiteConfiguration', done => {
|
||||
test('should return NoSuchWebsiteConfiguration', done => {
|
||||
s3.getBucketWebsite({ Bucket: bucketName }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'NoSuchWebsiteConfiguration');
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('NoSuchWebsiteConfiguration');
|
||||
expect(err.statusCode).toBe(404);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,20 +9,21 @@ describe('HEAD bucket', () => {
|
|||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
|
||||
|
||||
it('should return an error to a head request without a bucket name',
|
||||
test(
|
||||
'should return an error to a head request without a bucket name',
|
||||
done => {
|
||||
s3.headBucket({ Bucket: '' }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 405);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(405);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -48,7 +48,7 @@ const objects = [
|
|||
|
||||
describe('Listing corner cases tests', () => {
|
||||
let s3;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new AWS.S3(config);
|
||||
s3.createBucket(
|
||||
|
@ -64,7 +64,7 @@ describe('Listing corner cases tests', () => {
|
|||
}, done);
|
||||
});
|
||||
});
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3.listObjects({ Bucket }, (err, data) => {
|
||||
async.each(data.Contents, (o, next) => {
|
||||
s3.deleteObject({ Bucket, Key: o.Key }, next);
|
||||
|
@ -73,9 +73,9 @@ describe('Listing corner cases tests', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
it('should list everything', done => {
|
||||
test('should list everything', done => {
|
||||
s3.listObjects({ Bucket }, (err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
|
@ -100,14 +100,14 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with valid marker', done => {
|
||||
test('should list with valid marker', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
Marker: 'notes/summer/1.txt',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
|
@ -122,14 +122,14 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with unexpected marker', done => {
|
||||
test('should list with unexpected marker', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
Marker: 'zzzz',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
Marker: 'zzzz',
|
||||
|
@ -143,7 +143,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with unexpected marker and prefix', done => {
|
||||
test('should list with unexpected marker and prefix', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -151,7 +151,7 @@ describe('Listing corner cases tests', () => {
|
|||
Prefix: 'notes/summer/',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
Marker: 'notes/summer0',
|
||||
|
@ -165,13 +165,13 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with MaxKeys', done => {
|
||||
test('should list with MaxKeys', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
MaxKeys: 3,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: '',
|
||||
|
@ -188,13 +188,13 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with big MaxKeys', done => {
|
||||
test('should list with big MaxKeys', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
MaxKeys: 15000,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: '',
|
||||
|
@ -218,13 +218,13 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with delimiter', done => {
|
||||
test('should list with delimiter', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: '',
|
||||
|
@ -239,13 +239,13 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with long delimiter', done => {
|
||||
test('should list with long delimiter', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: 'notes/summer',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: '',
|
||||
|
@ -267,14 +267,14 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with delimiter and prefix related to #147', done => {
|
||||
test('should list with delimiter and prefix related to #147', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
Prefix: 'notes/',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: '',
|
||||
|
@ -296,7 +296,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with prefix and marker related to #147', done => {
|
||||
test('should list with prefix and marker related to #147', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -304,7 +304,7 @@ describe('Listing corner cases tests', () => {
|
|||
Marker: 'notes/year.txt',
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/year.txt',
|
||||
|
@ -319,7 +319,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with all parameters 1 of 5', done => {
|
||||
test('should list with all parameters 1 of 5', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -328,7 +328,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/',
|
||||
|
@ -344,7 +344,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with all parameters 2 of 5', done => {
|
||||
test('should list with all parameters 2 of 5', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -353,7 +353,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/spring/',
|
||||
|
@ -369,7 +369,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with all parameters 3 of 5', done => {
|
||||
test('should list with all parameters 3 of 5', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -378,7 +378,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/summer/',
|
||||
|
@ -394,7 +394,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with all parameters 4 of 5', done => {
|
||||
test('should list with all parameters 4 of 5', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -403,7 +403,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/year.txt',
|
||||
|
@ -419,7 +419,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should list with all parameters 5 of 5', done => {
|
||||
test('should list with all parameters 5 of 5', done => {
|
||||
s3.listObjects(
|
||||
{ Bucket,
|
||||
Delimiter: '/',
|
||||
|
@ -428,7 +428,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
Marker: 'notes/yore.rs',
|
||||
|
@ -443,7 +443,7 @@ describe('Listing corner cases tests', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should ends listing on last common prefix', done => {
|
||||
test('should ends listing on last common prefix', done => {
|
||||
s3.putObject({
|
||||
Bucket,
|
||||
Key: 'notes/zaphod/TheFourth.txt',
|
||||
|
@ -458,7 +458,7 @@ describe('Listing corner cases tests', () => {
|
|||
MaxKeys: 1,
|
||||
},
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
|
|
|
@ -24,14 +24,14 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
s3 = new S3(config);
|
||||
});
|
||||
|
||||
it('should return 403 and AccessDenied', done => {
|
||||
test('should return 403 and AccessDenied', done => {
|
||||
const params = { Bucket: 'mybucket' };
|
||||
|
||||
s3.makeUnauthenticatedRequest('createBucket', params, error => {
|
||||
assert(error);
|
||||
expect(error).toBeTruthy();
|
||||
|
||||
assert.strictEqual(error.statusCode, 403);
|
||||
assert.strictEqual(error.code, 'AccessDenied');
|
||||
expect(error.statusCode).toBe(403);
|
||||
expect(error.code).toBe('AccessDenied');
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -41,7 +41,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
withV4(sigCfg => {
|
||||
let bucketUtil;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
});
|
||||
|
||||
|
@ -62,7 +62,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
'provided.', done => {
|
||||
bucketUtil.s3.createBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
it('should return a 200 if us-east behavior', done => {
|
||||
test('should return a 200 if us-east behavior', done => {
|
||||
bucketUtil.s3.createBucket({
|
||||
Bucket: bucketName,
|
||||
CreateBucketConfiguration: {
|
||||
|
@ -70,17 +70,16 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
},
|
||||
}, done);
|
||||
});
|
||||
it('should return a 409 if us-west behavior', done => {
|
||||
test('should return a 409 if us-west behavior', done => {
|
||||
bucketUtil.s3.createBucket({
|
||||
Bucket: bucketName,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: 'scality-us-west-1',
|
||||
},
|
||||
}, error => {
|
||||
assert.notEqual(error, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(error.code, 'BucketAlreadyOwnedByYou');
|
||||
assert.strictEqual(error.statusCode, 409);
|
||||
expect(error).not.toEqual(null);
|
||||
expect(error.code).toBe('BucketAlreadyOwnedByYou');
|
||||
expect(error.statusCode).toBe(409);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -89,7 +88,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
describe('bucket naming restriction', () => {
|
||||
let testFn;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
testFn = (bucketName, done, errStatus, errCode) => {
|
||||
const expectedStatus = errStatus || 400;
|
||||
const expectedCode = errCode || 'InvalidBucketName';
|
||||
|
@ -102,9 +101,8 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
return done(e);
|
||||
})
|
||||
.catch(error => {
|
||||
assert.strictEqual(error.code, expectedCode);
|
||||
assert.strictEqual(error.statusCode,
|
||||
expectedStatus);
|
||||
expect(error.code).toBe(expectedCode);
|
||||
expect(error.statusCode).toBe(expectedStatus);
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
@ -115,23 +113,22 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
// Hence it skips some of test suites.
|
||||
const itSkipIfAWS = process.env.AWS_ON_AIR ? it.skip : it;
|
||||
|
||||
it('should return 405 if empty name', done => {
|
||||
test('should return 405 if empty name', done => {
|
||||
const shortName = '';
|
||||
|
||||
testFn(shortName, done, 405, 'MethodNotAllowed');
|
||||
});
|
||||
|
||||
it('should return 400 if name is shorter than 3 chars', done => {
|
||||
test('should return 400 if name is shorter than 3 chars', done => {
|
||||
const shortName = 'as';
|
||||
|
||||
testFn(shortName, done);
|
||||
});
|
||||
|
||||
it('should return 403 if name is reserved (e.g., METADATA)',
|
||||
done => {
|
||||
const reservedName = 'METADATA';
|
||||
testFn(reservedName, done, 403, 'AccessDenied');
|
||||
});
|
||||
test('should return 403 if name is reserved (e.g., METADATA)', done => {
|
||||
const reservedName = 'METADATA';
|
||||
testFn(reservedName, done, 403, 'AccessDenied');
|
||||
});
|
||||
|
||||
itSkipIfAWS('should return 400 if name is longer than 63 chars',
|
||||
done => {
|
||||
|
@ -154,7 +151,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
}
|
||||
);
|
||||
|
||||
it('should return 400 if name ends with period', done => {
|
||||
test('should return 400 if name ends with period', done => {
|
||||
const invalidName = 'myawsbucket.';
|
||||
testFn(invalidName, done);
|
||||
});
|
||||
|
@ -167,7 +164,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
}
|
||||
);
|
||||
|
||||
it('should return 400 if name has special chars', done => {
|
||||
test('should return 400 if name has special chars', done => {
|
||||
const invalidName = 'my.#s3bucket';
|
||||
testFn(invalidName, done);
|
||||
});
|
||||
|
@ -177,27 +174,31 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
function _test(name, done) {
|
||||
bucketUtil.s3.createBucket({ Bucket: name }, (err, res) => {
|
||||
assert.ifError(err);
|
||||
assert(res.Location, 'No Location in response');
|
||||
expect(res.Location).toBeTruthy();
|
||||
assert.deepStrictEqual(res.Location, `/${name}`,
|
||||
'Wrong Location header');
|
||||
bucketUtil.deleteOne(name).then(() => done()).catch(done);
|
||||
});
|
||||
}
|
||||
it('should create bucket if name is valid', done =>
|
||||
test('should create bucket if name is valid', done =>
|
||||
_test('scality-very-valid-bucket-name', done));
|
||||
|
||||
it('should create bucket if name is some prefix and an IP address',
|
||||
done => _test('prefix-192.168.5.4', done));
|
||||
test(
|
||||
'should create bucket if name is some prefix and an IP address',
|
||||
done => _test('prefix-192.168.5.4', done)
|
||||
);
|
||||
|
||||
it('should create bucket if name is an IP address with some suffix',
|
||||
done => _test('192.168.5.4-suffix', done));
|
||||
test(
|
||||
'should create bucket if name is an IP address with some suffix',
|
||||
done => _test('192.168.5.4-suffix', done)
|
||||
);
|
||||
});
|
||||
Object.keys(locationConstraints).forEach(
|
||||
location => {
|
||||
describeSkipAWS(`bucket creation with location: ${location}`,
|
||||
() => {
|
||||
after(() => bucketUtil.deleteOne(bucketName));
|
||||
it(`should create bucket with location: ${location}`, done => {
|
||||
afterAll(() => bucketUtil.deleteOne(bucketName));
|
||||
test(`should create bucket with location: ${location}`, done => {
|
||||
bucketUtil.s3.createBucketAsync(
|
||||
{
|
||||
Bucket: bucketName,
|
||||
|
@ -210,7 +211,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
});
|
||||
|
||||
describe('bucket creation with invalid location', () => {
|
||||
it('should return errors InvalidLocationConstraint', done => {
|
||||
test('should return errors InvalidLocationConstraint', done => {
|
||||
bucketUtil.s3.createBucketAsync(
|
||||
{
|
||||
Bucket: bucketName,
|
||||
|
@ -218,18 +219,17 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
LocationConstraint: 'coco',
|
||||
},
|
||||
}, err => {
|
||||
assert.strictEqual(err.code,
|
||||
'InvalidLocationConstraint');
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
expect(err.code).toBe('InvalidLocationConstraint');
|
||||
expect(err.statusCode).toBe(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('bucket creation with ingestion location', () => {
|
||||
after(done =>
|
||||
afterAll(done =>
|
||||
bucketUtil.s3.deleteBucket({ Bucket: bucketName }, done));
|
||||
it('should create bucket with location and ingestion', done => {
|
||||
test('should create bucket with location and ingestion', done => {
|
||||
async.waterfall([
|
||||
next => bucketUtil.s3.createBucketAsync(
|
||||
{
|
||||
|
@ -239,7 +239,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
},
|
||||
}, (err, res) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res.Location, `/${bucketName}`);
|
||||
expect(res.Location).toBe(`/${bucketName}`);
|
||||
return next();
|
||||
}),
|
||||
next => bucketUtil.s3.getBucketLocation(
|
||||
|
@ -247,13 +247,13 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
|
|||
Bucket: bucketName,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res.LocationConstraint, 'us-east-2');
|
||||
expect(res.LocationConstraint).toBe('us-east-2');
|
||||
return next();
|
||||
}),
|
||||
next => bucketUtil.s3.getBucketVersioning(
|
||||
{ Bucket: bucketName }, (err, res) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res.Status, 'Enabled');
|
||||
expect(res.Status).toBe('Enabled');
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
|
|
|
@ -25,14 +25,14 @@ describe('aws-node-sdk test bucket put acl', () => {
|
|||
let s3;
|
||||
|
||||
// setup test
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
s3.createBucket({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
// delete bucket after testing
|
||||
after(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
afterAll(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
const itSkipIfAWS = process.env.AWS_ON_AIR ? it.skip : it;
|
||||
itSkipIfAWS('should not accept xml body larger than 512 KB', done => {
|
||||
|
@ -48,9 +48,8 @@ describe('aws-node-sdk test bucket put acl', () => {
|
|||
};
|
||||
s3.putBucketAcl(params, error => {
|
||||
if (error) {
|
||||
assert.strictEqual(error.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
error.code, 'InvalidRequest');
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.code).toBe('InvalidRequest');
|
||||
done();
|
||||
} else {
|
||||
done('accepted xml body larger than 512 KB');
|
||||
|
@ -80,18 +79,18 @@ describe('PUT Bucket ACL', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if invalid grantee ' +
|
||||
test('should return InvalidArgument if invalid grantee ' +
|
||||
'user ID provided in ACL header request', done => {
|
||||
s3.putBucketAcl({
|
||||
Bucket: bucketName,
|
||||
GrantRead: 'id=invalidUserID' }, err => {
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
expect(err.statusCode).toBe(400);
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if invalid grantee ' +
|
||||
test('should return InvalidArgument if invalid grantee ' +
|
||||
'user ID provided in ACL request body', done => {
|
||||
s3.putBucketAcl({
|
||||
Bucket: bucketName,
|
||||
|
@ -111,8 +110,8 @@ describe('PUT Bucket ACL', () => {
|
|||
},
|
||||
},
|
||||
}, err => {
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
expect(err.statusCode).toBe(400);
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,13 +20,10 @@ const expirationRule = {
|
|||
// Check for the expected error response code and status code.
|
||||
function assertError(err, expectedErr, cb) {
|
||||
if (expectedErr === null) {
|
||||
assert.strictEqual(err, null, `expected no error but got '${err}'`);
|
||||
expect(err).toBe(null);
|
||||
} else {
|
||||
assert.strictEqual(err.code, expectedErr, 'incorrect error response ' +
|
||||
`code: should be '${expectedErr}' but got '${err.code}'`);
|
||||
assert.strictEqual(err.statusCode, errors[expectedErr].code,
|
||||
'incorrect error status code: should be ' +
|
||||
`${errors[expectedErr].code}, but got '${err.statusCode}'`);
|
||||
expect(err.code).toBe(expectedErr);
|
||||
expect(err.statusCode).toBe(errors[expectedErr].code);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
|
@ -50,14 +47,14 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
let s3;
|
||||
let otherAccountS3;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
otherAccountS3 = new BucketUtility('lisa', {}).s3;
|
||||
return done();
|
||||
});
|
||||
|
||||
it('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
test('should return NoSuchBucket error if bucket does not exist', done => {
|
||||
const params = getLifecycleParams();
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'NoSuchBucket', done));
|
||||
|
@ -68,80 +65,81 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done => {
|
||||
test('should return AccessDenied if user is not bucket owner', done => {
|
||||
const params = getLifecycleParams();
|
||||
otherAccountS3.putBucketLifecycleConfiguration(params,
|
||||
err => assertError(err, 'AccessDenied', done));
|
||||
});
|
||||
|
||||
it('should put lifecycle configuration on bucket', done => {
|
||||
test('should put lifecycle configuration on bucket', done => {
|
||||
const params = getLifecycleParams();
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with no Status', done => {
|
||||
test('should not allow lifecycle config with no Status', done => {
|
||||
const params = getLifecycleParams({ key: 'Status', value: '' });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with no Prefix or Filter',
|
||||
done => {
|
||||
test('should not allow lifecycle config with no Prefix or Filter', done => {
|
||||
const params = getLifecycleParams({ key: 'Prefix', value: null });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with empty action', done => {
|
||||
test('should not allow lifecycle config with empty action', done => {
|
||||
const params = getLifecycleParams({ key: 'Expiration', value: {} });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with ID longer than 255 char',
|
||||
done => {
|
||||
const params =
|
||||
getLifecycleParams({ key: 'ID', value: 'a'.repeat(256) });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'InvalidArgument', done));
|
||||
});
|
||||
test(
|
||||
'should not allow lifecycle config with ID longer than 255 char',
|
||||
done => {
|
||||
const params =
|
||||
getLifecycleParams({ key: 'ID', value: 'a'.repeat(256) });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'InvalidArgument', done));
|
||||
}
|
||||
);
|
||||
|
||||
it('should allow lifecycle config with Prefix length < 1024', done => {
|
||||
test('should allow lifecycle config with Prefix length < 1024', done => {
|
||||
const params =
|
||||
getLifecycleParams({ key: 'Prefix', value: 'a'.repeat(1023) });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with Prefix length === 1024',
|
||||
done => {
|
||||
test('should allow lifecycle config with Prefix length === 1024', done => {
|
||||
const params =
|
||||
getLifecycleParams({ key: 'Prefix', value: 'a'.repeat(1024) });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with Prefix length > 1024',
|
||||
done => {
|
||||
test('should not allow lifecycle config with Prefix length > 1024', done => {
|
||||
const params =
|
||||
getLifecycleParams({ key: 'Prefix', value: 'a'.repeat(1025) });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'InvalidRequest', done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with Filter.Prefix length > 1024',
|
||||
done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Prefix: 'a'.repeat(1025) },
|
||||
});
|
||||
delete params.LifecycleConfiguration.Rules[0].Prefix;
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'InvalidRequest', done));
|
||||
});
|
||||
test(
|
||||
'should not allow lifecycle config with Filter.Prefix length > 1024',
|
||||
done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Prefix: 'a'.repeat(1025) },
|
||||
});
|
||||
delete params.LifecycleConfiguration.Rules[0].Prefix;
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'InvalidRequest', done));
|
||||
}
|
||||
);
|
||||
|
||||
it('should not allow lifecycle config with Filter.And.Prefix length ' +
|
||||
test('should not allow lifecycle config with Filter.And.Prefix length ' +
|
||||
'> 1024', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
|
@ -157,7 +155,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'InvalidRequest', done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with Tag.Key length < 128', done => {
|
||||
test('should allow lifecycle config with Tag.Key length < 128', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a'.repeat(127), Value: 'bar' } },
|
||||
|
@ -167,8 +165,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with Tag.Key length === 128',
|
||||
done => {
|
||||
test('should allow lifecycle config with Tag.Key length === 128', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a'.repeat(128), Value: 'bar' } },
|
||||
|
@ -178,8 +175,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with Tag.Key length > 128',
|
||||
done => {
|
||||
test('should not allow lifecycle config with Tag.Key length > 128', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a'.repeat(129), Value: 'bar' } },
|
||||
|
@ -189,8 +185,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'InvalidRequest', done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with Tag.Value length < 256',
|
||||
done => {
|
||||
test('should allow lifecycle config with Tag.Value length < 256', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a', Value: 'b'.repeat(255) } },
|
||||
|
@ -200,8 +195,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with Tag.Value length === 256',
|
||||
done => {
|
||||
test('should allow lifecycle config with Tag.Value length === 256', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a', Value: 'b'.repeat(256) } },
|
||||
|
@ -211,8 +205,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with Tag.Value length > 256',
|
||||
done => {
|
||||
test('should not allow lifecycle config with Tag.Value length > 256', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'a', Value: 'b'.repeat(257) } },
|
||||
|
@ -222,20 +215,20 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'InvalidRequest', done));
|
||||
});
|
||||
|
||||
it('should not allow lifecycle config with Prefix and Filter', done => {
|
||||
test('should not allow lifecycle config with Prefix and Filter', done => {
|
||||
const params = getLifecycleParams(
|
||||
{ key: 'Filter', value: { Prefix: 'foo' } });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config without ID', done => {
|
||||
test('should allow lifecycle config without ID', done => {
|
||||
const params = getLifecycleParams({ key: 'ID', value: '' });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow lifecycle config with multiple actions', done => {
|
||||
test('should allow lifecycle config with multiple actions', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'NoncurrentVersionExpiration',
|
||||
value: { NoncurrentDays: 1 },
|
||||
|
@ -246,25 +239,25 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
|
||||
|
||||
describe('with Rule.Filter not Rule.Prefix', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
expirationRule.Prefix = null;
|
||||
done();
|
||||
});
|
||||
|
||||
it('should allow config with empty Filter', done => {
|
||||
test('should allow config with empty Filter', done => {
|
||||
const params = getLifecycleParams({ key: 'Filter', value: {} });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow config with And & Prefix', done => {
|
||||
test('should not allow config with And & Prefix', done => {
|
||||
const params = getLifecycleParams(
|
||||
{ key: 'Filter', value: { Prefix: 'foo', And: {} } });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow config with And & Tag', done => {
|
||||
test('should not allow config with And & Tag', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'foo', Value: 'bar' }, And: {} },
|
||||
|
@ -273,7 +266,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow config with Prefix & Tag', done => {
|
||||
test('should not allow config with Prefix & Tag', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'foo', Value: 'bar' }, Prefix: 'foo' },
|
||||
|
@ -282,14 +275,14 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should allow config with only Prefix', done => {
|
||||
test('should allow config with only Prefix', done => {
|
||||
const params = getLifecycleParams(
|
||||
{ key: 'Filter', value: { Prefix: 'foo' } });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow config with only Tag', done => {
|
||||
test('should allow config with only Tag', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { Tag: { Key: 'foo', Value: 'ba' } },
|
||||
|
@ -298,15 +291,14 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should not allow config with And.Prefix & no And.Tags',
|
||||
done => {
|
||||
test('should not allow config with And.Prefix & no And.Tags', done => {
|
||||
const params = getLifecycleParams(
|
||||
{ key: 'Filter', value: { And: { Prefix: 'foo' } } });
|
||||
s3.putBucketLifecycleConfiguration(params, err =>
|
||||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should not allow config with only one And.Tags', done => {
|
||||
test('should not allow config with only one And.Tags', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { And: { Tags: [{ Key: 'f', Value: 'b' }] } },
|
||||
|
@ -315,8 +307,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, 'MalformedXML', done));
|
||||
});
|
||||
|
||||
it('should allow config with And.Tags & no And.Prefix',
|
||||
done => {
|
||||
test('should allow config with And.Tags & no And.Prefix', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { And: { Tags:
|
||||
|
@ -328,7 +319,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
assertError(err, null, done));
|
||||
});
|
||||
|
||||
it('should allow config with And.Prefix & And.Tags', done => {
|
||||
test('should allow config with And.Prefix & And.Tags', done => {
|
||||
const params = getLifecycleParams({
|
||||
key: 'Filter',
|
||||
value: { And: { Prefix: 'foo',
|
||||
|
@ -358,7 +349,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
};
|
||||
}
|
||||
|
||||
it('should allow NoncurrentDays and StorageClass', done => {
|
||||
test('should allow NoncurrentDays and StorageClass', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: 0,
|
||||
StorageClass: 'us-east-2',
|
||||
|
@ -370,7 +361,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not allow duplicate StorageClass', done => {
|
||||
test('should not allow duplicate StorageClass', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: 1,
|
||||
StorageClass: 'us-east-2',
|
||||
|
@ -380,77 +371,70 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRequest');
|
||||
assert.strictEqual(err.message,
|
||||
"'StorageClass' must be different for " +
|
||||
expect(err.code).toBe('InvalidRequest');
|
||||
expect(err.message).toBe("'StorageClass' must be different for " +
|
||||
"'NoncurrentVersionTransition' actions in same " +
|
||||
"'Rule' with prefix ''");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow unknown StorageClass',
|
||||
done => {
|
||||
test('should not allow unknown StorageClass', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: 1,
|
||||
StorageClass: 'unknown',
|
||||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it(`should not allow NoncurrentDays value exceeding ${MAX_DAYS}`,
|
||||
done => {
|
||||
test(`should not allow NoncurrentDays value exceeding ${MAX_DAYS}`, done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: MAX_DAYS + 1,
|
||||
StorageClass: 'us-east-2',
|
||||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow negative NoncurrentDays',
|
||||
done => {
|
||||
test('should not allow negative NoncurrentDays', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: -1,
|
||||
StorageClass: 'us-east-2',
|
||||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
assert.strictEqual(err.message,
|
||||
"'NoncurrentDays' in NoncurrentVersionTransition " +
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
expect(err.message).toBe("'NoncurrentDays' in NoncurrentVersionTransition " +
|
||||
'action must be nonnegative');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow config missing NoncurrentDays',
|
||||
done => {
|
||||
test('should not allow config missing NoncurrentDays', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
StorageClass: 'us-east-2',
|
||||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow config missing StorageClass',
|
||||
done => {
|
||||
test('should not allow config missing StorageClass', done => {
|
||||
const noncurrentVersionTransitions = [{
|
||||
NoncurrentDays: 1,
|
||||
}];
|
||||
const params = getParams(noncurrentVersionTransitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -471,7 +455,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
};
|
||||
}
|
||||
|
||||
it('should allow Days', done => {
|
||||
test('should allow Days', done => {
|
||||
const transitions = [{
|
||||
Days: 0,
|
||||
StorageClass: 'us-east-2',
|
||||
|
@ -483,33 +467,32 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it(`should not allow Days value exceeding ${MAX_DAYS}`, done => {
|
||||
test(`should not allow Days value exceeding ${MAX_DAYS}`, done => {
|
||||
const transitions = [{
|
||||
Days: MAX_DAYS + 1,
|
||||
StorageClass: 'us-east-2',
|
||||
}];
|
||||
const params = getParams(transitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow negative Days value', done => {
|
||||
test('should not allow negative Days value', done => {
|
||||
const transitions = [{
|
||||
Days: -1,
|
||||
StorageClass: 'us-east-2',
|
||||
}];
|
||||
const params = getParams(transitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
assert.strictEqual(err.message,
|
||||
"'Days' in Transition action must be nonnegative");
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
expect(err.message).toBe("'Days' in Transition action must be nonnegative");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not allow duplicate StorageClass', done => {
|
||||
test('should not allow duplicate StorageClass', done => {
|
||||
const transitions = [{
|
||||
Days: 1,
|
||||
StorageClass: 'us-east-2',
|
||||
|
@ -519,16 +502,15 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
}];
|
||||
const params = getParams(transitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRequest');
|
||||
assert.strictEqual(err.message,
|
||||
"'StorageClass' must be different for 'Transition' " +
|
||||
"actions in same 'Rule' with prefix ''");
|
||||
expect(err.code).toBe('InvalidRequest');
|
||||
expect(err.message).toBe("'StorageClass' must be different for 'Transition' " +
|
||||
"actions in same 'Rule' with prefix ''");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Upgrade to aws-sdk >= 2.60.0 for correct Date field support
|
||||
it.skip('should allow Date', done => {
|
||||
test.skip('should allow Date', done => {
|
||||
const transitions = [{
|
||||
Date: '2016-01-01T00:00:00.000Z',
|
||||
StorageClass: 'us-east-2',
|
||||
|
@ -541,8 +523,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
});
|
||||
|
||||
// TODO: Upgrade to aws-sdk >= 2.60.0 for correct Date field support
|
||||
it.skip('should not allow speficying both Days and Date value',
|
||||
done => {
|
||||
test.skip('should not allow speficying both Days and Date value', done => {
|
||||
const transitions = [{
|
||||
Date: '2016-01-01T00:00:00.000Z',
|
||||
Days: 1,
|
||||
|
@ -550,13 +531,13 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
}];
|
||||
const params = getParams(transitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Upgrade to aws-sdk >= 2.60.0 for correct Date field support
|
||||
it.skip('should not allow speficying both Days and Date value ' +
|
||||
test.skip('should not allow speficying both Days and Date value ' +
|
||||
'across transitions', done => {
|
||||
const transitions = [{
|
||||
Date: '2016-01-01T00:00:00.000Z',
|
||||
|
@ -567,16 +548,15 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
}];
|
||||
const params = getParams(transitions);
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRequest');
|
||||
assert.strictEqual(err.message,
|
||||
"Found mixed 'Date' and 'Days' based Transition " +
|
||||
"actions in lifecycle rule for prefix ''");
|
||||
expect(err.code).toBe('InvalidRequest');
|
||||
expect(err.message).toBe("Found mixed 'Date' and 'Days' based Transition " +
|
||||
"actions in lifecycle rule for prefix ''");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Upgrade to aws-sdk >= 2.60.0 for correct Date field support
|
||||
it.skip('should not allow speficying both Days and Date value ' +
|
||||
test.skip('should not allow speficying both Days and Date value ' +
|
||||
'across transitions and expiration', done => {
|
||||
const transitions = [{
|
||||
Days: 1,
|
||||
|
@ -585,10 +565,9 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
const params = getParams(transitions);
|
||||
params.LifecycleConfiguration.Rules[0].Expiration = { Date: 0 };
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRequest');
|
||||
assert.strictEqual(err.message,
|
||||
"Found mixed 'Date' and 'Days' based Expiration and " +
|
||||
"Transition actions in lifecycle rule for prefix ''");
|
||||
expect(err.code).toBe('InvalidRequest');
|
||||
expect(err.message).toBe("Found mixed 'Date' and 'Days' based Expiration and " +
|
||||
"Transition actions in lifecycle rule for prefix ''");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -597,7 +576,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
// NoncurrentVersionTransitions not implemented
|
||||
describe.skip('with NoncurrentVersionTransitions and Transitions',
|
||||
() => {
|
||||
it('should allow config', done => {
|
||||
test('should allow config', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
LifecycleConfiguration: {
|
||||
|
@ -623,7 +602,7 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not allow config when specifying ' +
|
||||
test('should not allow config when specifying ' +
|
||||
'NoncurrentVersionTransitions', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
|
@ -640,8 +619,8 @@ describe('aws-sdk test put bucket lifecycle', () => {
|
|||
},
|
||||
};
|
||||
s3.putBucketLifecycleConfiguration(params, err => {
|
||||
assert.strictEqual(err.statusCode, 501);
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.statusCode).toBe(501);
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,13 +13,10 @@ const destinationBucket = 'destination-bucket';
|
|||
// Check for the expected error response code and status code.
|
||||
function assertError(err, expectedErr) {
|
||||
if (expectedErr === null) {
|
||||
assert.strictEqual(err, null, `expected no error but got '${err}'`);
|
||||
expect(err).toBe(null);
|
||||
} else {
|
||||
assert.strictEqual(err.code, expectedErr, 'incorrect error response ' +
|
||||
`code: should be '${expectedErr}' but got '${err.code}'`);
|
||||
assert.strictEqual(err.statusCode, errors[expectedErr].code,
|
||||
'incorrect error status code: should be 400 but got ' +
|
||||
`'${err.statusCode}'`);
|
||||
expect(err.code).toBe(expectedErr);
|
||||
expect(err.statusCode).toBe(errors[expectedErr].code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +80,7 @@ describe('aws-node-sdk test putBucketReplication bucket status', () => {
|
|||
});
|
||||
}
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
otherAccountS3 = new BucketUtility('lisa', {}).s3;
|
||||
|
@ -91,7 +88,7 @@ describe('aws-node-sdk test putBucketReplication bucket status', () => {
|
|||
return done();
|
||||
});
|
||||
|
||||
it('should return \'NoSuchBucket\' error if bucket does not exist', done =>
|
||||
test('should return \'NoSuchBucket\' error if bucket does not exist', done =>
|
||||
s3.putBucketReplication(replicationParams, err => {
|
||||
assertError(err, 'NoSuchBucket');
|
||||
return done();
|
||||
|
@ -102,29 +99,29 @@ describe('aws-node-sdk test putBucketReplication bucket status', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: sourceBucket }, done));
|
||||
|
||||
it('should return AccessDenied if user is not bucket owner', done =>
|
||||
test('should return AccessDenied if user is not bucket owner', done =>
|
||||
otherAccountS3.putBucketReplication(replicationParams,
|
||||
err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
expect(err.statusCode).toBe(403);
|
||||
return done();
|
||||
}));
|
||||
|
||||
it('should not put configuration on bucket without versioning', done =>
|
||||
test('should not put configuration on bucket without versioning', done =>
|
||||
s3.putBucketReplication(replicationParams, err => {
|
||||
assertError(err, 'InvalidRequest');
|
||||
return done();
|
||||
}));
|
||||
|
||||
it('should not put configuration on bucket with \'Suspended\'' +
|
||||
test('should not put configuration on bucket with \'Suspended\'' +
|
||||
'versioning', done =>
|
||||
checkVersioningError(s3, 'Suspended', 'InvalidRequest', done));
|
||||
|
||||
it('should put configuration on a bucket with versioning', done =>
|
||||
test('should put configuration on a bucket with versioning', done =>
|
||||
checkVersioningError(s3, 'Enabled', null, done));
|
||||
|
||||
it('should put configuration on a bucket with versioning if ' +
|
||||
test('should put configuration on a bucket with versioning if ' +
|
||||
'user is a replication user', done =>
|
||||
checkVersioningError(replicationAccountS3, 'Enabled', null, done));
|
||||
});
|
||||
|
@ -157,21 +154,20 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
const Role = ARN === '' || ARN === ',' ? ARN : `${ARN},${ARN}`;
|
||||
const config = Object.assign({}, replicationConfig, { Role });
|
||||
|
||||
it('should not accept configuration when \'Role\' is not a ' +
|
||||
test('should not accept configuration when \'Role\' is not a ' +
|
||||
'comma-separated list of two valid Amazon Resource Names: ' +
|
||||
`'${Role}'`, done =>
|
||||
checkError(config, 'InvalidArgument', done));
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Role\' is a comma-separated ' +
|
||||
'list of more than two valid Amazon Resource Names',
|
||||
done => {
|
||||
const Role = 'arn:aws:iam::account-id:role/resource-1,' +
|
||||
'arn:aws:iam::account-id:role/resource-2,' +
|
||||
'arn:aws:iam::account-id:role/resource-3';
|
||||
const config = Object.assign({}, replicationConfig, { Role });
|
||||
checkError(config, 'InvalidArgument', done);
|
||||
});
|
||||
test('should not accept configuration when \'Role\' is a comma-separated ' +
|
||||
'list of more than two valid Amazon Resource Names', done => {
|
||||
const Role = 'arn:aws:iam::account-id:role/resource-1,' +
|
||||
'arn:aws:iam::account-id:role/resource-2,' +
|
||||
'arn:aws:iam::account-id:role/resource-3';
|
||||
const config = Object.assign({}, replicationConfig, { Role });
|
||||
checkError(config, 'InvalidArgument', done);
|
||||
});
|
||||
|
||||
replicationUtils.validRoleARNs.forEach(ARN => {
|
||||
const config = setConfigRules({
|
||||
|
@ -182,13 +178,13 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
});
|
||||
config.Role = ARN;
|
||||
|
||||
it('should accept configuration if \'Role\' is a single valid ' +
|
||||
test('should accept configuration if \'Role\' is a single valid ' +
|
||||
`Amazon Resource Name: '${ARN}', and a rule storageClass defines ` +
|
||||
'an external location', done =>
|
||||
checkError(config, null, done));
|
||||
});
|
||||
|
||||
it('should allow a combination of storageClasses across rules', done => {
|
||||
test('should allow a combination of storageClasses across rules', done => {
|
||||
const config = setConfigRules([replicationConfig.Rules[0], {
|
||||
Destination: {
|
||||
Bucket: `arn:aws:s3:::${destinationBucket}`,
|
||||
|
@ -202,7 +198,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
checkError(config, null, done);
|
||||
});
|
||||
|
||||
it('should not allow a comma separated list of roles when a rule ' +
|
||||
test('should not allow a comma separated list of roles when a rule ' +
|
||||
'storageClass defines an external location', done => {
|
||||
const config = {
|
||||
Role: 'arn:aws:iam::account-id:role/src-resource,' +
|
||||
|
@ -225,7 +221,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
const Role = `${ARN},${ARN}`;
|
||||
const config = Object.assign({}, replicationConfig, { Role });
|
||||
|
||||
it('should accept configuration when \'Role\' is a comma-separated ' +
|
||||
test('should accept configuration when \'Role\' is a comma-separated ' +
|
||||
`list of two valid Amazon Resource Names: '${Role}'`, done =>
|
||||
checkError(config, null, done));
|
||||
});
|
||||
|
@ -233,17 +229,17 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
replicationUtils.invalidBucketARNs.forEach(ARN => {
|
||||
const config = setConfigRules({ Destination: { Bucket: ARN } });
|
||||
|
||||
it('should not accept configuration when \'Bucket\' is not a ' +
|
||||
test('should not accept configuration when \'Bucket\' is not a ' +
|
||||
`valid Amazon Resource Name format: '${ARN}'`, done =>
|
||||
checkError(config, 'InvalidArgument', done));
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Rules\' is empty ', done => {
|
||||
test('should not accept configuration when \'Rules\' is empty ', done => {
|
||||
const config = Object.assign({}, replicationConfig, { Rules: [] });
|
||||
return checkError(config, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Rules\' is > 1000', done => {
|
||||
test('should not accept configuration when \'Rules\' is > 1000', done => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < 1001; i++) {
|
||||
arr.push({
|
||||
|
@ -256,13 +252,13 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
return checkError(config, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'ID\' length is > 255', done => {
|
||||
test('should not accept configuration when \'ID\' length is > 255', done => {
|
||||
// Set ID to a string of length 256.
|
||||
const config = setConfigRules({ ID: new Array(257).join('x') });
|
||||
return checkError(config, 'InvalidArgument', done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'ID\' is not unique', done => {
|
||||
test('should not accept configuration when \'ID\' is not unique', done => {
|
||||
const rule1 = replicationConfig.Rules[0];
|
||||
// Prefix is unique, but not the ID.
|
||||
const rule2 = Object.assign({}, rule1, { Prefix: 'bar' });
|
||||
|
@ -270,7 +266,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
return checkError(config, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should accept configuration when \'ID\' is not provided for multiple ' +
|
||||
test('should accept configuration when \'ID\' is not provided for multiple ' +
|
||||
'rules', done => {
|
||||
const replicationConfigWithoutID = Object.assign({}, replicationConfig);
|
||||
const rule1 = replicationConfigWithoutID.Rules[0];
|
||||
|
@ -283,32 +279,33 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
replicationUtils.validStatuses.forEach(status => {
|
||||
const config = setConfigRules({ Status: status });
|
||||
|
||||
it(`should accept configuration when 'Role' is ${status}`, done =>
|
||||
test(`should accept configuration when 'Role' is ${status}`, done =>
|
||||
checkError(config, null, done));
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Status\' is invalid', done => {
|
||||
test('should not accept configuration when \'Status\' is invalid', done => {
|
||||
// Status must either be 'Enabled' or 'Disabled'.
|
||||
const config = setConfigRules({ Status: 'Invalid' });
|
||||
return checkError(config, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should accept configuration when \'Prefix\' is \'\'',
|
||||
done => {
|
||||
const config = setConfigRules({ Prefix: '' });
|
||||
return checkError(config, null, done);
|
||||
});
|
||||
test('should accept configuration when \'Prefix\' is \'\'', done => {
|
||||
const config = setConfigRules({ Prefix: '' });
|
||||
return checkError(config, null, done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Prefix\' length is > 1024',
|
||||
test(
|
||||
'should not accept configuration when \'Prefix\' length is > 1024',
|
||||
done => {
|
||||
// Set Prefix to a string of length of 1025.
|
||||
const config = setConfigRules({
|
||||
Prefix: new Array(1026).join('x'),
|
||||
});
|
||||
return checkError(config, 'InvalidArgument', done);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should not accept configuration when rules contain overlapping ' +
|
||||
test('should not accept configuration when rules contain overlapping ' +
|
||||
'\'Prefix\' values: new prefix starts with used prefix', done => {
|
||||
const config = setConfigRules([replicationConfig.Rules[0], {
|
||||
Destination: { Bucket: `arn:aws:s3:::${destinationBucket}` },
|
||||
|
@ -318,7 +315,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
return checkError(config, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when rules contain overlapping ' +
|
||||
test('should not accept configuration when rules contain overlapping ' +
|
||||
'\'Prefix\' values: used prefix starts with new prefix', done => {
|
||||
const config = setConfigRules([replicationConfig.Rules[0], {
|
||||
Destination: { Bucket: `arn:aws:s3:::${destinationBucket}` },
|
||||
|
@ -328,7 +325,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
return checkError(config, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'Destination\' properties of ' +
|
||||
test('should not accept configuration when \'Destination\' properties of ' +
|
||||
'two or more rules specify different buckets', done => {
|
||||
const config = setConfigRules([replicationConfig.Rules[0], {
|
||||
Destination: { Bucket: `arn:aws:s3:::${destinationBucket}-1` },
|
||||
|
@ -346,7 +343,7 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
},
|
||||
});
|
||||
|
||||
it('should accept configuration when \'StorageClass\' is ' +
|
||||
test('should accept configuration when \'StorageClass\' is ' +
|
||||
`${storageClass}`, done => checkError(config, null, done));
|
||||
});
|
||||
|
||||
|
@ -359,11 +356,12 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
},
|
||||
});
|
||||
|
||||
it('should accept configuration when \'StorageClass\' is ' +
|
||||
test('should accept configuration when \'StorageClass\' is ' +
|
||||
`${storageClass}`, done => checkError(config, null, done));
|
||||
});
|
||||
|
||||
it('should not accept configuration when \'StorageClass\' is invalid',
|
||||
test(
|
||||
'should not accept configuration when \'StorageClass\' is invalid',
|
||||
done => {
|
||||
const config = setConfigRules({
|
||||
Destination: {
|
||||
|
@ -372,5 +370,6 @@ describe('aws-node-sdk test putBucketReplication configuration rules', () => {
|
|||
},
|
||||
});
|
||||
return checkError(config, 'MalformedXML', done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -42,9 +42,9 @@ describe('PUT bucket cors', () => {
|
|||
function _testPutBucketCors(rules, statusCode, errMsg, cb) {
|
||||
s3.putBucketCors({ Bucket: bucketName,
|
||||
CORSConfiguration: rules }, err => {
|
||||
assert(err, 'Expected err but found none');
|
||||
assert.strictEqual(err.code, errMsg);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(errMsg);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -53,15 +53,15 @@ describe('PUT bucket cors', () => {
|
|||
|
||||
afterEach(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
it('should put a bucket cors successfully', done => {
|
||||
test('should put a bucket cors successfully', done => {
|
||||
s3.putBucketCors({ Bucket: bucketName,
|
||||
CORSConfiguration: sampleCors }, err => {
|
||||
assert.strictEqual(err, null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if more than 100 rules', done => {
|
||||
test('should return InvalidRequest if more than 100 rules', done => {
|
||||
const sampleRule = {
|
||||
AllowedMethods: ['PUT', 'POST', 'DELETE'],
|
||||
AllowedOrigins: ['http://www.example.com'],
|
||||
|
@ -76,50 +76,48 @@ describe('PUT bucket cors', () => {
|
|||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return MalformedXML if missing AllowedOrigin', done => {
|
||||
test('should return MalformedXML if missing AllowedOrigin', done => {
|
||||
const testCors = _corsTemplate({ AllowedOrigins: [] });
|
||||
_testPutBucketCors(testCors, 400, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if more than one asterisk in ' +
|
||||
test('should return InvalidRequest if more than one asterisk in ' +
|
||||
'AllowedOrigin', done => {
|
||||
const testCors =
|
||||
_corsTemplate({ AllowedOrigins: ['http://*.*.com'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return MalformedXML if missing AllowedMethod', done => {
|
||||
test('should return MalformedXML if missing AllowedMethod', done => {
|
||||
const testCors = _corsTemplate({ AllowedMethods: [] });
|
||||
_testPutBucketCors(testCors, 400, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if AllowedMethod is not a valid ' +
|
||||
test('should return InvalidRequest if AllowedMethod is not a valid ' +
|
||||
'method', done => {
|
||||
const testCors = _corsTemplate({ AllowedMethods: ['test'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest for lowercase value for ' +
|
||||
test('should return InvalidRequest for lowercase value for ' +
|
||||
'AllowedMethod', done => {
|
||||
const testCors = _corsTemplate({ AllowedMethods: ['put', 'get'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if more than one asterisk in ' +
|
||||
test('should return InvalidRequest if more than one asterisk in ' +
|
||||
'AllowedHeader', done => {
|
||||
const testCors = _corsTemplate({ AllowedHeaders: ['*-amz-*'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if ExposeHeader has character ' +
|
||||
'that is not dash or alphanumeric',
|
||||
done => {
|
||||
test('should return InvalidRequest if ExposeHeader has character ' +
|
||||
'that is not dash or alphanumeric', done => {
|
||||
const testCors = _corsTemplate({ ExposeHeaders: ['test header'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if ExposeHeader has wildcard',
|
||||
done => {
|
||||
test('should return InvalidRequest if ExposeHeader has wildcard', done => {
|
||||
const testCors = _corsTemplate({ ExposeHeaders: ['x-amz-*'] });
|
||||
_testPutBucketCors(testCors, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
|
|
@ -14,9 +14,9 @@ describe('PUT bucket website', () => {
|
|||
function _testPutBucketWebsite(config, statusCode, errMsg, cb) {
|
||||
s3.putBucketWebsite({ Bucket: bucketName,
|
||||
WebsiteConfiguration: config }, err => {
|
||||
assert(err, 'Expected err but found none');
|
||||
assert.strictEqual(err.code, errMsg);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(errMsg);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -44,22 +44,22 @@ describe('PUT bucket website', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should put a bucket website successfully', done => {
|
||||
test('should put a bucket website successfully', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucketName,
|
||||
WebsiteConfiguration: config }, err => {
|
||||
assert.strictEqual(err, null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if IndexDocument or ' +
|
||||
test('should return InvalidArgument if IndexDocument or ' +
|
||||
'RedirectAllRequestsTo is not provided', done => {
|
||||
const config = new WebsiteConfigTester();
|
||||
_testPutBucketWebsite(config, 400, 'InvalidArgument', done);
|
||||
});
|
||||
|
||||
it('should return an InvalidRequest if both ' +
|
||||
test('should return an InvalidRequest if both ' +
|
||||
'RedirectAllRequestsTo and IndexDocument are provided', done => {
|
||||
const redirectAllTo = {
|
||||
HostName: 'test',
|
||||
|
@ -71,12 +71,12 @@ describe('PUT bucket website', () => {
|
|||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if index has slash', done => {
|
||||
test('should return InvalidArgument if index has slash', done => {
|
||||
const config = new WebsiteConfigTester('in/dex.html');
|
||||
_testPutBucketWebsite(config, 400, 'InvalidArgument', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if both ReplaceKeyWith and ' +
|
||||
test('should return InvalidRequest if both ReplaceKeyWith and ' +
|
||||
'ReplaceKeyPrefixWith are present in same rule', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
config.addRoutingRule({ ReplaceKeyPrefixWith: 'test',
|
||||
|
@ -84,7 +84,7 @@ describe('PUT bucket website', () => {
|
|||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if both ReplaceKeyWith and ' +
|
||||
test('should return InvalidRequest if both ReplaceKeyWith and ' +
|
||||
'ReplaceKeyPrefixWith are present in same rule', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
config.addRoutingRule({ ReplaceKeyPrefixWith: 'test',
|
||||
|
@ -92,14 +92,14 @@ describe('PUT bucket website', () => {
|
|||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if Redirect Protocol is ' +
|
||||
test('should return InvalidRequest if Redirect Protocol is ' +
|
||||
'not http or https', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
config.addRoutingRule({ Protocol: 'notvalidprotocol' });
|
||||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if RedirectAllRequestsTo Protocol ' +
|
||||
test('should return InvalidRequest if RedirectAllRequestsTo Protocol ' +
|
||||
'is not http or https', done => {
|
||||
const redirectAllTo = {
|
||||
HostName: 'test',
|
||||
|
@ -109,21 +109,21 @@ describe('PUT bucket website', () => {
|
|||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return MalformedXML if Redirect HttpRedirectCode ' +
|
||||
test('should return MalformedXML if Redirect HttpRedirectCode ' +
|
||||
'is a string that does not contains a number', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
config.addRoutingRule({ HttpRedirectCode: 'notvalidhttpcode' });
|
||||
_testPutBucketWebsite(config, 400, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if Redirect HttpRedirectCode ' +
|
||||
test('should return InvalidRequest if Redirect HttpRedirectCode ' +
|
||||
'is not a valid http redirect code (3XX excepting 300)', done => {
|
||||
const config = new WebsiteConfigTester('index.html');
|
||||
config.addRoutingRule({ HttpRedirectCode: '400' });
|
||||
_testPutBucketWebsite(config, 400, 'InvalidRequest', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if Condition ' +
|
||||
test('should return InvalidRequest if Condition ' +
|
||||
'HttpErrorCodeReturnedEquals is a string that does ' +
|
||||
' not contain a number', done => {
|
||||
const condition = { HttpErrorCodeReturnedEquals: 'notvalidcode' };
|
||||
|
@ -132,7 +132,7 @@ describe('PUT bucket website', () => {
|
|||
_testPutBucketWebsite(config, 400, 'MalformedXML', done);
|
||||
});
|
||||
|
||||
it('should return InvalidRequest if Condition ' +
|
||||
test('should return InvalidRequest if Condition ' +
|
||||
'HttpErrorCodeReturnedEquals is not a valid http' +
|
||||
'error code (4XX or 5XX)', done => {
|
||||
const condition = { HttpErrorCodeReturnedEquals: '300' };
|
||||
|
|
|
@ -35,7 +35,7 @@ const Bucket = `bucket-skip-scan-${Date.now()}`;
|
|||
|
||||
describe('Skip scan cases tests', () => {
|
||||
let s3;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new AWS.S3(config);
|
||||
s3.createBucket(
|
||||
|
@ -60,7 +60,7 @@ describe('Skip scan cases tests', () => {
|
|||
}, done);
|
||||
});
|
||||
});
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3.listObjects({ Bucket }, (err, data) => {
|
||||
async.each(data.Contents, (o, next) => {
|
||||
s3.deleteObject({ Bucket, Key: o.Key }, next);
|
||||
|
@ -69,9 +69,9 @@ describe('Skip scan cases tests', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
it('should find all common prefixes in one shot', done => {
|
||||
test('should find all common prefixes in one shot', done => {
|
||||
s3.listObjects({ Bucket, Delimiter: '/' }, (err, data) => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
cutAttributes(data);
|
||||
assert.deepStrictEqual(data, {
|
||||
IsTruncated: false,
|
||||
|
|
|
@ -22,20 +22,19 @@ function deleteObjects(s3, loopId, cb) {
|
|||
}, cb);
|
||||
}
|
||||
|
||||
describe('aws-node-sdk stress test bucket', function testSuite() {
|
||||
describe('aws-node-sdk stress test bucket', () => {
|
||||
this.timeout(120000);
|
||||
let s3;
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
});
|
||||
|
||||
it('createBucket-putObject-deleteObject-deleteBucket loop', done =>
|
||||
test('createBucket-putObject-deleteObject-deleteBucket loop', done =>
|
||||
timesSeries(loopCount, (loopId, next) => waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket }, err => next(err)),
|
||||
next => putObjects(s3, loopId, err => next(err)),
|
||||
next => deleteObjects(s3, loopId, err => next(err)),
|
||||
next => s3.deleteBucket({ Bucket: bucket }, err => next(err)),
|
||||
], err => next(err)), done)
|
||||
);
|
||||
], err => next(err)), done));
|
||||
});
|
||||
|
|
|
@ -8,29 +8,28 @@ const config = getConfig('default', { signatureVersion: 'v4' });
|
|||
const configReplication = getConfig('replication',
|
||||
{ signatureVersion: 'v4' });
|
||||
const s3 = new S3(config);
|
||||
describe('aws-node-sdk test bucket versioning', function testSuite() {
|
||||
describe('aws-node-sdk test bucket versioning', () => {
|
||||
this.timeout(60000);
|
||||
let replicationAccountS3;
|
||||
|
||||
// setup test
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
replicationAccountS3 = new S3(configReplication);
|
||||
s3.createBucket({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
// delete bucket after testing
|
||||
after(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
afterAll(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should not accept empty versioning configuration', done => {
|
||||
test('should not accept empty versioning configuration', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {},
|
||||
};
|
||||
s3.putBucketVersioning(params, error => {
|
||||
if (error) {
|
||||
assert.strictEqual(error.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
error.code, 'IllegalVersioningConfigurationException');
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.code).toBe('IllegalVersioningConfigurationException');
|
||||
done();
|
||||
} else {
|
||||
done('accepted empty versioning configuration');
|
||||
|
@ -38,16 +37,16 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should retrieve an empty versioning configuration', done => {
|
||||
test('should retrieve an empty versioning configuration', done => {
|
||||
const params = { Bucket: bucket };
|
||||
s3.getBucketVersioning(params, (error, data) => {
|
||||
assert.strictEqual(error, null);
|
||||
expect(error).toBe(null);
|
||||
assert.deepStrictEqual(data, {});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not accept versioning configuration w/o "Status"', done => {
|
||||
test('should not accept versioning configuration w/o "Status"', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {
|
||||
|
@ -56,9 +55,8 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
};
|
||||
s3.putBucketVersioning(params, error => {
|
||||
if (error) {
|
||||
assert.strictEqual(error.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
error.code, 'IllegalVersioningConfigurationException');
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.code).toBe('IllegalVersioningConfigurationException');
|
||||
done();
|
||||
} else {
|
||||
done('accepted empty versioning configuration');
|
||||
|
@ -66,16 +64,16 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should retrieve an empty versioning configuration', done => {
|
||||
test('should retrieve an empty versioning configuration', done => {
|
||||
const params = { Bucket: bucket };
|
||||
s3.getBucketVersioning(params, (error, data) => {
|
||||
assert.strictEqual(error, null);
|
||||
expect(error).toBe(null);
|
||||
assert.deepStrictEqual(data, {});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not accept versioning configuration w/ invalid value', done => {
|
||||
test('should not accept versioning configuration w/ invalid value', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {
|
||||
|
@ -85,9 +83,8 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
};
|
||||
s3.putBucketVersioning(params, error => {
|
||||
if (error) {
|
||||
assert.strictEqual(error.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
error.code, 'IllegalVersioningConfigurationException');
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.code).toBe('IllegalVersioningConfigurationException');
|
||||
done();
|
||||
} else {
|
||||
done('accepted empty versioning configuration');
|
||||
|
@ -95,7 +92,7 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not accept versioning with MFA Delete enabled', done => {
|
||||
test('should not accept versioning with MFA Delete enabled', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {
|
||||
|
@ -104,14 +101,14 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
},
|
||||
};
|
||||
s3.putBucketVersioning(params, error => {
|
||||
assert.notEqual(error, null, 'Expected failure but got success');
|
||||
assert.strictEqual(error.statusCode, 501);
|
||||
assert.strictEqual(error.code, 'NotImplemented');
|
||||
expect(error).not.toEqual(null);
|
||||
expect(error.statusCode).toBe(501);
|
||||
expect(error.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept versioning with MFA Delete disabled', done => {
|
||||
test('should accept versioning with MFA Delete disabled', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {
|
||||
|
@ -120,23 +117,23 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
},
|
||||
};
|
||||
s3.putBucketVersioning(params, error => {
|
||||
assert.equal(error, null, 'Expected success but got failure');
|
||||
expect(error).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve the valid versioning configuration', done => {
|
||||
test('should retrieve the valid versioning configuration', done => {
|
||||
const params = { Bucket: bucket };
|
||||
// s3.getBucketVersioning(params, done);
|
||||
s3.getBucketVersioning(params, (error, data) => {
|
||||
assert.strictEqual(error, null);
|
||||
expect(error).toBe(null);
|
||||
assert.deepStrictEqual(data, { MFADelete: 'Disabled',
|
||||
Status: 'Enabled' });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept valid versioning configuration', done => {
|
||||
test('should accept valid versioning configuration', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
VersioningConfiguration: {
|
||||
|
@ -146,7 +143,7 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
s3.putBucketVersioning(params, done);
|
||||
});
|
||||
|
||||
it('should accept valid versioning configuration if user is a ' +
|
||||
test('should accept valid versioning configuration if user is a ' +
|
||||
'replication user', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
|
@ -157,11 +154,11 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
replicationAccountS3.putBucketVersioning(params, done);
|
||||
});
|
||||
|
||||
it('should retrieve the valid versioning configuration', done => {
|
||||
test('should retrieve the valid versioning configuration', done => {
|
||||
const params = { Bucket: bucket };
|
||||
// s3.getBucketVersioning(params, done);
|
||||
s3.getBucketVersioning(params, (error, data) => {
|
||||
assert.strictEqual(error, null);
|
||||
expect(error).toBe(null);
|
||||
assert.deepStrictEqual(data, { Status: 'Enabled' });
|
||||
done();
|
||||
});
|
||||
|
@ -171,21 +168,21 @@ describe('aws-node-sdk test bucket versioning', function testSuite() {
|
|||
|
||||
describe('bucket versioning for ingestion buckets', () => {
|
||||
const Bucket = `ingestion-bucket-${Date.now()}`;
|
||||
before(done => s3.createBucket({
|
||||
beforeAll(done => s3.createBucket({
|
||||
Bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: 'us-east-2:ingest',
|
||||
},
|
||||
}, done));
|
||||
|
||||
after(done => s3.deleteBucket({ Bucket }, done));
|
||||
afterAll(done => s3.deleteBucket({ Bucket }, done));
|
||||
|
||||
it('should not allow suspending versioning for ingestion buckets', done => {
|
||||
test('should not allow suspending versioning for ingestion buckets', done => {
|
||||
s3.putBucketVersioning({ Bucket, VersioningConfiguration: {
|
||||
Status: 'Suspended'
|
||||
} }, err => {
|
||||
assert(err, 'Expected error but got success');
|
||||
assert.strictEqual(err.code, 'InvalidBucketState');
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('InvalidBucketState');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,13 +6,13 @@ describe('S3 connect test', () => {
|
|||
const config = getConfig();
|
||||
const s3 = new S3(config);
|
||||
|
||||
it('should list buckets', done => {
|
||||
test('should list buckets', done => {
|
||||
s3.listBuckets((err, data) => {
|
||||
if (err) {
|
||||
done(err);
|
||||
}
|
||||
|
||||
assert.ok(data.Buckets, 'should contain Buckets');
|
||||
expect(data.Buckets).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ const itSkipAWS = process.env.AWS_ON_AIR
|
|||
function diff(putFile, receivedFile, done) {
|
||||
process.stdout.write(`diff ${putFile} ${receivedFile}\n`);
|
||||
cp.spawn('diff', [putFile, receivedFile]).on('exit', code => {
|
||||
assert.strictEqual(code, 0);
|
||||
expect(code).toBe(0);
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ function deleteFile(file, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
describe('aws-node-sdk v2auth query tests', function testSuite() {
|
||||
describe('aws-node-sdk v2auth query tests', () => {
|
||||
this.timeout(60000);
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const config = getConfig('default');
|
||||
|
||||
s3 = new S3(config);
|
||||
|
@ -46,96 +46,97 @@ describe('aws-node-sdk v2auth query tests', function testSuite() {
|
|||
const params = { Bucket: bucket, Expires: 604810 };
|
||||
const url = s3.getSignedUrl('createBucket', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '403 FORBIDDEN');
|
||||
expect(httpCode).toBe('403 FORBIDDEN');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error code if request occurs after expiry',
|
||||
done => {
|
||||
const params = { Bucket: bucket, Expires: 1 };
|
||||
const url = s3.getSignedUrl('createBucket', params);
|
||||
setTimeout(() => {
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '403 FORBIDDEN');
|
||||
done();
|
||||
});
|
||||
}, 1500);
|
||||
});
|
||||
test('should return an error code if request occurs after expiry', done => {
|
||||
const params = { Bucket: bucket, Expires: 1 };
|
||||
const url = s3.getSignedUrl('createBucket', params);
|
||||
setTimeout(() => {
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url], httpCode => {
|
||||
expect(httpCode).toBe('403 FORBIDDEN');
|
||||
done();
|
||||
});
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
it('should create a bucket', done => {
|
||||
test('should create a bucket', done => {
|
||||
const params = { Bucket: bucket, Expires: almostOutsideTime };
|
||||
const url = s3.getSignedUrl('createBucket', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should put an object', done => {
|
||||
test('should put an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key', Expires:
|
||||
almostOutsideTime };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object with an acl setting and a storage class setting',
|
||||
done => {
|
||||
// This will test that upper case query parameters and lowercase
|
||||
// query parameters (i.e., 'x-amz-acl') are being sorted properly.
|
||||
// This will also test that query params that contain "x-amz-"
|
||||
// are being added to the canonical headers list in our string
|
||||
// to sign.
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
ACL: 'public-read', StorageClass: 'STANDARD' };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should put an object with an acl setting and a storage class setting',
|
||||
done => {
|
||||
// This will test that upper case query parameters and lowercase
|
||||
// query parameters (i.e., 'x-amz-acl') are being sorted properly.
|
||||
// This will also test that query params that contain "x-amz-"
|
||||
// are being added to the canonical headers list in our string
|
||||
// to sign.
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
ACL: 'public-read', StorageClass: 'STANDARD' };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
it('should get an object', done => {
|
||||
test('should get an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key', Expires:
|
||||
almostOutsideTime };
|
||||
const url = s3.getSignedUrl('getObject', params);
|
||||
provideRawOutput(['-verbose', '-o', 'download', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('downloaded file should equal file that was put', done => {
|
||||
test('downloaded file should equal file that was put', done => {
|
||||
diff('uploadFile', 'download', () => {
|
||||
deleteFile('download', done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete an object', done => {
|
||||
test('should delete an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key', Expires:
|
||||
almostOutsideTime };
|
||||
const url = s3.getSignedUrl('deleteObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should delete a bucket', done => {
|
||||
test('should delete a bucket', done => {
|
||||
const params = { Bucket: bucket, Expires: almostOutsideTime };
|
||||
const url = s3.getSignedUrl('deleteBucket', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ const bucket = `mybucket-${random}`;
|
|||
function diff(putFile, receivedFile, done) {
|
||||
process.stdout.write(`diff ${putFile} ${receivedFile}\n`);
|
||||
cp.spawn('diff', [putFile, receivedFile]).on('exit', code => {
|
||||
assert.strictEqual(code, 0);
|
||||
expect(code).toBe(0);
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
@ -26,41 +26,41 @@ function deleteFile(file, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
describe('aws-node-sdk v4auth query tests', function testSuite() {
|
||||
describe('aws-node-sdk v4auth query tests', () => {
|
||||
this.timeout(60000);
|
||||
let s3;
|
||||
|
||||
// setup test
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
|
||||
s3 = new S3(config);
|
||||
});
|
||||
|
||||
// emptyListing test
|
||||
it('should do an empty bucket listing', done => {
|
||||
test('should do an empty bucket listing', done => {
|
||||
const url = s3.getSignedUrl('listBuckets');
|
||||
provideRawOutput(['-verbose', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// createBucket test
|
||||
it('should create a bucket', done => {
|
||||
test('should create a bucket', done => {
|
||||
const params = { Bucket: bucket };
|
||||
const url = s3.getSignedUrl('createBucket', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// fullListing test
|
||||
it('should do a bucket listing with result', done => {
|
||||
test('should do a bucket listing with result', done => {
|
||||
const url = s3.getSignedUrl('listBuckets');
|
||||
provideRawOutput(['-verbose', url], (httpCode, rawOutput) => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
parseString(rawOutput.stdout, (err, xml) => {
|
||||
if (err) {
|
||||
assert.ifError(err);
|
||||
|
@ -68,24 +68,25 @@ describe('aws-node-sdk v4auth query tests', function testSuite() {
|
|||
const bucketNames = xml.ListAllMyBucketsResult
|
||||
.Buckets[0].Bucket.map(item => item.Name[0]);
|
||||
const whereIsMyBucket = bucketNames.indexOf(bucket);
|
||||
assert(whereIsMyBucket > -1);
|
||||
expect(whereIsMyBucket > -1).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// putObject test
|
||||
it('should put an object', done => {
|
||||
test('should put an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key' };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object with an acl setting and a storage class setting',
|
||||
test(
|
||||
'should put an object with an acl setting and a storage class setting',
|
||||
done => {
|
||||
// This will test that upper case query parameters and lowercase
|
||||
// query parameters (i.e., 'x-amz-acl') are being sorted properly.
|
||||
|
@ -98,105 +99,106 @@ describe('aws-node-sdk v4auth query tests', function testSuite() {
|
|||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should put an object with native characters', done => {
|
||||
test('should put an object with native characters', done => {
|
||||
const Key = 'key-pâtisserie-中文-español-English-हिन्दी-العربية-' +
|
||||
'português-বাংলা-русский-日本語-ਪੰਜਾਬੀ-한국어-தமிழ்';
|
||||
const params = { Bucket: bucket, Key };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// listObjects test
|
||||
it('should list objects in bucket', done => {
|
||||
test('should list objects in bucket', done => {
|
||||
const params = { Bucket: bucket };
|
||||
const url = s3.getSignedUrl('listObjects', params);
|
||||
provideRawOutput(['-verbose', url], (httpCode, rawOutput) => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
parseString(rawOutput.stdout, (err, result) => {
|
||||
if (err) {
|
||||
assert.ifError(err);
|
||||
}
|
||||
assert.strictEqual(result.ListBucketResult
|
||||
.Contents[0].Key[0], 'key');
|
||||
expect(result.ListBucketResult
|
||||
.Contents[0].Key[0]).toBe('key');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// getObject test
|
||||
it('should get an object', done => {
|
||||
test('should get an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key' };
|
||||
const url = s3.getSignedUrl('getObject', params);
|
||||
provideRawOutput(['-verbose', '-o', 'download', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
expect(httpCode).toBe('200 OK');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('downloaded file should equal file that was put', done => {
|
||||
test('downloaded file should equal file that was put', done => {
|
||||
diff('uploadFile', 'download', () => {
|
||||
deleteFile('download', done);
|
||||
});
|
||||
});
|
||||
|
||||
// deleteObject test
|
||||
it('should delete an object', done => {
|
||||
test('should delete an object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key' };
|
||||
const url = s3.getSignedUrl('deleteObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a 204 on delete of an already deleted object', done => {
|
||||
test('should return a 204 on delete of an already deleted object', done => {
|
||||
const params = { Bucket: bucket, Key: 'key' };
|
||||
const url = s3.getSignedUrl('deleteObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return 204 on delete of non-existing object', done => {
|
||||
test('should return 204 on delete of non-existing object', done => {
|
||||
const params = { Bucket: bucket, Key: 'randomObject' };
|
||||
const url = s3.getSignedUrl('deleteObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete an object with native characters', done => {
|
||||
test('should delete an object with native characters', done => {
|
||||
const Key = 'key-pâtisserie-中文-español-English-हिन्दी-العربية-' +
|
||||
'português-বাংলা-русский-日本語-ਪੰਜਾਬੀ-한국어-தமிழ்';
|
||||
const params = { Bucket: bucket, Key };
|
||||
const url = s3.getSignedUrl('deleteObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url], httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// deleteBucket test
|
||||
it('should delete a bucket', done => {
|
||||
test('should delete a bucket', done => {
|
||||
const params = { Bucket: bucket };
|
||||
const url = s3.getSignedUrl('deleteBucket', params);
|
||||
provideRawOutput(['-verbose', '-X', 'DELETE', url],
|
||||
httpCode => {
|
||||
assert.strictEqual(httpCode, '204 NO CONTENT');
|
||||
expect(httpCode).toBe('204 NO CONTENT');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,36 +26,36 @@ const objectKey = 'toAbort&<>"\'';
|
|||
// same uploadId
|
||||
const multipartUploadData = {};
|
||||
|
||||
describe('aws-node-sdk test suite as registered user', function testSuite() {
|
||||
describe('aws-node-sdk test suite as registered user', () => {
|
||||
this.timeout(60000);
|
||||
let s3;
|
||||
|
||||
// setup test
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
|
||||
s3 = new S3(config);
|
||||
});
|
||||
|
||||
// bucketListing test
|
||||
it('should do bucket listing', done => {
|
||||
test('should do bucket listing', done => {
|
||||
s3.listBuckets((err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error listing buckets: ${err}`));
|
||||
}
|
||||
|
||||
assert(data.Buckets, 'No buckets Info sent back');
|
||||
assert(data.Owner, 'No owner Info sent back');
|
||||
assert(data.Owner.ID, 'Owner ID not sent back');
|
||||
assert(data.Owner.DisplayName, 'DisplayName not sent back');
|
||||
expect(data.Buckets).toBeTruthy();
|
||||
expect(data.Owner).toBeTruthy();
|
||||
expect(data.Owner.ID).toBeTruthy();
|
||||
expect(data.Owner.DisplayName).toBeTruthy();
|
||||
const owner = Object.keys(data.Owner);
|
||||
assert.strictEqual(owner.length, 2, 'Too much fields in owner');
|
||||
expect(owner.length).toBe(2);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
// createbucket test
|
||||
it('should create a bucket', done => {
|
||||
test('should create a bucket', done => {
|
||||
s3.createBucket({ Bucket: bucket }, err => {
|
||||
if (err) {
|
||||
return done(new Error(`error creating bucket: ${err}`));
|
||||
|
@ -65,22 +65,23 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
});
|
||||
|
||||
// createMPU test
|
||||
it('should create a multipart upload', done => {
|
||||
test('should create a multipart upload', done => {
|
||||
s3.createMultipartUpload({ Bucket: bucket, Key: objectKey },
|
||||
(err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(
|
||||
`error initiating multipart upload: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.Bucket, bucket);
|
||||
assert.strictEqual(data.Key, objectKey);
|
||||
assert.ok(data.UploadId);
|
||||
expect(data.Bucket).toBe(bucket);
|
||||
expect(data.Key).toBe(objectKey);
|
||||
expect(data.UploadId).toBeTruthy();
|
||||
multipartUploadData.firstUploadId = data.UploadId;
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should upload a part of a multipart upload to be aborted',
|
||||
test(
|
||||
'should upload a part of a multipart upload to be aborted',
|
||||
// uploadpart test
|
||||
done => {
|
||||
const params = {
|
||||
|
@ -94,13 +95,14 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
if (err) {
|
||||
return done(new Error(`error uploading a part: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.ETag, `"${calculatedFirstPartHash}"`);
|
||||
expect(data.ETag).toBe(`"${calculatedFirstPartHash}"`);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// abortMPU test
|
||||
it('should abort a multipart upload', done => {
|
||||
test('should abort a multipart upload', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: objectKey,
|
||||
|
@ -111,13 +113,13 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(new Error(
|
||||
`error aborting multipart upload: ${err}`));
|
||||
}
|
||||
assert.ok(data);
|
||||
expect(data).toBeTruthy();
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
// createMPU test
|
||||
it('should upload a part of a multipart upload', done => {
|
||||
test('should upload a part of a multipart upload', done => {
|
||||
s3.createMultipartUpload({ Bucket: bucket, Key: 'toComplete' },
|
||||
(err, data) => {
|
||||
if (err) {
|
||||
|
@ -138,35 +140,33 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(
|
||||
new Error(`error uploading a part: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.ETag,
|
||||
`"${calculatedFirstPartHash}"`);
|
||||
expect(data.ETag).toBe(`"${calculatedFirstPartHash}"`);
|
||||
return done();
|
||||
});
|
||||
return undefined;
|
||||
});
|
||||
});
|
||||
|
||||
it('should upload a second part of a multipart upload',
|
||||
// createMPU test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
PartNumber: 2,
|
||||
UploadId: multipartUploadData.secondUploadId,
|
||||
Body: secondBufferBody,
|
||||
};
|
||||
s3.uploadPart(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error uploading a part: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.ETag, `"${calculatedSecondPartHash}"`);
|
||||
return done();
|
||||
});
|
||||
test('should upload a second part of a multipart upload', // createMPU test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
PartNumber: 2,
|
||||
UploadId: multipartUploadData.secondUploadId,
|
||||
Body: secondBufferBody,
|
||||
};
|
||||
s3.uploadPart(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error uploading a part: ${err}`));
|
||||
}
|
||||
expect(data.ETag).toBe(`"${calculatedSecondPartHash}"`);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
// listparts test
|
||||
it('should list the parts of a multipart upload', done => {
|
||||
test('should list the parts of a multipart upload', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
|
@ -176,19 +176,17 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
if (err) {
|
||||
return done(new Error(`error listing parts: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.Bucket, bucket);
|
||||
assert.strictEqual(data.Key, 'toComplete');
|
||||
assert.strictEqual(data.UploadId, multipartUploadData
|
||||
expect(data.Bucket).toBe(bucket);
|
||||
expect(data.Key).toBe('toComplete');
|
||||
expect(data.UploadId).toBe(multipartUploadData
|
||||
.secondUploadId);
|
||||
assert.strictEqual(data.IsTruncated, false);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(data.Parts[0].ETag,
|
||||
`"${calculatedFirstPartHash}"`);
|
||||
assert.strictEqual(data.Parts[0].Size, 5242880);
|
||||
assert.strictEqual(data.Parts[1].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[1].ETag,
|
||||
`"${calculatedSecondPartHash}"`);
|
||||
assert.strictEqual(data.Parts[1].Size, 5242880);
|
||||
expect(data.IsTruncated).toBe(false);
|
||||
expect(data.Parts[0].PartNumber).toBe(1);
|
||||
expect(data.Parts[0].ETag).toBe(`"${calculatedFirstPartHash}"`);
|
||||
expect(data.Parts[0].Size).toBe(5242880);
|
||||
expect(data.Parts[1].PartNumber).toBe(2);
|
||||
expect(data.Parts[1].ETag).toBe(`"${calculatedSecondPartHash}"`);
|
||||
expect(data.Parts[1].Size).toBe(5242880);
|
||||
// Must disable for now when running with Vault
|
||||
// since will need to pull actual ARN and canonicalId
|
||||
// assert.strictEqual(data.Initiator.ID, accessKey1ARN);
|
||||
|
@ -197,13 +195,13 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
// call works. For real implementation with vault,
|
||||
// will need the canonicalId.
|
||||
// assert.strictEqual(data.Owner.ID, config.accessKeyId);
|
||||
assert.strictEqual(data.StorageClass, 'STANDARD');
|
||||
expect(data.StorageClass).toBe('STANDARD');
|
||||
return {};
|
||||
});
|
||||
return done();
|
||||
});
|
||||
|
||||
it('should return an error if do not provide correct ' +
|
||||
test('should return an error if do not provide correct ' +
|
||||
// completempu test
|
||||
'xml when completing a multipart upload', done => {
|
||||
const params = {
|
||||
|
@ -212,13 +210,13 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
UploadId: multipartUploadData.secondUploadId,
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.strictEqual(err.code, 'MalformedXML');
|
||||
expect(err.code).toBe('MalformedXML');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
// completempu test
|
||||
it('should complete a multipart upload', done => {
|
||||
test('should complete a multipart upload', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
|
@ -240,14 +238,14 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
if (err) {
|
||||
return done(new Error(`error completing mpu: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.Bucket, bucket);
|
||||
assert.strictEqual(data.Key, 'toComplete');
|
||||
assert.strictEqual(data.ETag, combinedETag);
|
||||
expect(data.Bucket).toBe(bucket);
|
||||
expect(data.Key).toBe('toComplete');
|
||||
expect(data.ETag).toBe(combinedETag);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get an object put by multipart upload', done => {
|
||||
test('should get an object put by multipart upload', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
|
@ -257,8 +255,7 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(new Error(
|
||||
`error getting object put by mpu: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.ETag,
|
||||
combinedETag);
|
||||
expect(data.ETag).toBe(combinedETag);
|
||||
const uploadedObj = Buffer.concat([firstBufferBody,
|
||||
secondBufferBody]);
|
||||
assert.deepStrictEqual(data.Body, uploadedObj);
|
||||
|
@ -316,7 +313,7 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
];
|
||||
|
||||
mpuRangeGetTests.forEach(test => {
|
||||
it(test.it, done => {
|
||||
test(test.it, done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
|
@ -327,34 +324,32 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(new Error(
|
||||
`error getting object range put by mpu: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.ContentLength, test.contentLength);
|
||||
assert.strictEqual(data.AcceptRanges, 'bytes');
|
||||
assert.strictEqual(data.ContentRange, test.contentRange);
|
||||
assert.strictEqual(data.ETag,
|
||||
combinedETag);
|
||||
expect(data.ContentLength).toBe(test.contentLength);
|
||||
expect(data.AcceptRanges).toBe('bytes');
|
||||
expect(data.ContentRange).toBe(test.contentRange);
|
||||
expect(data.ETag).toBe(combinedETag);
|
||||
assert.deepStrictEqual(data.Body, test.expectedBuff);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete object created by multipart upload',
|
||||
// deleteObject test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
};
|
||||
s3.deleteObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error deleting object: ${err}`));
|
||||
}
|
||||
assert.ok(data);
|
||||
return done();
|
||||
});
|
||||
test('should delete object created by multipart upload', // deleteObject test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'toComplete',
|
||||
};
|
||||
s3.deleteObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error deleting object: ${err}`));
|
||||
}
|
||||
expect(data).toBeTruthy();
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object regularly (non-MPU)', done => {
|
||||
test('should put an object regularly (non-MPU)', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'normalput',
|
||||
|
@ -365,22 +360,21 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(new Error(
|
||||
`error putting object regularly: ${err}`));
|
||||
}
|
||||
assert.ok(data);
|
||||
expect(data).toBeTruthy();
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidRange if the range of the resource does ' +
|
||||
'not cover the byte range',
|
||||
done => {
|
||||
test('should return InvalidRange if the range of the resource does ' +
|
||||
'not cover the byte range', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'normalput',
|
||||
Range: 'bytes=200-200',
|
||||
};
|
||||
s3.getObject(params, err => {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'InvalidRange');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('InvalidRange');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -420,9 +414,8 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
});
|
||||
testsRangeOnEmptyFile.forEach(test => {
|
||||
const validText = test.valid ? 'InvalidRange error' : 'empty file';
|
||||
it(`should return ${validText} if get range ${test.range} on ` +
|
||||
'empty object',
|
||||
done => {
|
||||
test(`should return ${validText} if get range ${test.range} on ` +
|
||||
'empty object', done => {
|
||||
const params = {
|
||||
Bucket: bucketEmptyObj,
|
||||
Key: 'emptyobj',
|
||||
|
@ -430,13 +423,11 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
};
|
||||
s3.getObject(params, (err, data) => {
|
||||
if (test.valid) {
|
||||
assert.notEqual(err, null, 'Expected failure but ' +
|
||||
'got success');
|
||||
assert.strictEqual(err.code, 'InvalidRange');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('InvalidRange');
|
||||
} else {
|
||||
assert.equal(err, null, 'Expected success but ' +
|
||||
`got failure: ${err}`);
|
||||
assert.strictEqual(data.Body.toString(), '');
|
||||
expect(err).toEqual(null);
|
||||
expect(data.Body.toString()).toBe('');
|
||||
}
|
||||
return done();
|
||||
});
|
||||
|
@ -477,7 +468,7 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
];
|
||||
|
||||
regularObjectRangeGetTests.forEach(test => {
|
||||
it(test.it, done => {
|
||||
test(test.it, done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'normalput',
|
||||
|
@ -488,33 +479,32 @@ describe('aws-node-sdk test suite as registered user', function testSuite() {
|
|||
return done(new Error(
|
||||
`error getting object range: ${err}`));
|
||||
}
|
||||
assert.strictEqual(data.AcceptRanges, 'bytes');
|
||||
assert.strictEqual(data.ContentLength, test.contentLength);
|
||||
assert.strictEqual(data.ContentRange, test.contentRange);
|
||||
expect(data.AcceptRanges).toBe('bytes');
|
||||
expect(data.ContentLength).toBe(test.contentLength);
|
||||
expect(data.ContentRange).toBe(test.contentRange);
|
||||
assert.deepStrictEqual(data.Body, test.expectedBuff);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete an object put without MPU',
|
||||
// deleteObject test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'normalput',
|
||||
};
|
||||
s3.deleteObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error deleting object: ${err}`));
|
||||
}
|
||||
assert.ok(data);
|
||||
return done();
|
||||
});
|
||||
test('should delete an object put without MPU', // deleteObject test
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: 'normalput',
|
||||
};
|
||||
s3.deleteObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(new Error(`error deleting object: ${err}`));
|
||||
}
|
||||
expect(data).toBeTruthy();
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
// deletebucket test
|
||||
it('should delete a bucket', done => {
|
||||
test('should delete a bucket', done => {
|
||||
s3.deleteBucket({ Bucket: bucket }, err => {
|
||||
if (err) {
|
||||
return done(new Error(`error deleting bucket: ${err}`));
|
||||
|
|
|
@ -10,7 +10,7 @@ const updatedUserMetadata = { food: 'cake' };
|
|||
|
||||
runIfMongo('Basic search', () => {
|
||||
const bucketName = `basicsearchmebucket${Date.now()}`;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.createBucket({ Bucket: bucketName }, err => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -26,7 +26,7 @@ runIfMongo('Basic search', () => {
|
|||
});
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3Client.deleteObjects({ Bucket: bucketName, Delete: { Objects: [
|
||||
{ Key: objectKey },
|
||||
{ Key: hiddenKey }],
|
||||
|
@ -39,46 +39,48 @@ runIfMongo('Basic search', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should list object with searched for system metadata', done => {
|
||||
test('should list object with searched for system metadata', done => {
|
||||
const encodedSearch = encodeURIComponent(`key="${objectKey}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, objectKey, done);
|
||||
});
|
||||
|
||||
it('should list object with regex searched for system metadata', done => {
|
||||
test('should list object with regex searched for system metadata', done => {
|
||||
const encodedSearch = encodeURIComponent('key LIKE "find.*"');
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, objectKey, done);
|
||||
});
|
||||
|
||||
it('should list object with regex searched for system metadata with flags',
|
||||
done => {
|
||||
const encodedSearch = encodeURIComponent('key LIKE "/FIND.*/i"');
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, objectKey, done);
|
||||
});
|
||||
test(
|
||||
'should list object with regex searched for system metadata with flags',
|
||||
done => {
|
||||
const encodedSearch = encodeURIComponent('key LIKE "/FIND.*/i"');
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, objectKey, done);
|
||||
}
|
||||
);
|
||||
|
||||
it('should return empty when no object match regex', done => {
|
||||
test('should return empty when no object match regex', done => {
|
||||
const encodedSearch = encodeURIComponent('key LIKE "/NOTFOUND.*/i"');
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, null, done);
|
||||
});
|
||||
|
||||
it('should list object with searched for user metadata', done => {
|
||||
test('should list object with searched for user metadata', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent(`x-amz-meta-food="${userMetadata.food}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName, encodedSearch,
|
||||
objectKey, done);
|
||||
});
|
||||
|
||||
it('should list object with searched for tag metadata', done => {
|
||||
test('should list object with searched for tag metadata', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent('tags.item-type="main"');
|
||||
return runAndCheckSearch(s3Client, bucketName, encodedSearch,
|
||||
objectKey, done);
|
||||
});
|
||||
|
||||
it('should return empty listing when no object has user md', done => {
|
||||
test('should return empty listing when no object has user md', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent('x-amz-meta-food="nosuchfood"');
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
|
@ -86,33 +88,32 @@ runIfMongo('Basic search', () => {
|
|||
});
|
||||
|
||||
describe('search when overwrite object', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.putObject({ Bucket: bucketName, Key: objectKey,
|
||||
Metadata: updatedUserMetadata }, done);
|
||||
});
|
||||
|
||||
it('should list object with searched for updated user metadata',
|
||||
done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent('x-amz-meta-food' +
|
||||
`="${updatedUserMetadata.food}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName, encodedSearch,
|
||||
objectKey, done);
|
||||
});
|
||||
test('should list object with searched for updated user metadata', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent('x-amz-meta-food' +
|
||||
`="${updatedUserMetadata.food}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName, encodedSearch,
|
||||
objectKey, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
runIfMongo('Search when no objects in bucket', () => {
|
||||
const bucketName = `noobjectbucket${Date.now()}`;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.createBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3Client.deleteBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
|
||||
it('should return empty listing when no objects in bucket', done => {
|
||||
test('should return empty listing when no objects in bucket', done => {
|
||||
const encodedSearch = encodeURIComponent(`key="${objectKey}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
encodedSearch, null, done);
|
||||
|
@ -121,15 +122,15 @@ runIfMongo('Search when no objects in bucket', () => {
|
|||
|
||||
runIfMongo('Invalid regular expression searches', () => {
|
||||
const bucketName = `badregex-${Date.now()}`;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.createBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3Client.deleteBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
|
||||
it('should return error if pattern is invalid', done => {
|
||||
test('should return error if pattern is invalid', done => {
|
||||
const encodedSearch = encodeURIComponent('key LIKE "/((helloworld/"');
|
||||
const testError = {
|
||||
code: 'InvalidArgument',
|
||||
|
|
|
@ -28,18 +28,18 @@ testUtils.runAndCheckSearch = (s3Client, bucketName, encodedSearch,
|
|||
});
|
||||
searchRequest.on('success', res => {
|
||||
if (testResult) {
|
||||
assert(res.data.Contents[0], 'should be Contents listed');
|
||||
assert.strictEqual(res.data.Contents[0].Key, testResult);
|
||||
assert.strictEqual(res.data.Contents.length, 1);
|
||||
expect(res.data.Contents[0]).toBeTruthy();
|
||||
expect(res.data.Contents[0].Key).toBe(testResult);
|
||||
expect(res.data.Contents.length).toBe(1);
|
||||
} else {
|
||||
assert.strictEqual(res.data.Contents.length, 0);
|
||||
expect(res.data.Contents.length).toBe(0);
|
||||
}
|
||||
return done();
|
||||
});
|
||||
searchRequest.on('error', err => {
|
||||
if (testResult) {
|
||||
assert.strictEqual(err.code, testResult.code);
|
||||
assert.strictEqual(err.message, testResult.message);
|
||||
expect(err.code).toBe(testResult.code);
|
||||
expect(err.message).toBe(testResult.message);
|
||||
}
|
||||
return done();
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ runIfMongo('Search in version enabled bucket', () => {
|
|||
MFADelete: 'Disabled',
|
||||
Status: 'Enabled',
|
||||
};
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.createBucket({ Bucket: bucketName }, err => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -28,7 +28,7 @@ runIfMongo('Search in version enabled bucket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
removeAllVersions(s3Client, bucketName,
|
||||
err => {
|
||||
if (err) {
|
||||
|
@ -38,7 +38,7 @@ runIfMongo('Search in version enabled bucket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should list just master object with searched for metadata', done => {
|
||||
test('should list just master object with searched for metadata', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent(`x-amz-meta-food="${userMetadata.food}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
|
@ -46,12 +46,12 @@ runIfMongo('Search in version enabled bucket', () => {
|
|||
});
|
||||
|
||||
describe('New version overwrite', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3Client.putObject({ Bucket: bucketName,
|
||||
Key: masterKey, Metadata: updatedMetadata }, done);
|
||||
});
|
||||
|
||||
it('should list just master object with updated metadata', done => {
|
||||
test('should list just master object with updated metadata', done => {
|
||||
const encodedSearch =
|
||||
encodeURIComponent(`x-amz-meta-food="${updatedMetadata.food}"`);
|
||||
return runAndCheckSearch(s3Client, bucketName,
|
||||
|
|
|
@ -58,8 +58,7 @@ testAcp.addGrantee('Group', constants.publicId, 'READ');
|
|||
function putObjectAcl(s3, key, versionId, acp, cb) {
|
||||
s3.putObjectAcl({ Bucket: bucket, Key: key, AccessControlPolicy: acp,
|
||||
VersionId: versionId }, err => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object acl, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -67,8 +66,7 @@ function putObjectAcl(s3, key, versionId, acp, cb) {
|
|||
function putObjectAndAcl(s3, key, body, acp, cb) {
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: body },
|
||||
(err, putData) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
putObjectAcl(s3, key, putData.VersionId, acp, () =>
|
||||
cb(null, putData.VersionId));
|
||||
});
|
||||
|
@ -91,8 +89,7 @@ function putVersionsWithAclToAws(s3, key, data, acps, cb) {
|
|||
async.timesLimit(data.length, 1, (i, next) => {
|
||||
putObjectAndAcl(s3, key, data[i], acps[i], next);
|
||||
}, (err, results) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting versions with acl, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb(null, results);
|
||||
});
|
||||
});
|
||||
|
@ -105,9 +102,8 @@ function getObjectAndAssertAcl(s3, params, cb) {
|
|||
() => {
|
||||
s3.getObjectAcl({ Bucket: bucket, Key: key, VersionId: versionId },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`getting object acl, got error ${err}`);
|
||||
assert.deepEqual(data, expectedResult);
|
||||
expect(err).toBe(null);
|
||||
expect(data).toEqual(expectedResult);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -133,8 +129,7 @@ function getObjectsAndAssertAcls(s3, key, versionIds, expectedData,
|
|||
getObjectAndAssertAcl(s3, { bucket, key, versionId, body,
|
||||
expectedResult, expectedVersionId: versionId }, next);
|
||||
}, err => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`getting object acls, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -175,19 +170,18 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: should put/get acl successfully when ' +
|
||||
test('versioning not configured: should put/get acl successfully when ' +
|
||||
'versioning not configured', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
putObjectAndAcl(s3, key, someBody, testAcp, (err, versionId) => {
|
||||
assert.strictEqual(versionId, undefined);
|
||||
expect(versionId).toBe(undefined);
|
||||
getObjectAndAssertAcl(s3, { bucket, key, body: someBody,
|
||||
expectedResult: testAcp }, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('versioning suspended then enabled: should put/get acl on null ' +
|
||||
'version successfully even when latest version is not null version',
|
||||
done => {
|
||||
test('versioning suspended then enabled: should put/get acl on null ' +
|
||||
'version successfully even when latest version is not null version', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => putNullVersionsToAws(s3, bucket, key, [undefined],
|
||||
|
@ -201,8 +195,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should get correct acl using version IDs',
|
||||
done => {
|
||||
test('versioning enabled: should get correct acl using version IDs', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const acps = ['READ', 'FULL_CONTROL', 'READ_ACP', 'WRITE_ACP']
|
||||
.map(perm => {
|
||||
|
@ -226,7 +219,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should get correct acl when getting ' +
|
||||
test('versioning enabled: should get correct acl when getting ' +
|
||||
'without version ID', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const acps = ['READ', 'FULL_CONTROL', 'READ_ACP', 'WRITE_ACP']
|
||||
|
|
|
@ -26,7 +26,7 @@ describeSkipIfNotMultiple('Multiple backend delete', () => {
|
|||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -78,7 +78,7 @@ describeSkipIfNotMultiple('Multiple backend delete', () => {
|
|||
throw err;
|
||||
});
|
||||
});
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Deleting bucket\n');
|
||||
return bucketUtil.deleteOne(bucket)
|
||||
.catch(err => {
|
||||
|
@ -87,69 +87,57 @@ describeSkipIfNotMultiple('Multiple backend delete', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should delete object from mem', done => {
|
||||
test('should delete object from mem', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: memObject }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket: bucket, Key: memObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete object from file', done => {
|
||||
test('should delete object from file', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: fileObject }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket: bucket, Key: fileObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete object from AWS', done => {
|
||||
test('should delete object from AWS', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: awsObject }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket: bucket, Key: awsObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete 0-byte object from AWS', done => {
|
||||
test('should delete 0-byte object from AWS', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: emptyObject }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket: bucket, Key: emptyObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete large object from AWS', done => {
|
||||
test('should delete large object from AWS', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: bigObject }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket: bucket, Key: bigObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should delete object from AWS location with bucketMatch set to ' +
|
||||
test('should delete object from AWS location with bucketMatch set to ' +
|
||||
'false', done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: mismatchObject }, err => {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: mismatchObject }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey',
|
||||
'Expected error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -47,17 +47,16 @@ function _assertDeleteResult(result, resultType, requestVersionId) {
|
|||
const [expectVersionId, matchReqVersionId, expectDeleteMarker] =
|
||||
_deleteResultSchema[resultType];
|
||||
if (expectVersionId && matchReqVersionId) {
|
||||
assert.strictEqual(result.VersionId, requestVersionId);
|
||||
expect(result.VersionId).toBe(requestVersionId);
|
||||
} else if (expectVersionId) {
|
||||
assert(result.VersionId, 'expected version id in result');
|
||||
expect(result.VersionId).toBeTruthy();
|
||||
} else {
|
||||
assert.strictEqual(result.VersionId, undefined,
|
||||
`did not expect version id in result, got "${result.VersionId}"`);
|
||||
expect(result.VersionId).toBe(undefined);
|
||||
}
|
||||
if (expectDeleteMarker) {
|
||||
assert.strictEqual(result.DeleteMarker, 'true');
|
||||
expect(result.DeleteMarker).toBe('true');
|
||||
} else {
|
||||
assert.strictEqual(result.DeleteMarker, undefined);
|
||||
expect(result.DeleteMarker).toBe(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,13 +65,12 @@ function delAndAssertResult(s3, params, cb) {
|
|||
return s3.deleteObject({ Bucket: bucket, Key: key, VersionId:
|
||||
versionId }, (err, result) => {
|
||||
if (resultError) {
|
||||
assert(err, `expected ${resultError} but found no error`);
|
||||
assert.strictEqual(err.code, resultError);
|
||||
assert.strictEqual(err.statusCode, errors[resultError].code);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(resultError);
|
||||
expect(err.statusCode).toBe(errors[resultError].code);
|
||||
return cb(null);
|
||||
}
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`deleting object, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
_assertDeleteResult(result, resultType, versionId);
|
||||
return cb(null, result.VersionId);
|
||||
});
|
||||
|
@ -96,8 +94,8 @@ function _getAssertDeleted(s3, params, cb) {
|
|||
const { key, versionId, errorCode } = params;
|
||||
return s3.getObject({ Bucket: bucket, Key: key, VersionId: versionId },
|
||||
err => {
|
||||
assert.strictEqual(err.code, errorCode);
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err.code).toBe(errorCode);
|
||||
expect(err.statusCode).toBe(404);
|
||||
return cb();
|
||||
});
|
||||
}
|
||||
|
@ -105,8 +103,8 @@ function _getAssertDeleted(s3, params, cb) {
|
|||
function _awsGetAssertDeleted(params, cb) {
|
||||
const { key, versionId, errorCode } = params;
|
||||
return getAwsRetry({ key, versionId }, 0, err => {
|
||||
assert.strictEqual(err.code, errorCode);
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
expect(err.code).toBe(errorCode);
|
||||
expect(err.statusCode).toBe(404);
|
||||
return cb();
|
||||
});
|
||||
}
|
||||
|
@ -142,7 +140,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: if specifying "null" version, should ' +
|
||||
test('versioning not configured: if specifying "null" version, should ' +
|
||||
'delete specific version in AWS backend', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -160,7 +158,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning not configured: specifying any version id other ' +
|
||||
test('versioning not configured: specifying any version id other ' +
|
||||
'than null should not result in its deletion in AWS backend', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -172,13 +170,13 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
'InvalidArgument' }, err => next(err, awsVerId)),
|
||||
(awsVerId, next) => awsGetLatestVerId(key, someBody,
|
||||
(err, resultVid) => {
|
||||
assert.strictEqual(resultVid, awsVerId);
|
||||
expect(resultVid).toBe(awsVerId);
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should delete a specific version in AWS ' +
|
||||
test('versioning suspended: should delete a specific version in AWS ' +
|
||||
'backend successfully', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -196,7 +194,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should delete a specific version in AWS ' +
|
||||
test('versioning enabled: should delete a specific version in AWS ' +
|
||||
'backend successfully', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -215,7 +213,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning not configured: deleting existing object should ' +
|
||||
test('versioning not configured: deleting existing object should ' +
|
||||
'not return version id or x-amz-delete-marker: true but should ' +
|
||||
'create a delete marker in aws ', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
|
@ -231,7 +229,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should create a delete marker in s3 ' +
|
||||
test('versioning suspended: should create a delete marker in s3 ' +
|
||||
'and aws successfully when deleting existing object', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -249,10 +247,9 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
// NOTE: Normal deletes when versioning is suspended create a
|
||||
// delete marker with the version id "null", which overwrites an
|
||||
// existing null version in s3 metadata.
|
||||
it('versioning suspended: creating a delete marker will overwrite an ' +
|
||||
test('versioning suspended: creating a delete marker will overwrite an ' +
|
||||
'existing null version that is the latest version in s3 metadata,' +
|
||||
' but the data of the first null version will remain in AWS',
|
||||
function itF(done) {
|
||||
' but the data of the first null version will remain in AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => putNullVersionsToAws(s3, bucket, key, [someBody],
|
||||
|
@ -275,7 +272,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
// get directly to aws however will give us first null version
|
||||
next => awsGetLatestVerId(key, someBody, next),
|
||||
(awsLatestVid, next) => {
|
||||
assert.strictEqual(awsLatestVid, this.test.awsNullVid);
|
||||
expect(awsLatestVid).toBe(this.test.awsNullVid);
|
||||
next();
|
||||
},
|
||||
], done);
|
||||
|
@ -284,10 +281,9 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
// NOTE: Normal deletes when versioning is suspended create a
|
||||
// delete marker with the version id "null" which is supposed to
|
||||
// overwrite any existing null version.
|
||||
it('versioning suspended: creating a delete marker will overwrite an ' +
|
||||
test('versioning suspended: creating a delete marker will overwrite an ' +
|
||||
'existing null version that is not the latest version in s3 metadata,' +
|
||||
' but the data of the first null version will remain in AWS',
|
||||
function itF(done) {
|
||||
' but the data of the first null version will remain in AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [undefined, 'data1'];
|
||||
async.waterfall([
|
||||
|
@ -329,13 +325,13 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
// when getting the latest version in AWS now
|
||||
next => awsGetLatestVerId(key, '', next),
|
||||
(awsLatestVid, next) => {
|
||||
assert.strictEqual(awsLatestVid, this.test.awsNullVid);
|
||||
expect(awsLatestVid).toBe(this.test.awsNullVid);
|
||||
next();
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should create a delete marker in s3 and ' +
|
||||
test('versioning enabled: should create a delete marker in s3 and ' +
|
||||
'aws successfully when deleting existing object', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -350,7 +346,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should delete a delete marker in s3 and ' +
|
||||
test('versioning enabled: should delete a delete marker in s3 and ' +
|
||||
'aws successfully', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -372,7 +368,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('multiple delete markers: should be able to get pre-existing ' +
|
||||
test('multiple delete markers: should be able to get pre-existing ' +
|
||||
'versions after creating and deleting several delete markers', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -390,7 +386,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('multiple delete markers: should get NoSuchObject if only ' +
|
||||
test('multiple delete markers: should get NoSuchObject if only ' +
|
||||
'one of the delete markers is deleted', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -408,7 +404,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get the new latest version after deleting the latest' +
|
||||
test('should get the new latest version after deleting the latest' +
|
||||
'specific version', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [...Array(4).keys()].map(i => i.toString());
|
||||
|
@ -441,7 +437,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should delete the correct version even if other versions or ' +
|
||||
test('should delete the correct version even if other versions or ' +
|
||||
'delete markers put directly on aws', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -469,7 +465,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should not return an error deleting a version that was already ' +
|
||||
test('should not return an error deleting a version that was already ' +
|
||||
'deleted directly from AWS backend', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -528,7 +524,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: deleting non-existing object should ' +
|
||||
test('versioning not configured: deleting non-existing object should ' +
|
||||
'not return version id or x-amz-delete-marker: true nor create a ' +
|
||||
'delete marker in aws ', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
|
@ -542,7 +538,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should create a delete marker in s3 ' +
|
||||
test('versioning suspended: should create a delete marker in s3 ' +
|
||||
'and aws successfully when deleting non-existing object', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -556,7 +552,7 @@ describeSkipIfNotMultiple('AWS backend delete object w. versioning: ' +
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should create a delete marker in s3 and ' +
|
||||
test('versioning enabled: should create a delete marker in s3 and ' +
|
||||
'aws successfully when deleting non-existing object', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
|
|
@ -32,7 +32,7 @@ function testSuite() {
|
|||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -43,7 +43,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(azureContainerName)
|
||||
.then(() => {
|
||||
|
@ -59,7 +59,7 @@ function testSuite() {
|
|||
keys.forEach(key => {
|
||||
const keyName = uniqName(keyObject);
|
||||
describe(`${key.describe} size`, () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: keyName,
|
||||
|
@ -70,19 +70,17 @@ function testSuite() {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it(`should delete an ${key.describe} object from Azure`,
|
||||
done => {
|
||||
test(`should delete an ${key.describe} object from Azure`, done => {
|
||||
s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: keyName,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success ' +
|
||||
`but got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() =>
|
||||
azureClient.getBlobProperties(azureContainerName,
|
||||
keyName, err => {
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
assert.strictEqual(err.code, 'NotFound');
|
||||
expect(err.statusCode).toBe(404);
|
||||
expect(err.code).toBe('NotFound');
|
||||
return done();
|
||||
}), azureTimeout);
|
||||
});
|
||||
|
@ -92,11 +90,17 @@ function testSuite() {
|
|||
|
||||
describe('delete from Azure location with bucketMatch set to false',
|
||||
() => {
|
||||
beforeEach(function beforeF(done) {
|
||||
this.currentTest.azureObject = uniqName(keyObject);
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.azureObject = uniqName(keyObject);
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.azureObject,
|
||||
Key: testContext.currentTest.azureObject,
|
||||
Body: normalBody,
|
||||
Metadata: {
|
||||
'scal-location-constraint': azureLocationMismatch,
|
||||
|
@ -104,19 +108,18 @@ function testSuite() {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it('should delete object', function itF(done) {
|
||||
test('should delete object', done => {
|
||||
s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.azureObject,
|
||||
Key: testContext.test.azureObject,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success ' +
|
||||
`but got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() =>
|
||||
azureClient.getBlobProperties(azureContainerName,
|
||||
`${azureContainerName}/${this.test.azureObject}`,
|
||||
`${azureContainerName}/${testContext.test.azureObject}`,
|
||||
err => {
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
assert.strictEqual(err.code, 'NotFound');
|
||||
expect(err.statusCode).toBe(404);
|
||||
expect(err.code).toBe('NotFound');
|
||||
return done();
|
||||
}), azureTimeout);
|
||||
});
|
||||
|
@ -124,46 +127,55 @@ function testSuite() {
|
|||
});
|
||||
|
||||
describe('returning no error', () => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.azureObject = uniqName(keyObject);
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.azureObject = uniqName(keyObject);
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.azureObject,
|
||||
Key: testContext.currentTest.azureObject,
|
||||
Body: normalBody,
|
||||
Metadata: {
|
||||
'scal-location-constraint': azureLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
azureClient.deleteBlob(azureContainerName,
|
||||
this.currentTest.azureObject, err => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
testContext.currentTest.azureObject, err => {
|
||||
expect(err).toEqual(null);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return no error on deleting an object deleted ' +
|
||||
'from Azure', function itF(done) {
|
||||
test('should return no error on deleting an object deleted ' +
|
||||
'from Azure', done => {
|
||||
s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.azureObject,
|
||||
Key: testContext.test.azureObject,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Versioning:: ', () => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.azureObject = uniqName(keyObject);
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.azureObject = uniqName(keyObject);
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.azureObject,
|
||||
Key: testContext.currentTest.azureObject,
|
||||
Body: normalBody,
|
||||
Metadata: {
|
||||
'scal-location-constraint': azureLocation,
|
||||
|
@ -171,27 +183,25 @@ function testSuite() {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it('should not delete object when deleting a non-existing ' +
|
||||
'version from Azure', function itF(done) {
|
||||
test('should not delete object when deleting a non-existing ' +
|
||||
'version from Azure', done => {
|
||||
async.waterfall([
|
||||
next => s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.azureObject,
|
||||
Key: testContext.test.azureObject,
|
||||
VersionId: nonExistingId,
|
||||
}, err => next(err)),
|
||||
next => s3.getObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.azureObject,
|
||||
Key: testContext.test.azureObject,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'getObject: Expected success ' +
|
||||
`but got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
assert.deepStrictEqual(res.Body, normalBody);
|
||||
return next(err);
|
||||
}),
|
||||
next => azureClient.getBlobToText(azureContainerName,
|
||||
this.test.azureObject, (err, res) => {
|
||||
assert.equal(err, null, 'getBlobToText: Expected ' +
|
||||
`successbut got error ${err}`);
|
||||
testContext.test.azureObject, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
assert.deepStrictEqual(Buffer.from(res, 'utf8'),
|
||||
normalBody);
|
||||
return next();
|
||||
|
@ -201,48 +211,52 @@ function testSuite() {
|
|||
});
|
||||
|
||||
describe('with ongoing MPU: ', () => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.key = uniqName(keyObject);
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Err putting object to Azure: ' +
|
||||
`${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.createMultipartUpload(params, (err, res) => {
|
||||
assert.equal(err, null, 'Err initiating MPU on ' +
|
||||
`Azure: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
setTimeout(() => done(), azureTimeout);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function afF(done) {
|
||||
afterEach(done => {
|
||||
s3.abortMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => {
|
||||
assert.equal(err, null, `Err aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() => done(), azureTimeout);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InternalError', function itFn(done) {
|
||||
test('should return InternalError', done => {
|
||||
s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
Key: testContext.test.key,
|
||||
}, err => {
|
||||
assert.strictEqual(err.code, 'MPUinProgress');
|
||||
expect(err.code).toBe('MPUinProgress');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ function testSuite() {
|
|||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -63,7 +63,7 @@ function testSuite() {
|
|||
throw err;
|
||||
});
|
||||
});
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Deleting bucket\n');
|
||||
return bucketUtil.deleteOne(bucket)
|
||||
.catch(err => {
|
||||
|
@ -93,22 +93,21 @@ function testSuite() {
|
|||
];
|
||||
deleteTests.forEach(test => {
|
||||
const { msg, Bucket, Key } = test;
|
||||
it(msg, done => s3.deleteObject({ Bucket, Key }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
test(msg, done => s3.deleteObject({ Bucket, Key }, err => {
|
||||
expect(err).toBe(null);
|
||||
s3.getObject({ Bucket, Key }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey', 'Expected ' +
|
||||
'error but got success');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should return success if the object does not exist',
|
||||
test(
|
||||
'should return success if the object does not exist',
|
||||
done => s3.deleteObject({ Bucket: bucket, Key: 'noop' }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
}));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,12 +26,18 @@ const correctMD5 = 'be747eb4b75517bf6b3cf7c5fbb62f3a';
|
|||
const emptyMD5 = 'd41d8cd98f00b204e9800998ecf8427e';
|
||||
const bigMD5 = 'f1c9645dbc14efddc7d8a322685f26eb';
|
||||
|
||||
describe('Multiple backend get object', function testSuite() {
|
||||
describe('Multiple backend get object', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
this.timeout(30000);
|
||||
withV4(sigCfg => {
|
||||
let bucketUtil;
|
||||
let s3;
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -42,7 +48,7 @@ describe('Multiple backend get object', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucket)
|
||||
.then(() => {
|
||||
|
@ -56,47 +62,46 @@ describe('Multiple backend get object', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return an error to get request without a valid bucket name',
|
||||
test(
|
||||
'should return an error to get request without a valid bucket name',
|
||||
done => {
|
||||
s3.getObject({ Bucket: '', Key: 'somekey' }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'MethodNotAllowed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return NoSuchKey error when no such object',
|
||||
done => {
|
||||
s3.getObject({ Bucket: bucket, Key: 'nope' }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'NoSuchKey');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('MethodNotAllowed');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
test('should return NoSuchKey error when no such object', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: 'nope' }, err => {
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describeSkipIfNotMultiple('Complete MPU then get object on AWS ' +
|
||||
'location with bucketMatch: true ', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket, Key: this.currentTest.key,
|
||||
Bucket: bucket, Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': awsLocation,
|
||||
} }, (err, res) => next(err, res.UploadId)),
|
||||
(uploadId, next) => s3.uploadPart({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
Body: 'helloworld' }, (err, res) => next(err, uploadId,
|
||||
res.ETag)),
|
||||
(uploadId, eTag, next) => s3.completeMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
MultipartUpload: {
|
||||
Parts: [
|
||||
{
|
||||
|
@ -109,16 +114,15 @@ describe('Multiple backend get object', function testSuite() {
|
|||
}, err => next(err)),
|
||||
], done);
|
||||
});
|
||||
it('should get object from MPU on AWS ' +
|
||||
'location with bucketMatch: true ', function it(done) {
|
||||
test('should get object from MPU on AWS ' +
|
||||
'location with bucketMatch: true ', done => {
|
||||
s3.getObject({
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
Key: testContext.test.key,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ContentLength, '10');
|
||||
assert.strictEqual(res.Body.toString(), 'helloworld');
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ContentLength).toBe('10');
|
||||
expect(res.Body.toString()).toBe('helloworld');
|
||||
assert.deepStrictEqual(res.Metadata,
|
||||
{ 'scal-location-constraint': awsLocation });
|
||||
return done(err);
|
||||
|
@ -128,27 +132,27 @@ describe('Multiple backend get object', function testSuite() {
|
|||
|
||||
describeSkipIfNotMultiple('Complete MPU then get object on AWS ' +
|
||||
'location with bucketMatch: false ', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket, Key: this.currentTest.key,
|
||||
Bucket: bucket, Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
awsLocationMismatch,
|
||||
} }, (err, res) => next(err, res.UploadId)),
|
||||
(uploadId, next) => s3.uploadPart({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
Body: 'helloworld' }, (err, res) => next(err, uploadId,
|
||||
res.ETag)),
|
||||
(uploadId, eTag, next) => s3.completeMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
MultipartUpload: {
|
||||
Parts: [
|
||||
{
|
||||
|
@ -161,16 +165,15 @@ describe('Multiple backend get object', function testSuite() {
|
|||
}, err => next(err)),
|
||||
], done);
|
||||
});
|
||||
it('should get object from MPU on AWS ' +
|
||||
'location with bucketMatch: false ', function it(done) {
|
||||
test('should get object from MPU on AWS ' +
|
||||
'location with bucketMatch: false ', done => {
|
||||
s3.getObject({
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
Key: testContext.test.key,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ContentLength, '10');
|
||||
assert.strictEqual(res.Body.toString(), 'helloworld');
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ContentLength).toBe('10');
|
||||
expect(res.Body.toString()).toBe('helloworld');
|
||||
assert.deepStrictEqual(res.Metadata,
|
||||
{ 'scal-location-constraint': awsLocationMismatch });
|
||||
return done(err);
|
||||
|
@ -180,7 +183,7 @@ describe('Multiple backend get object', function testSuite() {
|
|||
|
||||
describeSkipIfNotMultiple('with objects in all available backends ' +
|
||||
'(mem/file/AWS)', () => {
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Putting object to mem\n');
|
||||
return s3.putObjectAsync({ Bucket: bucket, Key: memObject,
|
||||
Body: body,
|
||||
|
@ -226,69 +229,61 @@ describe('Multiple backend get object', function testSuite() {
|
|||
throw err;
|
||||
});
|
||||
});
|
||||
it('should get an object from mem', done => {
|
||||
test('should get an object from mem', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: memObject }, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get a 0-byte object from mem', done => {
|
||||
test('should get a 0-byte object from mem', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: emptyObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get a 0-byte object from AWS', done => {
|
||||
test('should get a 0-byte object from AWS', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: emptyAwsObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got error ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get an object from file', done => {
|
||||
test('should get an object from file', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: fileObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get an object from AWS', done => {
|
||||
test('should get an object from AWS', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: awsObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get a large object from AWS', done => {
|
||||
test('should get a large object from AWS', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: bigObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${bigMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${bigMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get an object using range query from AWS', done => {
|
||||
test('should get an object using range query from AWS', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: bigObject,
|
||||
Range: 'bytes=0-9' },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.strictEqual(res.ContentLength, '10');
|
||||
assert.strictEqual(res.ContentRange,
|
||||
`bytes 0-9/${bigBodyLen}`);
|
||||
assert.strictEqual(res.ETag, `"${bigMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ContentLength).toBe('10');
|
||||
expect(res.ContentRange).toBe(`bytes 0-9/${bigBodyLen}`);
|
||||
expect(res.ETag).toBe(`"${bigMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -299,16 +294,16 @@ describe('Multiple backend get object', function testSuite() {
|
|||
s3.putObject({ Bucket: bucket, Key: mismatchObject, Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocationMismatch } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get an object from AWS', done => {
|
||||
test('should get an object from AWS', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: mismatchObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, `Error getting object: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,8 +25,7 @@ function getAndAssertVersions(s3, bucket, key, versionIds, expectedData,
|
|||
s3.getObject({ Bucket: bucket, Key: key,
|
||||
VersionId: versionId }, next);
|
||||
}, (err, results) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`getting object, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const resultIds = results.map(result => result.VersionId);
|
||||
const resultData = results.map(result =>
|
||||
result.Body.toString());
|
||||
|
@ -68,35 +67,33 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not return version ids when versioning has not been ' +
|
||||
test('should not return version ids when versioning has not been ' +
|
||||
'configured via CloudServer', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: someBody,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(err).toBe(null);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
getAndAssertResult(s3, { bucket, key, body: someBody,
|
||||
expectedVersionId: false }, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return version ids when versioning has not been ' +
|
||||
test('should not return version ids when versioning has not been ' +
|
||||
'configured via CloudServer, even when version id specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: someBody,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } },
|
||||
(err, data) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(err).toBe(null);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
getAndAssertResult(s3, { bucket, key, body: someBody,
|
||||
versionId: 'null', expectedVersionId: false }, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return version id for null version when versioning ' +
|
||||
test('should return version id for null version when versioning ' +
|
||||
'has been configured via CloudServer', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -113,7 +110,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should overwrite the null version if putting object twice ' +
|
||||
test('should overwrite the null version if putting object twice ' +
|
||||
'before versioning is configured', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = ['data1', 'data2'];
|
||||
|
@ -128,7 +125,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should overwrite existing null version if putting object ' +
|
||||
test('should overwrite existing null version if putting object ' +
|
||||
'after suspending versioning', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = ['data1', 'data2'];
|
||||
|
@ -149,7 +146,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should overwrite null version if putting object when ' +
|
||||
test('should overwrite null version if putting object when ' +
|
||||
'versioning is suspended after versioning enabled', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [...Array(3).keys()].map(i => `data${i}`);
|
||||
|
@ -162,9 +159,8 @@ function testSuite() {
|
|||
next => s3.putObject({ Bucket: bucket, Key: key, Body: data[1],
|
||||
Metadata: { 'scal-location-constraint': awsLocation } },
|
||||
(err, result) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
assert.notEqual(result.VersionId, 'null');
|
||||
expect(err).toBe(null);
|
||||
expect(result.VersionId).not.toEqual('null');
|
||||
firstVersionId = result.VersionId;
|
||||
next();
|
||||
}),
|
||||
|
@ -185,8 +181,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get correct data from aws backend using version IDs',
|
||||
done => {
|
||||
test('should get correct data from aws backend using version IDs', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [...Array(5).keys()].map(i => i.toString());
|
||||
const versionIds = ['null'];
|
||||
|
@ -204,8 +199,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get correct version when getting without version ID',
|
||||
done => {
|
||||
test('should get correct version when getting without version ID', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [...Array(5).keys()].map(i => i.toString());
|
||||
const versionIds = ['null'];
|
||||
|
@ -223,10 +217,9 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get correct data from aws backend using version IDs ' +
|
||||
test('should get correct data from aws backend using version IDs ' +
|
||||
'after putting null versions, putting versions, putting more null ' +
|
||||
'versions and then putting more versions',
|
||||
done => {
|
||||
'versions and then putting more versions', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const data = [...Array(16).keys()].map(i => i.toString());
|
||||
// put three null versions,
|
||||
|
@ -270,9 +263,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return the correct data getting versioned object ' +
|
||||
'even if object was deleted from AWS (creating a delete marker)',
|
||||
done => {
|
||||
test('should return the correct data getting versioned object ' +
|
||||
'even if object was deleted from AWS (creating a delete marker)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
@ -287,9 +279,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return the correct data getting versioned object ' +
|
||||
'even if object is put directly to AWS (creating new version)',
|
||||
done => {
|
||||
test('should return the correct data getting versioned object ' +
|
||||
'even if object is put directly to AWS (creating new version)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
@ -304,9 +295,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return a ServiceUnavailable if trying to get an object ' +
|
||||
'that was deleted in AWS but exists in s3 metadata',
|
||||
done => {
|
||||
test('should return a ServiceUnavailable if trying to get an object ' +
|
||||
'that was deleted in AWS but exists in s3 metadata', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
@ -321,16 +311,15 @@ function testSuite() {
|
|||
err => next(err, s3VerId)),
|
||||
(s3VerId, next) => s3.getObject({ Bucket: bucket, Key: key },
|
||||
err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
assert.strictEqual(err.statusCode, 503);
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
expect(err.statusCode).toBe(503);
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should return a ServiceUnavailable if trying to get a version ' +
|
||||
'that was deleted in AWS but exists in s3 metadata',
|
||||
done => {
|
||||
test('should return a ServiceUnavailable if trying to get a version ' +
|
||||
'that was deleted in AWS but exists in s3 metadata', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
@ -345,8 +334,8 @@ function testSuite() {
|
|||
err => next(err, s3VerId)),
|
||||
(s3VerId, next) => s3.getObject({ Bucket: bucket, Key: key,
|
||||
VersionId: s3VerId }, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
assert.strictEqual(err.statusCode, 503);
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
expect(err.statusCode).toBe(503);
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
|
|
|
@ -28,7 +28,7 @@ function testSuite() {
|
|||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -39,7 +39,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(azureContainerName)
|
||||
.then(() => {
|
||||
|
@ -55,7 +55,7 @@ function testSuite() {
|
|||
keys.forEach(key => {
|
||||
describe(`${key.describe} size`, () => {
|
||||
const testKey = `${key.name}-${Date.now()}`;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
setTimeout(() => {
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
|
@ -68,13 +68,12 @@ function testSuite() {
|
|||
}, azureTimeout);
|
||||
});
|
||||
|
||||
it(`should get an ${key.describe} object from Azure`, done => {
|
||||
test(`should get an ${key.describe} object from Azure`, done => {
|
||||
s3.getObject({ Bucket: azureContainerName, Key:
|
||||
testKey },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success ' +
|
||||
`but got error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${key.MD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${key.MD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -83,7 +82,7 @@ function testSuite() {
|
|||
|
||||
describe('with range', () => {
|
||||
const azureObject = uniqName(keyObject);
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: azureObject,
|
||||
|
@ -94,33 +93,29 @@ function testSuite() {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it('should get an object with body 012345 with "bytes=0-5"',
|
||||
done => {
|
||||
test('should get an object with body 012345 with "bytes=0-5"', done => {
|
||||
s3.getObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: azureObject,
|
||||
Range: 'bytes=0-5',
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.equal(res.ContentLength, 6);
|
||||
assert.strictEqual(res.ContentRange, 'bytes 0-5/10');
|
||||
assert.strictEqual(res.Body.toString(), '012345');
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ContentLength).toEqual(6);
|
||||
expect(res.ContentRange).toBe('bytes 0-5/10');
|
||||
expect(res.Body.toString()).toBe('012345');
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should get an object with body 456789 with "bytes=4-"',
|
||||
done => {
|
||||
test('should get an object with body 456789 with "bytes=4-"', done => {
|
||||
s3.getObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: azureObject,
|
||||
Range: 'bytes=4-',
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
assert.equal(res.ContentLength, 6);
|
||||
assert.strictEqual(res.ContentRange, 'bytes 4-9/10');
|
||||
assert.strictEqual(res.Body.toString(), '456789');
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ContentLength).toEqual(6);
|
||||
expect(res.ContentRange).toBe('bytes 4-9/10');
|
||||
expect(res.Body.toString()).toBe('456789');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -128,7 +123,7 @@ function testSuite() {
|
|||
|
||||
describe('returning error', () => {
|
||||
const azureObject = uniqName(keyObject);
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: azureObject,
|
||||
|
@ -137,24 +132,22 @@ function testSuite() {
|
|||
'scal-location-constraint': azureLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
azureClient.deleteBlob(azureContainerName, azureObject,
|
||||
err => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error on get done to object deleted ' +
|
||||
test('should return an error on get done to object deleted ' +
|
||||
'from Azure', done => {
|
||||
s3.getObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: azureObject,
|
||||
}, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,12 +20,12 @@ const correctMD5 = 'be747eb4b75517bf6b3cf7c5fbb62f3a';
|
|||
const emptyMD5 = 'd41d8cd98f00b204e9800998ecf8427e';
|
||||
const bigMD5 = 'f1c9645dbc14efddc7d8a322685f26eb';
|
||||
|
||||
describe('Multiple backend get object', function testSuite() {
|
||||
describe('Multiple backend get object', () => {
|
||||
this.timeout(30000);
|
||||
withV4(sigCfg => {
|
||||
let bucketUtil;
|
||||
let s3;
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Creating bucket');
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -36,7 +36,7 @@ describe('Multiple backend get object', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucket)
|
||||
.then(() => {
|
||||
|
@ -51,7 +51,7 @@ describe('Multiple backend get object', function testSuite() {
|
|||
});
|
||||
|
||||
describeSkipIfNotMultipleOrCeph('with objects in GCP', () => {
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('Putting object to GCP\n');
|
||||
return s3.putObjectAsync({ Bucket: bucket, Key: gcpObject,
|
||||
Body: body,
|
||||
|
@ -108,16 +108,15 @@ describe('Multiple backend get object', function testSuite() {
|
|||
getTests.forEach(test => {
|
||||
const { Bucket, Key, range, size } = test.input;
|
||||
const { MD5, contentRange } = test.output;
|
||||
it(test.msg, done => {
|
||||
test(test.msg, done => {
|
||||
s3.getObject({ Bucket, Key, Range: range },
|
||||
(err, res) => {
|
||||
assert.equal(err, null,
|
||||
`Expected success but got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
if (range) {
|
||||
assert.strictEqual(res.ContentLength, `${size}`);
|
||||
assert.strictEqual(res.ContentRange, contentRange);
|
||||
expect(res.ContentLength).toBe(`${size}`);
|
||||
expect(res.ContentRange).toBe(contentRange);
|
||||
}
|
||||
assert.strictEqual(res.ETag, `"${MD5}"`);
|
||||
expect(res.ETag).toBe(`"${MD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -129,16 +128,16 @@ describe('Multiple backend get object', function testSuite() {
|
|||
s3.putObject({ Bucket: bucket, Key: mismatchObject, Body: body,
|
||||
Metadata: { 'scal-location-constraint': gcpLocationMismatch } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get an object from GCP', done => {
|
||||
test('should get an object from GCP', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: mismatchObject },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, `Error getting object: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,47 +32,53 @@ describeSkipIfNotMultipleOrCeph('Initiate MPU to AZURE', () => {
|
|||
});
|
||||
});
|
||||
describe('Basic test: ', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done =>
|
||||
s3.createBucket({ Bucket: azureContainerName,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: azureLocation,
|
||||
},
|
||||
}, done));
|
||||
afterEach(function afterEachF(done) {
|
||||
afterEach(done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: keyName,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
s3.abortMultipartUpload(params, done);
|
||||
});
|
||||
it('should create MPU and list in-progress multipart uploads',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, res) => {
|
||||
this.test.uploadId = res.UploadId;
|
||||
assert(this.test.uploadId);
|
||||
assert.strictEqual(res.Bucket, azureContainerName);
|
||||
assert.strictEqual(res.Key, keyName);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listMultipartUploads(
|
||||
{ Bucket: azureContainerName }, (err, res) => {
|
||||
assert.strictEqual(res.NextKeyMarker, keyName);
|
||||
assert.strictEqual(res.NextUploadIdMarker,
|
||||
this.test.uploadId);
|
||||
assert.strictEqual(res.Uploads[0].Key, keyName);
|
||||
assert.strictEqual(res.Uploads[0].UploadId,
|
||||
this.test.uploadId);
|
||||
next(err);
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should create MPU and list in-progress multipart uploads',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, res) => {
|
||||
testContext.test.uploadId = res.UploadId;
|
||||
expect(testContext.test.uploadId).toBeTruthy();
|
||||
expect(res.Bucket).toBe(azureContainerName);
|
||||
expect(res.Key).toBe(keyName);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listMultipartUploads(
|
||||
{ Bucket: azureContainerName }, (err, res) => {
|
||||
expect(res.NextKeyMarker).toBe(keyName);
|
||||
expect(res.NextUploadIdMarker).toBe(testContext.test.uploadId);
|
||||
expect(res.Uploads[0].Key).toBe(keyName);
|
||||
expect(res.Uploads[0].UploadId).toBe(testContext.test.uploadId);
|
||||
next(err);
|
||||
}),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,60 +34,66 @@ describeSkipIfNotMultipleOrCeph('Initiate MPU to GCP', () => {
|
|||
});
|
||||
});
|
||||
describe('Basic test: ', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done =>
|
||||
s3.createBucket({ Bucket: bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: gcpLocation,
|
||||
},
|
||||
}, done));
|
||||
afterEach(function afterEachF(done) {
|
||||
afterEach(done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: keyName,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
s3.abortMultipartUpload(params, done);
|
||||
});
|
||||
it('should create MPU and list in-progress multipart uploads',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: keyName,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, res) => {
|
||||
this.test.uploadId = res.UploadId;
|
||||
assert(this.test.uploadId);
|
||||
assert.strictEqual(res.Bucket, bucket);
|
||||
assert.strictEqual(res.Key, keyName);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listMultipartUploads(
|
||||
{ Bucket: bucket }, (err, res) => {
|
||||
assert.strictEqual(res.NextKeyMarker, keyName);
|
||||
assert.strictEqual(res.NextUploadIdMarker,
|
||||
this.test.uploadId);
|
||||
assert.strictEqual(res.Uploads[0].Key, keyName);
|
||||
assert.strictEqual(res.Uploads[0].UploadId,
|
||||
this.test.uploadId);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const mpuKey =
|
||||
createMpuKey(keyName, this.test.uploadId, 'init');
|
||||
const params = {
|
||||
Bucket: gcpBucketMPU,
|
||||
Key: mpuKey,
|
||||
};
|
||||
gcpClient.getObject(params, err => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should create MPU and list in-progress multipart uploads',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: keyName,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, res) => {
|
||||
testContext.test.uploadId = res.UploadId;
|
||||
expect(testContext.test.uploadId).toBeTruthy();
|
||||
expect(res.Bucket).toBe(bucket);
|
||||
expect(res.Key).toBe(keyName);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listMultipartUploads(
|
||||
{ Bucket: bucket }, (err, res) => {
|
||||
expect(res.NextKeyMarker).toBe(keyName);
|
||||
expect(res.NextUploadIdMarker).toBe(testContext.test.uploadId);
|
||||
expect(res.Uploads[0].Key).toBe(keyName);
|
||||
expect(res.Uploads[0].UploadId).toBe(testContext.test.uploadId);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const mpuKey =
|
||||
createMpuKey(keyName, testContext.test.uploadId, 'init');
|
||||
const params = {
|
||||
Bucket: gcpBucketMPU,
|
||||
Key: mpuKey,
|
||||
};
|
||||
gcpClient.getObject(params, err => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ let s3;
|
|||
describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
|
||||
() => {
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeEachFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -44,7 +44,7 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn() {
|
||||
afterEach(() => {
|
||||
process.stdout.write('Emptying bucket');
|
||||
return s3.abortMultipartUploadAsync({
|
||||
Bucket: azureContainerName, Key: this.currentTest.key,
|
||||
|
@ -61,35 +61,35 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
|
|||
});
|
||||
});
|
||||
|
||||
it('should list both parts', function itFn(done) {
|
||||
test('should list both parts', done => {
|
||||
s3.listParts({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId },
|
||||
(err, data) => {
|
||||
assert.equal(err, null, `Err listing parts: ${err}`);
|
||||
assert.strictEqual(data.Parts.length, 2);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(data.Parts[0].Size, firstPartSize);
|
||||
assert.strictEqual(data.Parts[0].ETag, this.test.firstEtag);
|
||||
assert.strictEqual(data.Parts[1].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[1].Size, secondPartSize);
|
||||
assert.strictEqual(data.Parts[1].ETag, this.test.secondEtag);
|
||||
expect(err).toEqual(null);
|
||||
expect(data.Parts.length).toBe(2);
|
||||
expect(data.Parts[0].PartNumber).toBe(1);
|
||||
expect(data.Parts[0].Size).toBe(firstPartSize);
|
||||
expect(data.Parts[0].ETag).toBe(this.test.firstEtag);
|
||||
expect(data.Parts[1].PartNumber).toBe(2);
|
||||
expect(data.Parts[1].Size).toBe(secondPartSize);
|
||||
expect(data.Parts[1].ETag).toBe(this.test.secondEtag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should only list the second part', function itFn(done) {
|
||||
test('should only list the second part', done => {
|
||||
s3.listParts({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
PartNumberMarker: 1,
|
||||
UploadId: this.test.uploadId },
|
||||
(err, data) => {
|
||||
assert.equal(err, null, `Err listing parts: ${err}`);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[0].Size, secondPartSize);
|
||||
assert.strictEqual(data.Parts[0].ETag, this.test.secondEtag);
|
||||
expect(err).toEqual(null);
|
||||
expect(data.Parts[0].PartNumber).toBe(2);
|
||||
expect(data.Parts[0].Size).toBe(secondPartSize);
|
||||
expect(data.Parts[0].ETag).toBe(this.test.secondEtag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ let s3;
|
|||
|
||||
describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeEachFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -43,7 +43,7 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn() {
|
||||
afterEach(() => {
|
||||
process.stdout.write('Emptying bucket');
|
||||
return s3.abortMultipartUploadAsync({
|
||||
Bucket: bucket, Key: this.currentTest.key,
|
||||
|
@ -60,35 +60,35 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should list both parts', function itFn(done) {
|
||||
test('should list both parts', done => {
|
||||
s3.listParts({
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId },
|
||||
(err, data) => {
|
||||
assert.equal(err, null, `Err listing parts: ${err}`);
|
||||
assert.strictEqual(data.Parts.length, 2);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(data.Parts[0].Size, firstPartSize);
|
||||
assert.strictEqual(data.Parts[0].ETag, this.test.firstEtag);
|
||||
assert.strictEqual(data.Parts[1].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[1].Size, secondPartSize);
|
||||
assert.strictEqual(data.Parts[1].ETag, this.test.secondEtag);
|
||||
expect(err).toEqual(null);
|
||||
expect(data.Parts.length).toBe(2);
|
||||
expect(data.Parts[0].PartNumber).toBe(1);
|
||||
expect(data.Parts[0].Size).toBe(firstPartSize);
|
||||
expect(data.Parts[0].ETag).toBe(this.test.firstEtag);
|
||||
expect(data.Parts[1].PartNumber).toBe(2);
|
||||
expect(data.Parts[1].Size).toBe(secondPartSize);
|
||||
expect(data.Parts[1].ETag).toBe(this.test.secondEtag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should only list the second part', function itFn(done) {
|
||||
test('should only list the second part', done => {
|
||||
s3.listParts({
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
PartNumberMarker: 1,
|
||||
UploadId: this.test.uploadId },
|
||||
(err, data) => {
|
||||
assert.equal(err, null, `Err listing parts: ${err}`);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[0].Size, secondPartSize);
|
||||
assert.strictEqual(data.Parts[0].ETag, this.test.secondEtag);
|
||||
expect(err).toEqual(null);
|
||||
expect(data.Parts[0].PartNumber).toBe(2);
|
||||
expect(data.Parts[0].Size).toBe(secondPartSize);
|
||||
expect(data.Parts[0].ETag).toBe(this.test.secondEtag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,26 +34,32 @@ describeSkipIfNotMultipleOrCeph('Abort MPU on GCP data backend', function
|
|||
descrbeFn() {
|
||||
this.timeout(180000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket },
|
||||
err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -62,62 +68,67 @@ descrbeFn() {
|
|||
afterEach(done => s3.deleteBucket({ Bucket: bucket },
|
||||
done));
|
||||
|
||||
it('should abort a MPU with 0 parts', function itFn(done) {
|
||||
test('should abort a MPU with 0 parts', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload(params, () => next()),
|
||||
next => setTimeout(() => checkMPUList(
|
||||
gcpBucketMPU, this.test.key, this.test.uploadId, next),
|
||||
gcpBucketMPU, testContext.test.key, testContext.test.uploadId, next),
|
||||
gcpTimeout),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should abort a MPU with uploaded parts', function itFn(done) {
|
||||
test('should abort a MPU with uploaded parts', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
async.times(2, (n, cb) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
Body: body,
|
||||
PartNumber: n + 1,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(
|
||||
res.ETag, `"${correctMD5}"`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
cb();
|
||||
});
|
||||
}, () => next());
|
||||
},
|
||||
next => s3.abortMultipartUpload(params, () => next()),
|
||||
next => setTimeout(() => checkMPUList(
|
||||
gcpBucketMPU, this.test.key, this.test.uploadId, next),
|
||||
gcpBucketMPU, testContext.test.key, testContext.test.uploadId, next),
|
||||
gcpTimeout),
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with previously existing object with same key', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket },
|
||||
err => next(err)),
|
||||
next => {
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: {
|
||||
'scal-location-constraint': gcpLocation },
|
||||
Body: body,
|
||||
|
@ -129,13 +140,13 @@ descrbeFn() {
|
|||
},
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -155,12 +166,11 @@ descrbeFn() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should abort MPU without deleting existing object',
|
||||
function itFn(done) {
|
||||
test('should abort MPU without deleting existing object', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
|
@ -177,12 +187,12 @@ descrbeFn() {
|
|||
next => setTimeout(() => {
|
||||
const params = {
|
||||
Bucket: gcpBucket,
|
||||
Key: this.test.key,
|
||||
Key: testContext.test.key,
|
||||
};
|
||||
gcpClient.getObject(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
next();
|
||||
});
|
||||
}, gcpTimeout),
|
||||
|
|
|
@ -20,11 +20,11 @@ let s3;
|
|||
function azureCheck(container, key, expected, cb) {
|
||||
azureClient.getBlobProperties(container, key, (err, res) => {
|
||||
if (expected.error) {
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
assert.strictEqual(err.code, 'NotFound');
|
||||
expect(err.statusCode).toBe(404);
|
||||
expect(err.code).toBe('NotFound');
|
||||
} else {
|
||||
const convertedMD5 = convertMD5(res.contentSettings.contentMD5);
|
||||
assert.strictEqual(convertedMD5, expectedMD5);
|
||||
expect(convertedMD5).toBe(expectedMD5);
|
||||
}
|
||||
return cb();
|
||||
});
|
||||
|
@ -34,25 +34,31 @@ describeSkipIfNotMultipleOrCeph('Abort MPU on Azure data backend', function
|
|||
describeF() {
|
||||
this.timeout(50000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: azureContainerName },
|
||||
err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -61,57 +67,63 @@ describeF() {
|
|||
afterEach(done => s3.deleteBucket({ Bucket: azureContainerName },
|
||||
done));
|
||||
|
||||
it('should abort an MPU with one empty part ', function itFn(done) {
|
||||
test('should abort an MPU with one empty part ', done => {
|
||||
const expected = { error: true };
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
const partParams = Object.assign({ PartNumber: 1 },
|
||||
params);
|
||||
s3.uploadPart(partParams, err => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.abortMultipartUpload(params, err => next(err)),
|
||||
next => azureCheck(azureContainerName, this.test.key,
|
||||
next => azureCheck(azureContainerName, testContext.test.key,
|
||||
expected, next),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should abort MPU with one part bigger than max subpart',
|
||||
function itFn(done) {
|
||||
const expected = { error: true };
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
const body = Buffer.alloc(maxSubPartSize + 10);
|
||||
const partParams = Object.assign(
|
||||
{ PartNumber: 1, Body: body }, params);
|
||||
s3.uploadPart(partParams, err => {
|
||||
assert.strictEqual(err, null, 'Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.abortMultipartUpload(params, err => next(err)),
|
||||
next => azureCheck(azureContainerName, this.test.key,
|
||||
expected, next),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should abort MPU with one part bigger than max subpart',
|
||||
done => {
|
||||
const expected = { error: true };
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
const body = Buffer.alloc(maxSubPartSize + 10);
|
||||
const partParams = Object.assign(
|
||||
{ PartNumber: 1, Body: body }, params);
|
||||
s3.uploadPart(partParams, err => {
|
||||
expect(err).toBe(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.abortMultipartUpload(params, err => next(err)),
|
||||
next => azureCheck(azureContainerName, testContext.test.key,
|
||||
expected, next),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('with previously existing object with same key', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: azureContainerName },
|
||||
err => next(err)),
|
||||
|
@ -119,25 +131,24 @@ describeF() {
|
|||
const body = Buffer.alloc(10);
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocation },
|
||||
Body: body,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Err putting object to ' +
|
||||
`azure: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -157,13 +168,12 @@ describeF() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should abort MPU without deleting existing object',
|
||||
function itFn(done) {
|
||||
test('should abort MPU without deleting existing object', done => {
|
||||
const expected = { error: false };
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => {
|
||||
|
@ -171,13 +181,12 @@ describeF() {
|
|||
const partParams = Object.assign(
|
||||
{ PartNumber: 1, Body: body }, params);
|
||||
s3.uploadPart(partParams, err => {
|
||||
assert.strictEqual(err, null, 'Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.abortMultipartUpload(params, err => next(err)),
|
||||
next => azureCheck(azureContainerName, this.test.key,
|
||||
next => azureCheck(azureContainerName, testContext.test.key,
|
||||
expected, next),
|
||||
], done);
|
||||
});
|
||||
|
|
|
@ -36,16 +36,16 @@ function getCheck(key, bucketMatch, cb) {
|
|||
let azureKey = key;
|
||||
s3.getObject({ Bucket: azureContainerName, Key: azureKey },
|
||||
(err, s3Res) => {
|
||||
assert.equal(err, null, `Err getting object from S3: ${err}`);
|
||||
assert.strictEqual(s3Res.ETag, `"${s3MD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(s3Res.ETag).toBe(`"${s3MD5}"`);
|
||||
|
||||
if (!bucketMatch) {
|
||||
azureKey = `${azureContainerName}/${key}`;
|
||||
}
|
||||
azureClient.getBlobProperties(azureContainerName, azureKey,
|
||||
(err, azureRes) => {
|
||||
assert.equal(err, null, `Err getting object from Azure: ${err}`);
|
||||
assert.strictEqual(expectedContentLength, azureRes.contentLength);
|
||||
expect(err).toEqual(null);
|
||||
expect(expectedContentLength).toBe(azureRes.contentLength);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -62,9 +62,9 @@ function mpuSetup(key, location, cb) {
|
|||
};
|
||||
s3.createMultipartUpload(params, (err, res) => {
|
||||
const uploadId = res.UploadId;
|
||||
assert(uploadId);
|
||||
assert.strictEqual(res.Bucket, azureContainerName);
|
||||
assert.strictEqual(res.Key, key);
|
||||
expect(uploadId).toBeTruthy();
|
||||
expect(res.Bucket).toBe(azureContainerName);
|
||||
expect(res.Key).toBe(key);
|
||||
next(err, uploadId);
|
||||
});
|
||||
},
|
||||
|
@ -96,7 +96,7 @@ function mpuSetup(key, location, cb) {
|
|||
},
|
||||
], (err, uploadId) => {
|
||||
process.stdout.write('Created MPU and put two parts\n');
|
||||
assert.equal(err, null, `Err setting up MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
cb(uploadId, partArray);
|
||||
});
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ describeSkipIfNotMultipleOrCeph('Complete MPU API for Azure data backend',
|
|||
function testSuite() {
|
||||
this.timeout(150000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -130,7 +130,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on Azure', function itFn(done) {
|
||||
test('should complete an MPU on Azure', done => {
|
||||
mpuSetup(this.test.key, azureLocation, (uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
|
@ -139,33 +139,35 @@ function testSuite() {
|
|||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() => getCheck(this.test.key, true, done),
|
||||
azureTimeout);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on Azure with bucketMatch=false',
|
||||
function itFn(done) {
|
||||
mpuSetup(this.test.key, azureLocationMismatch,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: uploadId,
|
||||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
setTimeout(() => getCheck(this.test.key, false, done),
|
||||
azureTimeout);
|
||||
test(
|
||||
'should complete an MPU on Azure with bucketMatch=false',
|
||||
done => {
|
||||
mpuSetup(this.test.key, azureLocationMismatch,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: uploadId,
|
||||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() => getCheck(this.test.key, false, done),
|
||||
azureTimeout);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should complete an MPU on Azure with same key as object put ' +
|
||||
'to file', function itFn(done) {
|
||||
test('should complete an MPU on Azure with same key as object put ' +
|
||||
'to file', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
|
@ -173,7 +175,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': fileLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to file: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, azureLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -183,7 +185,7 @@ function testSuite() {
|
|||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() => getCheck(this.test.key, true, done),
|
||||
azureTimeout);
|
||||
});
|
||||
|
@ -191,8 +193,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on Azure with same key as object put ' +
|
||||
'to Azure', function itFn(done) {
|
||||
test('should complete an MPU on Azure with same key as object put ' +
|
||||
'to Azure', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
|
@ -200,7 +202,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': azureLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to Azure: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, azureLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -210,7 +212,7 @@ function testSuite() {
|
|||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() => getCheck(this.test.key, true, done),
|
||||
azureTimeout);
|
||||
});
|
||||
|
@ -218,8 +220,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on Azure with same key as object put ' +
|
||||
'to AWS', function itFn(done) {
|
||||
test('should complete an MPU on Azure with same key as object put ' +
|
||||
'to AWS', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
|
@ -227,7 +229,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to AWS: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, azureLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -237,12 +239,12 @@ function testSuite() {
|
|||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
// make sure object is gone from AWS
|
||||
setTimeout(() => {
|
||||
this.test.awsClient.getObject({ Bucket: awsBucket,
|
||||
Key: this.test.key }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
getCheck(this.test.key, true, done);
|
||||
});
|
||||
}, azureTimeout);
|
||||
|
|
|
@ -21,16 +21,16 @@ function getCheck(key, bucketMatch, cb) {
|
|||
let gcpKey = key;
|
||||
s3.getObject({ Bucket: bucket, Key: gcpKey },
|
||||
(err, s3Res) => {
|
||||
assert.equal(err, null, `Err getting object from S3: ${err}`);
|
||||
assert.strictEqual(s3Res.ETag, `"${s3MD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(s3Res.ETag).toBe(`"${s3MD5}"`);
|
||||
|
||||
if (!bucketMatch) {
|
||||
gcpKey = `${bucket}/${gcpKey}`;
|
||||
}
|
||||
const params = { Bucket: gcpBucket, Key: gcpKey };
|
||||
gcpClient.getObject(params, (err, gcpRes) => {
|
||||
assert.equal(err, null, `Err getting object from GCP: ${err}`);
|
||||
assert.strictEqual(expectedContentLength, gcpRes.ContentLength);
|
||||
expect(err).toEqual(null);
|
||||
expect(expectedContentLength).toBe(gcpRes.ContentLength);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -47,9 +47,9 @@ function mpuSetup(key, location, cb) {
|
|||
};
|
||||
s3.createMultipartUpload(params, (err, res) => {
|
||||
const uploadId = res.UploadId;
|
||||
assert(uploadId);
|
||||
assert.strictEqual(res.Bucket, bucket);
|
||||
assert.strictEqual(res.Key, key);
|
||||
expect(uploadId).toBeTruthy();
|
||||
expect(res.Bucket).toBe(bucket);
|
||||
expect(res.Key).toBe(key);
|
||||
next(err, uploadId);
|
||||
});
|
||||
},
|
||||
|
@ -81,7 +81,7 @@ function mpuSetup(key, location, cb) {
|
|||
},
|
||||
], (err, uploadId) => {
|
||||
process.stdout.write('Created MPU and put two parts\n');
|
||||
assert.equal(err, null, `Err setting up MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
cb(uploadId, partArray);
|
||||
});
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ describeSkipIfNotMultipleOrCeph('Complete MPU API for GCP data backend',
|
|||
function testSuite() {
|
||||
this.timeout(150000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = `somekey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -115,7 +115,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on GCP', function itFn(done) {
|
||||
test('should complete an MPU on GCP', done => {
|
||||
mpuSetup(this.test.key, gcpLocation, (uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
|
@ -125,36 +125,36 @@ function testSuite() {
|
|||
};
|
||||
setTimeout(() => {
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
getCheck(this.test.key, true, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on GCP with bucketMatch=false',
|
||||
function itFn(done) {
|
||||
mpuSetup(this.test.key, gcpLocationMismatch,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: uploadId,
|
||||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
setTimeout(() => {
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Err completing MPU: ${err}`);
|
||||
getCheck(this.test.key, false, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should complete an MPU on GCP with bucketMatch=false',
|
||||
done => {
|
||||
mpuSetup(this.test.key, gcpLocationMismatch,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: uploadId,
|
||||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
setTimeout(() => {
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
expect(err).toEqual(null);
|
||||
getCheck(this.test.key, false, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should complete an MPU on GCP with same key as object put ' +
|
||||
'to file', function itFn(done) {
|
||||
test('should complete an MPU on GCP with same key as object put ' +
|
||||
'to file', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
|
@ -162,7 +162,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': fileLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to file: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, gcpLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -173,8 +173,7 @@ function testSuite() {
|
|||
};
|
||||
setTimeout(() => {
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
getCheck(this.test.key, true, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
|
@ -182,8 +181,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on GCP with same key as object put ' +
|
||||
'to GCP', function itFn(done) {
|
||||
test('should complete an MPU on GCP with same key as object put ' +
|
||||
'to GCP', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
|
@ -191,7 +190,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to GCP: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, gcpLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -202,8 +201,7 @@ function testSuite() {
|
|||
};
|
||||
setTimeout(() => {
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
getCheck(this.test.key, true, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
|
@ -211,8 +209,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should complete an MPU on GCP with same key as object put ' +
|
||||
'to AWS', function itFn(done) {
|
||||
test('should complete an MPU on GCP with same key as object put ' +
|
||||
'to AWS', done => {
|
||||
const body = Buffer.from('I am a body', 'utf8');
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
|
@ -220,7 +218,7 @@ function testSuite() {
|
|||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } },
|
||||
err => {
|
||||
assert.equal(err, null, `Err putting object to AWS: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
mpuSetup(this.test.key, gcpLocation,
|
||||
(uploadId, partArray) => {
|
||||
const params = {
|
||||
|
@ -230,12 +228,12 @@ function testSuite() {
|
|||
MultipartUpload: { Parts: partArray },
|
||||
};
|
||||
s3.completeMultipartUpload(params, err => {
|
||||
assert.equal(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
// make sure object is gone from AWS
|
||||
setTimeout(() => {
|
||||
this.test.awsClient.getObject({ Bucket: awsBucket,
|
||||
Key: this.test.key }, err => {
|
||||
assert.strictEqual(err.code, 'NoSuchKey');
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
getCheck(this.test.key, true, done);
|
||||
});
|
||||
}, gcpTimeout);
|
||||
|
|
|
@ -30,11 +30,11 @@ function mpuSetup(s3, key, location, cb) {
|
|||
Metadata: { 'scal-location-constraint': location },
|
||||
};
|
||||
s3.createMultipartUpload(params, (err, res) => {
|
||||
assert.strictEqual(err, null, `err creating mpu: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const uploadId = res.UploadId;
|
||||
assert(uploadId);
|
||||
assert.strictEqual(res.Bucket, bucket);
|
||||
assert.strictEqual(res.Key, key);
|
||||
expect(uploadId).toBeTruthy();
|
||||
expect(res.Bucket).toBe(bucket);
|
||||
expect(res.Key).toBe(key);
|
||||
next(err, uploadId);
|
||||
});
|
||||
},
|
||||
|
@ -47,7 +47,7 @@ function mpuSetup(s3, key, location, cb) {
|
|||
Body: data[0],
|
||||
};
|
||||
s3.uploadPart(partParams, (err, res) => {
|
||||
assert.strictEqual(err, null, `err uploading part 1: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
partArray.push({ ETag: res.ETag, PartNumber: 1 });
|
||||
next(err, uploadId);
|
||||
});
|
||||
|
@ -61,7 +61,7 @@ function mpuSetup(s3, key, location, cb) {
|
|||
Body: data[1],
|
||||
};
|
||||
s3.uploadPart(partParams, (err, res) => {
|
||||
assert.strictEqual(err, null, `err uploading part 2: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
partArray.push({ ETag: res.ETag, PartNumber: 2 });
|
||||
next(err, uploadId);
|
||||
});
|
||||
|
@ -81,11 +81,11 @@ function completeAndAssertMpu(s3, params, cb) {
|
|||
UploadId: uploadId,
|
||||
MultipartUpload: { Parts: partArray },
|
||||
}, (err, data) => {
|
||||
assert.strictEqual(err, null, `Err completing MPU: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (expectVersionId) {
|
||||
assert.notEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).not.toEqual(undefined);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
}
|
||||
const expectedVersionId = expectedGetVersionId || data.VersionId;
|
||||
getAndAssertResult(s3, { bucket, key, body: concattedData,
|
||||
|
@ -114,7 +114,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: should not return version id ' +
|
||||
test('versioning not configured: should not return version id ' +
|
||||
'completing mpu', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
mpuSetup(s3, key, awsLocation, (err, uploadId, partArray) => {
|
||||
|
@ -123,9 +123,9 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: if complete mpu on already-existing ' +
|
||||
test('versioning not configured: if complete mpu on already-existing ' +
|
||||
'object, metadata should be overwritten but data of previous version' +
|
||||
'in AWS should not be deleted', function itF(done) {
|
||||
'in AWS should not be deleted', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => putToAwsBackend(s3, bucket, key, '', err => next(err)),
|
||||
|
@ -144,26 +144,27 @@ function testSuite() {
|
|||
expectedError: 'NoSuchKey' }, next),
|
||||
next => awsGetLatestVerId(key, '', next),
|
||||
(awsVerId, next) => {
|
||||
assert.strictEqual(awsVerId, this.test.awsVerId);
|
||||
expect(awsVerId).toBe(this.test.awsVerId);
|
||||
next();
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should not return version id completing mpu',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => suspendVersioning(s3, bucket, next),
|
||||
next => mpuSetup(s3, key, awsLocation, next),
|
||||
(uploadId, partArray, next) => completeAndAssertMpu(s3,
|
||||
{ bucket, key, uploadId, partArray, expectVersionId: false,
|
||||
expectedGetVersionId: 'null' }, next),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'versioning suspended: should not return version id completing mpu',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => suspendVersioning(s3, bucket, next),
|
||||
next => mpuSetup(s3, key, awsLocation, next),
|
||||
(uploadId, partArray, next) => completeAndAssertMpu(s3,
|
||||
{ bucket, key, uploadId, partArray, expectVersionId: false,
|
||||
expectedGetVersionId: 'null' }, next),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('versioning enabled: should return version id completing mpu',
|
||||
done => {
|
||||
test('versioning enabled: should return version id completing mpu', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
|
|
@ -21,15 +21,14 @@ let s3;
|
|||
|
||||
function checkSubPart(key, uploadId, expectedParts, cb) {
|
||||
azureClient.listBlocks(azureContainerName, key, 'all', (err, list) => {
|
||||
assert.equal(err, null, 'Expected success, got error ' +
|
||||
`on call to Azure: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const uncommittedBlocks = list.UncommittedBlocks;
|
||||
const committedBlocks = list.CommittedBlocks;
|
||||
assert.strictEqual(committedBlocks, undefined);
|
||||
expect(committedBlocks).toBe(undefined);
|
||||
uncommittedBlocks.forEach((l, index) => {
|
||||
assert.strictEqual(l.Name, getBlockId(uploadId,
|
||||
expect(l.Name).toBe(getBlockId(uploadId,
|
||||
expectedParts[index].partnbr, expectedParts[index].subpartnbr));
|
||||
assert.strictEqual(l.Size, expectedParts[index].size.toString());
|
||||
expect(l.Size).toBe(expectedParts[index].size.toString());
|
||||
});
|
||||
cb();
|
||||
});
|
||||
|
@ -37,11 +36,11 @@ function checkSubPart(key, uploadId, expectedParts, cb) {
|
|||
|
||||
function azureCheck(key, cb) {
|
||||
s3.getObject({ Bucket: azureContainerName, Key: key }, (err, res) => {
|
||||
assert.equal(err, null);
|
||||
assert.strictEqual(res.ETag, `"${expectedMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${expectedMD5}"`);
|
||||
azureClient.getBlobProperties(azureContainerName, key, (err, res) => {
|
||||
const convertedMD5 = convertMD5(res.contentSettings.contentMD5);
|
||||
assert.strictEqual(convertedMD5, expectedMD5);
|
||||
expect(convertedMD5).toBe(expectedMD5);
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
|
@ -51,155 +50,162 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend put part to AZURE', function
|
|||
describeF() {
|
||||
this.timeout(80000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: azureContainerName,
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => next(err)),
|
||||
next => s3.deleteBucket({ Bucket: azureContainerName },
|
||||
err => next(err)),
|
||||
], err => {
|
||||
assert.equal(err, null, `Error aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put 0-byte block to Azure', function itFn(done) {
|
||||
test('should put 0-byte block to Azure', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = `"${azureMpuUtils.zeroByteETag}"`;
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
}),
|
||||
next => azureClient.listBlocks(azureContainerName,
|
||||
this.test.key, 'all', err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'BlobNotFound');
|
||||
testContext.test.key, 'all', err => {
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('BlobNotFound');
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put 2 blocks to Azure', function itFn(done) {
|
||||
test('should put 2 blocks to Azure', done => {
|
||||
const body = Buffer.alloc(maxSubPartSize + 10);
|
||||
const parts = [{ partnbr: 1, subpartnbr: 0,
|
||||
size: maxSubPartSize },
|
||||
{ partnbr: 1, subpartnbr: 1, size: 10 }];
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = expectedETag(body);
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
}),
|
||||
next => checkSubPart(this.test.key, this.test.uploadId,
|
||||
next => checkSubPart(testContext.test.key, testContext.test.uploadId,
|
||||
parts, next),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put 5 parts bigger than maxSubPartSize to Azure',
|
||||
function it(done) {
|
||||
const body = Buffer.alloc(maxSubPartSize + 10);
|
||||
let parts = [];
|
||||
for (let i = 1; i < 6; i++) {
|
||||
parts = parts.concat([
|
||||
{ partnbr: i, subpartnbr: 0, size: maxSubPartSize },
|
||||
{ partnbr: i, subpartnbr: 1, size: 10 },
|
||||
]);
|
||||
}
|
||||
async.times(5, (n, next) => {
|
||||
const partNumber = n + 1;
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
PartNumber: partNumber,
|
||||
Body: body,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = expectedETag(body);
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
return next(err);
|
||||
test(
|
||||
'should put 5 parts bigger than maxSubPartSize to Azure',
|
||||
done => {
|
||||
const body = Buffer.alloc(maxSubPartSize + 10);
|
||||
let parts = [];
|
||||
for (let i = 1; i < 6; i++) {
|
||||
parts = parts.concat([
|
||||
{ partnbr: i, subpartnbr: 0, size: maxSubPartSize },
|
||||
{ partnbr: i, subpartnbr: 1, size: 10 },
|
||||
]);
|
||||
}
|
||||
async.times(5, (n, next) => {
|
||||
const partNumber = n + 1;
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: partNumber,
|
||||
Body: body,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = expectedETag(body);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
});
|
||||
}, err => {
|
||||
expect(err).toEqual(null);
|
||||
checkSubPart(testContext.test.key, testContext.test.uploadId,
|
||||
parts, done);
|
||||
});
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error: ${err}`);
|
||||
checkSubPart(this.test.key, this.test.uploadId,
|
||||
parts, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('should put 5 parts smaller than maxSubPartSize to Azure',
|
||||
function it(done) {
|
||||
const body = Buffer.alloc(10);
|
||||
let parts = [];
|
||||
for (let i = 1; i < 6; i++) {
|
||||
parts = parts.concat([
|
||||
{ partnbr: i, subpartnbr: 0, size: 10 },
|
||||
]);
|
||||
}
|
||||
async.times(5, (n, next) => {
|
||||
const partNumber = n + 1;
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
PartNumber: partNumber,
|
||||
Body: body,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = expectedETag(body);
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
return next(err);
|
||||
});
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error: ${err}`);
|
||||
checkSubPart(this.test.key, this.test.uploadId,
|
||||
parts, done);
|
||||
});
|
||||
});
|
||||
);
|
||||
|
||||
it('should put the same part twice', function itFn(done) {
|
||||
test(
|
||||
'should put 5 parts smaller than maxSubPartSize to Azure',
|
||||
done => {
|
||||
const body = Buffer.alloc(10);
|
||||
let parts = [];
|
||||
for (let i = 1; i < 6; i++) {
|
||||
parts = parts.concat([
|
||||
{ partnbr: i, subpartnbr: 0, size: 10 },
|
||||
]);
|
||||
}
|
||||
async.times(5, (n, next) => {
|
||||
const partNumber = n + 1;
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: partNumber,
|
||||
Body: body,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected = expectedETag(body);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
});
|
||||
}, err => {
|
||||
expect(err).toEqual(null);
|
||||
checkSubPart(testContext.test.key, testContext.test.uploadId,
|
||||
parts, done);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
test('should put the same part twice', done => {
|
||||
const body1 = Buffer.alloc(maxSubPartSize + 10);
|
||||
const body2 = Buffer.alloc(20);
|
||||
const parts2 = [{ partnbr: 1, subpartnbr: 0, size: 20 },
|
||||
|
@ -207,30 +213,36 @@ describeF() {
|
|||
async.waterfall([
|
||||
next => s3.uploadPart({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body1,
|
||||
}, err => next(err)),
|
||||
next => s3.uploadPart({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body2,
|
||||
}, (err, res) => {
|
||||
const eTagExpected = expectedETag(body2);
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
}),
|
||||
next => checkSubPart(this.test.key, this.test.uploadId,
|
||||
next => checkSubPart(testContext.test.key, testContext.test.uploadId,
|
||||
parts2, next),
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with same key as preexisting part', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: azureContainerName },
|
||||
err => next(err)),
|
||||
|
@ -238,45 +250,44 @@ describeF() {
|
|||
const body = Buffer.alloc(10);
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocation },
|
||||
Body: body,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Err putting object to ' +
|
||||
`azure: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => {
|
||||
process.stdout.write('Aborting multipart upload\n');
|
||||
s3.abortMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId },
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId },
|
||||
err => next(err));
|
||||
},
|
||||
next => {
|
||||
process.stdout.write('Deleting object\n');
|
||||
s3.deleteObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key },
|
||||
Key: testContext.currentTest.key },
|
||||
err => next(err));
|
||||
},
|
||||
next => {
|
||||
|
@ -286,26 +297,27 @@ describeF() {
|
|||
err => next(err));
|
||||
},
|
||||
], err => {
|
||||
assert.equal(err, null, `Err in afterEach: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put a part without overwriting existing object',
|
||||
function itFn(done) {
|
||||
const body = Buffer.alloc(20);
|
||||
s3.uploadPart({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body,
|
||||
}, err => {
|
||||
assert.strictEqual(err, null, 'Err putting part to ' +
|
||||
`Azure: ${err}`);
|
||||
azureCheck(this.test.key, done);
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should put a part without overwriting existing object',
|
||||
done => {
|
||||
const body = Buffer.alloc(20);
|
||||
s3.uploadPart({
|
||||
Bucket: azureContainerName,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body,
|
||||
}, err => {
|
||||
expect(err).toBe(null);
|
||||
azureCheck(testContext.test.key, done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -315,53 +327,59 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend put part to AZURE ' +
|
|||
describeF() {
|
||||
this.timeout(80000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: azureContainerName,
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocationMismatch },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => next(err)),
|
||||
next => s3.deleteBucket({ Bucket: azureContainerName },
|
||||
err => next(err)),
|
||||
], err => {
|
||||
assert.equal(err, null, `Error aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put block to AZURE location with bucketMatch' +
|
||||
' sets to false', function itFn(done) {
|
||||
test('should put block to AZURE location with bucketMatch' +
|
||||
' sets to false', done => {
|
||||
const body20 = Buffer.alloc(20);
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body20,
|
||||
};
|
||||
|
@ -371,12 +389,12 @@ describeF() {
|
|||
next => s3.uploadPart(params, (err, res) => {
|
||||
const eTagExpected =
|
||||
'"441018525208457705bf09a8ee3c1093"';
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
return next(err);
|
||||
}),
|
||||
next => checkSubPart(
|
||||
`${azureContainerName}/${this.test.key}`,
|
||||
this.test.uploadId, parts, next),
|
||||
`${azureContainerName}/${testContext.test.key}`,
|
||||
testContext.test.uploadId, parts, next),
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,11 +27,10 @@ function checkMPUResult(bucket, key, uploadId, objCount, expected, cb) {
|
|||
gcpClient.listParts(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert((res && res.Contents &&
|
||||
res.Contents.length === objCount));
|
||||
expect(res && res.Contents &&
|
||||
res.Contents.length === objCount).toBeTruthy();
|
||||
res.Contents.forEach(part => {
|
||||
assert.strictEqual(
|
||||
part.ETag, `"${expected}"`);
|
||||
expect(part.ETag).toBe(`"${expected}"`);
|
||||
});
|
||||
cb();
|
||||
});
|
||||
|
@ -41,63 +40,69 @@ describeSkipIfNotMultipleOrCeph('MultipleBacked put part to GCP', function
|
|||
describeFn() {
|
||||
this.timeout(180000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket,
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => next(err)),
|
||||
next => s3.deleteBucket({ Bucket: bucket },
|
||||
err => next(err)),
|
||||
], err => {
|
||||
assert.equal(err, null, `Error aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put 0-byte part to GCP', function itFn(done) {
|
||||
test('should put 0-byte part to GCP', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPart(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
next();
|
||||
}),
|
||||
next => {
|
||||
const mpuKey =
|
||||
createMpuKey(this.test.key, this.test.uploadId, 1);
|
||||
createMpuKey(testContext.test.key, testContext.test.uploadId, 1);
|
||||
const getParams = {
|
||||
Bucket: gcpBucketMPU,
|
||||
Key: mpuKey,
|
||||
|
@ -105,40 +110,39 @@ describeFn() {
|
|||
gcpClient.getObject(getParams, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put 2 parts to GCP', function ifFn(done) {
|
||||
test('should put 2 parts to GCP', done => {
|
||||
async.waterfall([
|
||||
next => {
|
||||
async.times(2, (n, cb) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
Body: body,
|
||||
PartNumber: n + 1,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(
|
||||
res.ETag, `"${correctMD5}"`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
cb();
|
||||
});
|
||||
}, () => next());
|
||||
},
|
||||
next => checkMPUResult(
|
||||
gcpBucketMPU, this.test.key, this.test.uploadId,
|
||||
gcpBucketMPU, testContext.test.key, testContext.test.uploadId,
|
||||
2, correctMD5, next),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put the same part twice', function ifFn(done) {
|
||||
test('should put the same part twice', done => {
|
||||
async.waterfall([
|
||||
next => {
|
||||
const partBody = ['', body];
|
||||
|
@ -146,74 +150,78 @@ describeFn() {
|
|||
async.timesSeries(2, (n, cb) => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
Body: partBody[n],
|
||||
PartNumber: 1,
|
||||
};
|
||||
s3.uploadPart(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(
|
||||
res.ETag, `"${partMD5[n]}"`);
|
||||
expect(res.ETag).toBe(`"${partMD5[n]}"`);
|
||||
cb();
|
||||
});
|
||||
}, () => next());
|
||||
},
|
||||
next => checkMPUResult(
|
||||
gcpBucketMPU, this.test.key, this.test.uploadId,
|
||||
gcpBucketMPU, testContext.test.key, testContext.test.uploadId,
|
||||
1, correctMD5, next),
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with same key as preexisting part', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket },
|
||||
err => next(err)),
|
||||
next => {
|
||||
s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: {
|
||||
'scal-location-constraint': gcpLocation },
|
||||
Body: body,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Err putting object to ' +
|
||||
`GCP: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => {
|
||||
process.stdout.write('Aborting multipart upload\n');
|
||||
s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId },
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId },
|
||||
err => next(err));
|
||||
},
|
||||
next => {
|
||||
process.stdout.write('Deleting object\n');
|
||||
s3.deleteObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key },
|
||||
Key: testContext.currentTest.key },
|
||||
err => next(err));
|
||||
},
|
||||
next => {
|
||||
|
@ -223,34 +231,35 @@ describeFn() {
|
|||
err => next(err));
|
||||
},
|
||||
], err => {
|
||||
assert.equal(err, null, `Err in afterEach: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put a part without overwriting existing object',
|
||||
function itFn(done) {
|
||||
const body = Buffer.alloc(20);
|
||||
s3.uploadPart({
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body,
|
||||
}, err => {
|
||||
assert.strictEqual(err, null, 'Err putting part to ' +
|
||||
`GCP: ${err}`);
|
||||
gcpClient.getObject({
|
||||
Bucket: gcpBucket,
|
||||
Key: this.test.key,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
done();
|
||||
test(
|
||||
'should put a part without overwriting existing object',
|
||||
done => {
|
||||
const body = Buffer.alloc(20);
|
||||
s3.uploadPart({
|
||||
Bucket: bucket,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body,
|
||||
}, err => {
|
||||
expect(err).toBe(null);
|
||||
gcpClient.getObject({
|
||||
Bucket: gcpBucket,
|
||||
Key: testContext.test.key,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -260,53 +269,59 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend put part to GCP location ' +
|
|||
describeF() {
|
||||
this.timeout(80000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
describe('with bucket location header', () => {
|
||||
beforeEach(function beforeEachFn(done) {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.createBucket({ Bucket: bucket,
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
Key: testContext.currentTest.key,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
gcpLocationMismatch },
|
||||
}, (err, res) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
return next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterEachFn(done) {
|
||||
afterEach(done => {
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.key,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.key,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => next(err)),
|
||||
next => s3.deleteBucket({ Bucket: bucket },
|
||||
err => next(err)),
|
||||
], err => {
|
||||
assert.equal(err, null, `Error aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put part to GCP location with bucketMatch' +
|
||||
' sets to false', function itFn(done) {
|
||||
test('should put part to GCP location with bucketMatch' +
|
||||
' sets to false', done => {
|
||||
const body20 = Buffer.alloc(20);
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.key,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.key,
|
||||
UploadId: testContext.test.uploadId,
|
||||
PartNumber: 1,
|
||||
Body: body20,
|
||||
};
|
||||
|
@ -314,12 +329,12 @@ describeF() {
|
|||
'"441018525208457705bf09a8ee3c1093"';
|
||||
async.waterfall([
|
||||
next => s3.uploadPart(params, (err, res) => {
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const key =
|
||||
createMpuKey(this.test.key, this.test.uploadId, 1);
|
||||
createMpuKey(testContext.test.key, testContext.test.uploadId, 1);
|
||||
const mpuKey = `${bucket}/${key}`;
|
||||
const getParams = {
|
||||
Bucket: gcpBucketMPU,
|
||||
|
@ -328,7 +343,7 @@ describeF() {
|
|||
gcpClient.getObject(getParams, (err, res) => {
|
||||
assert.ifError(err,
|
||||
`Expected success, but got err ${err}`);
|
||||
assert.strictEqual(res.ETag, eTagExpected);
|
||||
expect(res.ETag).toBe(eTagExpected);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -51,13 +51,13 @@ function putSourceObj(key, location, objSize, bucket, cb) {
|
|||
sourceParams.Body = body;
|
||||
}
|
||||
s3.putObject(sourceParams, (err, result) => {
|
||||
assert.equal(err, null, `Error putting source object: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
if (objSize && objSize.empty) {
|
||||
assert.strictEqual(result.ETag, `"${emptyMD5}"`);
|
||||
expect(result.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else if (objSize && objSize.big) {
|
||||
assert.strictEqual(result.ETag, `"${bigMD5}"`);
|
||||
expect(result.ETag).toBe(`"${bigMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(result.ETag, `"${normalMD5}"`);
|
||||
expect(result.ETag).toBe(`"${normalMD5}"`);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
@ -72,42 +72,40 @@ destBucket, destLoc, azureKey, mdDirective, objSize, callback) {
|
|||
cb => s3.getObject(destGetParams, cb),
|
||||
cb => azureClient.getBlobProperties(azureContainerName, azureKey, cb),
|
||||
], (err, results) => {
|
||||
assert.equal(err, null, `Error in assertGetObjects: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const [sourceRes, destRes, azureRes] = results;
|
||||
const convertedMD5 = convertMD5(azureRes[0].contentSettings.contentMD5);
|
||||
if (objSize && objSize.empty) {
|
||||
assert.strictEqual(sourceRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(convertedMD5, `${emptyMD5}`);
|
||||
assert.strictEqual('0', azureRes[0].contentLength);
|
||||
expect(sourceRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(convertedMD5).toBe(`${emptyMD5}`);
|
||||
expect('0').toBe(azureRes[0].contentLength);
|
||||
} else if (objSize && objSize.big) {
|
||||
assert.strictEqual(sourceRes.ETag, `"${bigMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${bigMD5}"`);
|
||||
expect(sourceRes.ETag).toBe(`"${bigMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${bigMD5}"`);
|
||||
if (process.env.ENABLE_KMS_ENCRYPTION === 'true') {
|
||||
assert.strictEqual(sourceRes.ServerSideEncryption, 'AES256');
|
||||
assert.strictEqual(destRes.ServerSideEncryption, 'AES256');
|
||||
expect(sourceRes.ServerSideEncryption).toBe('AES256');
|
||||
expect(destRes.ServerSideEncryption).toBe('AES256');
|
||||
} else {
|
||||
assert.strictEqual(convertedMD5, `${bigMD5}`);
|
||||
expect(convertedMD5).toBe(`${bigMD5}`);
|
||||
}
|
||||
} else {
|
||||
if (process.env.ENABLE_KMS_ENCRYPTION === 'true') {
|
||||
assert.strictEqual(sourceRes.ServerSideEncryption, 'AES256');
|
||||
assert.strictEqual(destRes.ServerSideEncryption, 'AES256');
|
||||
expect(sourceRes.ServerSideEncryption).toBe('AES256');
|
||||
expect(destRes.ServerSideEncryption).toBe('AES256');
|
||||
} else {
|
||||
assert.strictEqual(sourceRes.ETag, `"${normalMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${normalMD5}"`);
|
||||
assert.strictEqual(convertedMD5, `${normalMD5}`);
|
||||
expect(sourceRes.ETag).toBe(`"${normalMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${normalMD5}"`);
|
||||
expect(convertedMD5).toBe(`${normalMD5}`);
|
||||
}
|
||||
}
|
||||
if (mdDirective === 'COPY') {
|
||||
assert.strictEqual(sourceRes.Metadata['test-header'],
|
||||
destRes.Metadata['test-header']);
|
||||
assert.strictEqual(azureRes[0].metadata.test_header,
|
||||
destRes.Metadata['test-header']);
|
||||
expect(sourceRes.Metadata['test-header']).toBe(destRes.Metadata['test-header']);
|
||||
expect(azureRes[0].metadata.test_header).toBe(destRes.Metadata['test-header']);
|
||||
}
|
||||
assert.strictEqual(sourceRes.ContentLength, destRes.ContentLength);
|
||||
assert.strictEqual(sourceRes.Metadata[locMetaHeader], sourceLoc);
|
||||
assert.strictEqual(destRes.Metadata[locMetaHeader], destLoc);
|
||||
expect(sourceRes.ContentLength).toBe(destRes.ContentLength);
|
||||
expect(sourceRes.Metadata[locMetaHeader]).toBe(sourceLoc);
|
||||
expect(destRes.Metadata[locMetaHeader]).toBe(destLoc);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
@ -116,7 +114,7 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend object copy: Azure',
|
|||
function testSuite() {
|
||||
this.timeout(250000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beFn() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.key = `azureputkey-${genUniqID()}`;
|
||||
this.currentTest.copyKey = `azurecopyKey-${genUniqID()}`;
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
|
@ -159,7 +157,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from mem to Azure', function itFn(done) {
|
||||
test('should copy an object from mem to Azure', done => {
|
||||
putSourceObj(this.test.key, memLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -169,10 +167,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, memLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', null, done);
|
||||
|
@ -180,28 +176,28 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object with no location contraint from mem to Azure',
|
||||
function itFn(done) {
|
||||
putSourceObj(this.test.key, null, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucketAzure,
|
||||
Key: this.test.copyKey,
|
||||
CopySource: `/${bucket}/${this.test.key}`,
|
||||
MetadataDirective: 'COPY',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, undefined,
|
||||
this.test.copyKey, bucketAzure, undefined,
|
||||
this.test.copyKey, 'COPY', null, done);
|
||||
test(
|
||||
'should copy an object with no location contraint from mem to Azure',
|
||||
done => {
|
||||
putSourceObj(this.test.key, null, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucketAzure,
|
||||
Key: this.test.copyKey,
|
||||
CopySource: `/${bucket}/${this.test.key}`,
|
||||
MetadataDirective: 'COPY',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, undefined,
|
||||
this.test.copyKey, bucketAzure, undefined,
|
||||
this.test.copyKey, 'COPY', null, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should copy an object from Azure to mem', function itFn(done) {
|
||||
test('should copy an object from Azure to mem', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -211,10 +207,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, memLocation, this.test.key,
|
||||
'REPLACE', null, done);
|
||||
|
@ -222,7 +216,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from AWS to Azure', function itFn(done) {
|
||||
test('should copy an object from AWS to Azure', done => {
|
||||
putSourceObj(this.test.key, awsLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -232,10 +226,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, awsLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', null, done);
|
||||
|
@ -243,7 +235,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from Azure to AWS', function itFn(done) {
|
||||
test('should copy an object from Azure to AWS', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -253,10 +245,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, awsLocation, this.test.key,
|
||||
'REPLACE', null, done);
|
||||
|
@ -264,8 +254,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from Azure to mem with "REPLACE" directive ' +
|
||||
'and no location constraint md', function itFn(done) {
|
||||
test('should copy an object from Azure to mem with "REPLACE" directive ' +
|
||||
'and no location constraint md', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -274,10 +264,8 @@ function testSuite() {
|
|||
MetadataDirective: 'REPLACE',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, undefined, this.test.key,
|
||||
'REPLACE', null, done);
|
||||
|
@ -285,8 +273,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from mem to Azure with "REPLACE" directive ' +
|
||||
'and no location constraint md', function itFn(done) {
|
||||
test('should copy an object from mem to Azure with "REPLACE" directive ' +
|
||||
'and no location constraint md', done => {
|
||||
putSourceObj(this.test.key, null, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucketAzure,
|
||||
|
@ -295,10 +283,8 @@ function testSuite() {
|
|||
MetadataDirective: 'REPLACE',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, undefined,
|
||||
this.test.copyKey, bucketAzure, undefined,
|
||||
this.test.copyKey, 'REPLACE', null, done);
|
||||
|
@ -306,9 +292,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from Azure to Azure showing sending ' +
|
||||
'metadata location constraint this doesn\'t matter with COPY directive',
|
||||
function itFn(done) {
|
||||
test('should copy an object from Azure to Azure showing sending ' +
|
||||
'metadata location constraint this doesn\'t matter with COPY directive', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucketAzure,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -319,10 +304,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucketAzure, azureLocation,
|
||||
this.test.copyKey, bucketAzure, azureLocation,
|
||||
this.test.copyKey, 'COPY', null, done);
|
||||
|
@ -330,9 +313,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object with no location constraint from Azure to ' +
|
||||
'Azure relying on the bucket location constraint',
|
||||
function itFn(done) {
|
||||
test('should copy an object with no location constraint from Azure to ' +
|
||||
'Azure relying on the bucket location constraint', done => {
|
||||
putSourceObj(this.test.key, null, null, bucketAzure,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -342,10 +324,8 @@ function testSuite() {
|
|||
MetadataDirective: 'COPY',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucketAzure, undefined,
|
||||
this.test.copyKey, bucketAzure, undefined,
|
||||
this.test.copyKey, 'COPY', null, done);
|
||||
|
@ -353,8 +333,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from Azure to mem because bucket ' +
|
||||
'destination location is mem', function itFn(done) {
|
||||
test('should copy an object from Azure to mem because bucket ' +
|
||||
'destination location is mem', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -363,10 +343,8 @@ function testSuite() {
|
|||
MetadataDirective: 'COPY',
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, memLocation,
|
||||
this.test.key, 'COPY', null, done);
|
||||
|
@ -374,9 +352,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object on Azure to a different Azure ' +
|
||||
'account without source object READ access',
|
||||
function itFn(done) {
|
||||
test('should copy an object on Azure to a different Azure ' +
|
||||
'account without source object READ access', done => {
|
||||
putSourceObj(this.test.key, azureLocation2, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -386,10 +363,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation2,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', null, done);
|
||||
|
@ -397,9 +372,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 5MB object on Azure to a different Azure ' +
|
||||
'account without source object READ access',
|
||||
function itFn(done) {
|
||||
test('should copy a 5MB object on Azure to a different Azure ' +
|
||||
'account without source object READ access', done => {
|
||||
putSourceObj(this.test.key, azureLocation2, { big: true }, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -410,10 +384,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${bigMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${bigMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation2,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', { big: true }, done);
|
||||
|
@ -421,9 +393,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from bucketmatch=false ' +
|
||||
'Azure location to MPU with a bucketmatch=false Azure location',
|
||||
function itFn(done) {
|
||||
test('should copy an object from bucketmatch=false ' +
|
||||
'Azure location to MPU with a bucketmatch=false Azure location', done => {
|
||||
putSourceObj(this.test.key, azureLocationMismatch, null, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -435,10 +406,8 @@ function testSuite() {
|
|||
azureLocationMismatch },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket,
|
||||
azureLocationMismatch,
|
||||
this.test.copyKey, bucket, azureLocationMismatch,
|
||||
|
@ -448,9 +417,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from bucketmatch=false ' +
|
||||
'Azure location to MPU with a bucketmatch=true Azure location',
|
||||
function itFn(done) {
|
||||
test('should copy an object from bucketmatch=false ' +
|
||||
'Azure location to MPU with a bucketmatch=true Azure location', done => {
|
||||
putSourceObj(this.test.key, azureLocationMismatch, null, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -461,10 +429,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket,
|
||||
azureLocationMismatch,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
|
@ -473,9 +439,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from bucketmatch=true ' +
|
||||
'Azure location to MPU with a bucketmatch=false Azure location',
|
||||
function itFn(done) {
|
||||
test('should copy an object from bucketmatch=true ' +
|
||||
'Azure location to MPU with a bucketmatch=false Azure location', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket, () => {
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
|
@ -486,10 +451,8 @@ function testSuite() {
|
|||
azureLocationMismatch },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${normalMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket,
|
||||
azureLocation,
|
||||
this.test.copyKey, bucket, azureLocationMismatch,
|
||||
|
@ -499,8 +462,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 0-byte object from mem to Azure',
|
||||
function itFn(done) {
|
||||
test('should copy a 0-byte object from mem to Azure', done => {
|
||||
putSourceObj(this.test.key, memLocation, { empty: true }, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -511,10 +473,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${emptyMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, memLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', { empty: true }, done);
|
||||
|
@ -522,7 +482,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 0-byte object on Azure', function itFn(done) {
|
||||
test('should copy a 0-byte object on Azure', done => {
|
||||
putSourceObj(this.test.key, azureLocation, { empty: true }, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -533,10 +493,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${emptyMD5}"`);
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
this.test.copyKey, 'REPLACE', { empty: true }, done);
|
||||
|
@ -544,7 +502,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 5MB object from mem to Azure', function itFn(done) {
|
||||
test('should copy a 5MB object from mem to Azure', done => {
|
||||
putSourceObj(this.test.key, memLocation, { big: true }, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -555,9 +513,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, `Err copying object: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${bigMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${bigMD5}"`);
|
||||
setTimeout(() => {
|
||||
assertGetObjects(this.test.key, bucket, memLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
|
@ -567,7 +524,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 5MB object on Azure', function itFn(done) {
|
||||
test('should copy a 5MB object on Azure', done => {
|
||||
putSourceObj(this.test.key, azureLocation, { big: true }, bucket,
|
||||
() => {
|
||||
const copyParams = {
|
||||
|
@ -578,9 +535,8 @@ function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, `Err copying object: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${bigMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${bigMD5}"`);
|
||||
setTimeout(() => {
|
||||
assertGetObjects(this.test.key, bucket, azureLocation,
|
||||
this.test.copyKey, bucket, azureLocation,
|
||||
|
@ -590,14 +546,13 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return error if Azure source object has ' +
|
||||
'been deleted', function itFn(done) {
|
||||
test('should return error if Azure source object has ' +
|
||||
'been deleted', done => {
|
||||
putSourceObj(this.test.key, azureLocation, null, bucket,
|
||||
() => {
|
||||
azureClient.deleteBlob(azureContainerName, this.test.key,
|
||||
err => {
|
||||
assert.equal(err, null, 'Error deleting object from ' +
|
||||
`Azure: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const copyParams = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.copyKey,
|
||||
|
@ -605,7 +560,7 @@ function testSuite() {
|
|||
MetadataDirective: 'COPY',
|
||||
};
|
||||
s3.copyObject(copyParams, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,11 +38,11 @@ function putSourceObj(location, isEmptyObj, bucket, cb) {
|
|||
}
|
||||
process.stdout.write('Putting source object\n');
|
||||
s3.putObject(sourceParams, (err, result) => {
|
||||
assert.equal(err, null, `Error putting source object: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
if (isEmptyObj) {
|
||||
assert.strictEqual(result.ETag, `"${emptyMD5}"`);
|
||||
expect(result.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(result.ETag, `"${correctMD5}"`);
|
||||
expect(result.ETag).toBe(`"${correctMD5}"`);
|
||||
}
|
||||
cb(key);
|
||||
});
|
||||
|
@ -61,47 +61,45 @@ callback) {
|
|||
cb => s3.getObject(destGetParams, cb),
|
||||
cb => awsS3.getObject(awsParams, cb),
|
||||
], (err, results) => {
|
||||
assert.equal(err, null, `Error in assertGetObjects: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const [sourceRes, destRes, awsRes] = results;
|
||||
if (isEmptyObj) {
|
||||
assert.strictEqual(sourceRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(awsRes.ETag, `"${emptyMD5}"`);
|
||||
expect(sourceRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(awsRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else if (process.env.ENABLE_KMS_ENCRYPTION === 'true') {
|
||||
assert.strictEqual(sourceRes.ServerSideEncryption, 'AES256');
|
||||
assert.strictEqual(destRes.ServerSideEncryption, 'AES256');
|
||||
expect(sourceRes.ServerSideEncryption).toBe('AES256');
|
||||
expect(destRes.ServerSideEncryption).toBe('AES256');
|
||||
} else {
|
||||
assert.strictEqual(sourceRes.ETag, `"${correctMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${correctMD5}"`);
|
||||
expect(sourceRes.ETag).toBe(`"${correctMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${correctMD5}"`);
|
||||
assert.deepStrictEqual(sourceRes.Body, destRes.Body);
|
||||
assert.strictEqual(awsRes.ETag, `"${correctMD5}"`);
|
||||
expect(awsRes.ETag).toBe(`"${correctMD5}"`);
|
||||
assert.deepStrictEqual(sourceRes.Body, awsRes.Body);
|
||||
}
|
||||
if (destLoc === awsLocationEncryption) {
|
||||
assert.strictEqual(awsRes.ServerSideEncryption, 'AES256');
|
||||
expect(awsRes.ServerSideEncryption).toBe('AES256');
|
||||
} else {
|
||||
assert.strictEqual(awsRes.ServerSideEncryption, undefined);
|
||||
expect(awsRes.ServerSideEncryption).toBe(undefined);
|
||||
}
|
||||
if (mdDirective === 'COPY') {
|
||||
assert.deepStrictEqual(sourceRes.Metadata['test-header'],
|
||||
destRes.Metadata['test-header']);
|
||||
} else if (mdDirective === 'REPLACE') {
|
||||
assert.strictEqual(destRes.Metadata['test-header'],
|
||||
undefined);
|
||||
expect(destRes.Metadata['test-header']).toBe(undefined);
|
||||
}
|
||||
if (destLoc === awsLocation) {
|
||||
assert.strictEqual(awsRes.Metadata[locMetaHeader], destLoc);
|
||||
expect(awsRes.Metadata[locMetaHeader]).toBe(destLoc);
|
||||
if (mdDirective === 'COPY') {
|
||||
assert.deepStrictEqual(sourceRes.Metadata['test-header'],
|
||||
awsRes.Metadata['test-header']);
|
||||
} else if (mdDirective === 'REPLACE') {
|
||||
assert.strictEqual(awsRes.Metadata['test-header'],
|
||||
undefined);
|
||||
expect(awsRes.Metadata['test-header']).toBe(undefined);
|
||||
}
|
||||
}
|
||||
assert.strictEqual(sourceRes.ContentLength, destRes.ContentLength);
|
||||
assert.strictEqual(sourceRes.Metadata[locMetaHeader], sourceLoc);
|
||||
assert.strictEqual(destRes.Metadata[locMetaHeader], destLoc);
|
||||
expect(sourceRes.ContentLength).toBe(destRes.ContentLength);
|
||||
expect(sourceRes.Metadata[locMetaHeader]).toBe(sourceLoc);
|
||||
expect(destRes.Metadata[locMetaHeader]).toBe(destLoc);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
@ -163,9 +161,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from mem to AWS relying on ' +
|
||||
'destination bucket location',
|
||||
done => {
|
||||
test('should copy an object from mem to AWS relying on ' +
|
||||
'destination bucket location', done => {
|
||||
putSourceObj(memLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -176,10 +173,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, memLocation, copyKey,
|
||||
bucketAws, awsLocation, copyKey, 'COPY', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -187,9 +182,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from Azure to AWS relying on ' +
|
||||
'destination bucket location',
|
||||
done => {
|
||||
test('should copy an object from Azure to AWS relying on ' +
|
||||
'destination bucket location', done => {
|
||||
putSourceObj(azureLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -200,10 +194,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, azureLocation, copyKey,
|
||||
bucketAws, awsLocation, copyKey, 'COPY', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -211,9 +203,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object without location contraint from mem ' +
|
||||
'to AWS relying on destination bucket location',
|
||||
done => {
|
||||
test('should copy an object without location contraint from mem ' +
|
||||
'to AWS relying on destination bucket location', done => {
|
||||
putSourceObj(null, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -224,10 +215,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, undefined, copyKey,
|
||||
bucketAws, undefined, copyKey, 'COPY', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -235,9 +224,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from AWS to mem relying on destination ' +
|
||||
'bucket location',
|
||||
done => {
|
||||
test('should copy an object from AWS to mem relying on destination ' +
|
||||
'bucket location', done => {
|
||||
putSourceObj(awsLocation, false, bucketAws, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -248,10 +236,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucketAws, awsLocation, copyKey,
|
||||
bucket, memLocation, key, 'COPY', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -259,7 +245,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from mem to AWS', done => {
|
||||
test('should copy an object from mem to AWS', done => {
|
||||
putSourceObj(memLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -272,10 +258,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, memLocation, copyKey, bucket,
|
||||
awsLocation, copyKey, 'REPLACE', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -297,10 +281,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, memLocation, copyKey, bucket,
|
||||
awsLocationEncryption, copyKey, 'REPLACE', false,
|
||||
awsS3, awsLocation, done);
|
||||
|
@ -308,7 +290,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from AWS to mem with encryption with ' +
|
||||
test('should copy an object from AWS to mem with encryption with ' +
|
||||
'REPLACE directive but no location constraint', done => {
|
||||
putSourceObj(awsLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
|
@ -320,10 +302,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
undefined, key, 'REPLACE', false,
|
||||
awsS3, awsLocation, done);
|
||||
|
@ -346,10 +326,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
awsLocationEncryption, copyKey, 'REPLACE', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -370,10 +348,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, awsServerSideEncryptionbucket,
|
||||
awsLocation, copyKey, awsServerSideEncryptionbucket,
|
||||
awsLocationEncryption, copyKey, 'COPY',
|
||||
|
@ -382,7 +358,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from mem to AWS with encryption with ' +
|
||||
test('should copy an object from mem to AWS with encryption with ' +
|
||||
'REPLACE directive but no location constraint', done => {
|
||||
putSourceObj(null, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
|
@ -394,10 +370,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, undefined, copyKey,
|
||||
bucketAws, undefined, copyKey, 'REPLACE', false,
|
||||
awsS3, awsLocation, done);
|
||||
|
@ -405,9 +379,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object from AWS to mem with "COPY" ' +
|
||||
'directive and aws location metadata',
|
||||
done => {
|
||||
test('should copy an object from AWS to mem with "COPY" ' +
|
||||
'directive and aws location metadata', done => {
|
||||
putSourceObj(awsLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -420,10 +393,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
memLocation, key, 'COPY', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -431,7 +402,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object on AWS', done => {
|
||||
test('should copy an object on AWS', done => {
|
||||
putSourceObj(awsLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -443,10 +414,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
awsLocation, copyKey, 'REPLACE', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -454,9 +423,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object on AWS location with bucketMatch equals ' +
|
||||
'false to a different AWS location with bucketMatch equals true',
|
||||
done => {
|
||||
test('should copy an object on AWS location with bucketMatch equals ' +
|
||||
'false to a different AWS location with bucketMatch equals true', done => {
|
||||
putSourceObj(awsLocationMismatch, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -469,10 +437,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocationMismatch, copyKey,
|
||||
bucket, awsLocation, copyKey, 'REPLACE', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -480,9 +446,8 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy an object on AWS to a different AWS location ' +
|
||||
'with source object READ access',
|
||||
done => {
|
||||
test('should copy an object on AWS to a different AWS location ' +
|
||||
'with source object READ access', done => {
|
||||
const awsConfig2 = getRealAwsConfig(awsLocation2);
|
||||
const awsS3Two = new AWS.S3(awsConfig2);
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
|
@ -506,10 +471,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success ' +
|
||||
`but got error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
next(err, key);
|
||||
});
|
||||
},
|
||||
|
@ -535,13 +498,13 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, err => {
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy an object on AWS with REPLACE', done => {
|
||||
test('should copy an object on AWS with REPLACE', done => {
|
||||
putSourceObj(awsLocation, false, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -554,10 +517,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${correctMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${correctMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
awsLocation, copyKey, 'REPLACE', false, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -565,7 +526,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 0-byte object from mem to AWS', done => {
|
||||
test('should copy a 0-byte object from mem to AWS', done => {
|
||||
putSourceObj(memLocation, true, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -578,10 +539,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${emptyMD5}"`);
|
||||
assertGetObjects(key, bucket, memLocation, copyKey, bucket,
|
||||
awsLocation, copyKey, 'REPLACE', true, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -589,7 +548,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 0-byte object on AWS', done => {
|
||||
test('should copy a 0-byte object on AWS', done => {
|
||||
putSourceObj(awsLocation, true, bucket, key => {
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = {
|
||||
|
@ -601,10 +560,8 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, (err, result) => {
|
||||
assert.equal(err, null, 'Expected success but got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(result.CopyObjectResult.ETag,
|
||||
`"${emptyMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(result.CopyObjectResult.ETag).toBe(`"${emptyMD5}"`);
|
||||
assertGetObjects(key, bucket, awsLocation, copyKey, bucket,
|
||||
awsLocation, copyKey, 'REPLACE', true, awsS3,
|
||||
awsLocation, done);
|
||||
|
@ -612,14 +569,13 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return error if AWS source object has ' +
|
||||
test('should return error if AWS source object has ' +
|
||||
'been deleted', done => {
|
||||
putSourceObj(awsLocation, false, bucket, key => {
|
||||
const awsBucket =
|
||||
config.locationConstraints[awsLocation].details.bucketName;
|
||||
awsS3.deleteObject({ Bucket: awsBucket, Key: key }, err => {
|
||||
assert.equal(err, null, 'Error deleting object from AWS: ' +
|
||||
`${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const copyKey = `copyKey-${genUniqID()}`;
|
||||
const copyParams = { Bucket: bucket, Key: copyKey,
|
||||
CopySource: `/${bucket}/${key}`,
|
||||
|
@ -628,7 +584,7 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Copying object\n');
|
||||
s3.copyObject(copyParams, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -64,12 +64,11 @@ function putSourceObj(testParams, cb) {
|
|||
sourceParams.Body = someBody;
|
||||
}
|
||||
s3.putObject(sourceParams, (err, result) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Error putting source object: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (isEmptyObj) {
|
||||
assert.strictEqual(result.ETag, `"${emptyMD5}"`);
|
||||
expect(result.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(result.ETag, `"${correctMD5}"`);
|
||||
expect(result.ETag).toBe(`"${correctMD5}"`);
|
||||
}
|
||||
Object.assign(testParams, {
|
||||
sourceKey,
|
||||
|
@ -98,12 +97,11 @@ function copyObject(testParams, cb) {
|
|||
`${copyParams.CopySource}?versionId=null`;
|
||||
}
|
||||
s3.copyObject(copyParams, (err, data) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Error copying object to destination: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (destVersioningState === 'Enabled') {
|
||||
assert.notEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).not.toEqual(undefined);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
}
|
||||
const expectedBody = isEmptyObj ? '' : someBody;
|
||||
return awsGetLatestVerId(destKey, expectedBody, (err, awsVersionId) => {
|
||||
|
@ -145,17 +143,17 @@ function assertGetObjects(testParams, cb) {
|
|||
cb => s3.getObject(destGetParams, cb),
|
||||
cb => awsS3.getObject(awsParams, cb),
|
||||
], (err, results) => {
|
||||
assert.strictEqual(err, null, `Error in assertGetObjects: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const [sourceRes, destRes, awsRes] = results;
|
||||
if (isEmptyObj) {
|
||||
assert.strictEqual(sourceRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${emptyMD5}"`);
|
||||
assert.strictEqual(awsRes.ETag, `"${emptyMD5}"`);
|
||||
expect(sourceRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
expect(awsRes.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(sourceRes.ETag, `"${correctMD5}"`);
|
||||
assert.strictEqual(destRes.ETag, `"${correctMD5}"`);
|
||||
expect(sourceRes.ETag).toBe(`"${correctMD5}"`);
|
||||
expect(destRes.ETag).toBe(`"${correctMD5}"`);
|
||||
assert.deepStrictEqual(sourceRes.Body, destRes.Body);
|
||||
assert.strictEqual(awsRes.ETag, `"${correctMD5}"`);
|
||||
expect(awsRes.ETag).toBe(`"${correctMD5}"`);
|
||||
assert.deepStrictEqual(sourceRes.Body, awsRes.Body);
|
||||
}
|
||||
if (directive === 'COPY') {
|
||||
|
@ -166,7 +164,7 @@ function assertGetObjects(testParams, cb) {
|
|||
assert.deepStrictEqual(destRes.Metadata, {});
|
||||
assert.deepStrictEqual(awsRes.Metadata, {});
|
||||
}
|
||||
assert.strictEqual(sourceRes.ContentLength, destRes.ContentLength);
|
||||
expect(sourceRes.ContentLength).toBe(destRes.ContentLength);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -198,8 +196,7 @@ function testSuite() {
|
|||
`in afterEach: ${err}\n`);
|
||||
throw err;
|
||||
}
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
[{
|
||||
directive: 'REPLACE',
|
||||
|
@ -357,7 +354,7 @@ function testSuite() {
|
|||
expectedError: 'NoSuchKey' }, next),
|
||||
next => awsGetLatestVerId(testParams.destKey, someBody, next),
|
||||
(awsVerId, next) => {
|
||||
assert.strictEqual(awsVerId, this.test.awsVerId);
|
||||
expect(awsVerId).toBe(this.test.awsVerId);
|
||||
next();
|
||||
},
|
||||
], done);
|
||||
|
@ -389,7 +386,7 @@ function testSuite() {
|
|||
});
|
||||
const { sourceLocation, directive, isEmptyObj } = testParams;
|
||||
|
||||
it(`should copy ${isEmptyObj ? 'empty ' : ''}object from ` +
|
||||
test(`should copy ${isEmptyObj ? 'empty ' : ''}object from ` +
|
||||
`${sourceLocation} to bucket on AWS backend with ` +
|
||||
`versioning with ${directive}`, done => {
|
||||
async.waterfall([
|
||||
|
@ -401,7 +398,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it(`should copy ${isEmptyObj ? 'an empty ' : ''}version from ` +
|
||||
test(`should copy ${isEmptyObj ? 'an empty ' : ''}version from ` +
|
||||
`${sourceLocation} to bucket on AWS backend with ` +
|
||||
`versioning with ${directive} directive`, done => {
|
||||
async.waterfall([
|
||||
|
|
|
@ -86,8 +86,7 @@ function assertCopyPart(infos, cb) {
|
|||
Key: mpuKeyNameAzure,
|
||||
UploadId: uploadId,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
|
@ -98,13 +97,11 @@ function assertCopyPart(infos, cb) {
|
|||
}),
|
||||
next => azureClient.listBlocks(azureContainerName,
|
||||
mpuKeyNameAzure, 'all', (err, res) => {
|
||||
assert.equal(err, null, 'listBlocks: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
subPartSize.forEach((size, index) => {
|
||||
const partName = azureMpuUtils.getBlockId(uploadId, 1, index);
|
||||
assert.strictEqual(res.UncommittedBlocks[index].Name,
|
||||
partName);
|
||||
assert.equal(res.UncommittedBlocks[index].Size, size);
|
||||
expect(res.UncommittedBlocks[index].Name).toBe(partName);
|
||||
expect(res.UncommittedBlocks[index].Size).toEqual(size);
|
||||
});
|
||||
next();
|
||||
}),
|
||||
|
@ -137,36 +134,42 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
});
|
||||
});
|
||||
describe('Basic test: ', () => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.keyNameNormalAzure =
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.keyNameNormalAzure =
|
||||
`normalazure${uniqName(keyObjectAzure)}`;
|
||||
this.currentTest.keyNameNormalAzureMismatch =
|
||||
testContext.currentTest.keyNameNormalAzureMismatch =
|
||||
`normalazuremismatch${uniqName(keyObjectAzure)}`;
|
||||
|
||||
this.currentTest.keyNameFiveMbAzure =
|
||||
testContext.currentTest.keyNameFiveMbAzure =
|
||||
`fivembazure${uniqName(keyObjectAzure)}`;
|
||||
this.currentTest.keyNameFiveMbMem =
|
||||
testContext.currentTest.keyNameFiveMbMem =
|
||||
`fivembmem${uniqName(keyObjectMemory)}`;
|
||||
|
||||
this.currentTest.mpuKeyNameAzure =
|
||||
testContext.currentTest.mpuKeyNameAzure =
|
||||
`mpukeyname${uniqName(keyObjectAzure)}`;
|
||||
this.currentTest.mpuKeyNameMem =
|
||||
testContext.currentTest.mpuKeyNameMem =
|
||||
`mpukeyname${uniqName(keyObjectMemory)}`;
|
||||
this.currentTest.mpuKeyNameAWS =
|
||||
testContext.currentTest.mpuKeyNameAWS =
|
||||
`mpukeyname${uniqName(keyObjectAWS)}`;
|
||||
const paramsAzure = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
const paramsMem = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameMem,
|
||||
Key: testContext.currentTest.mpuKeyNameMem,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
const paramsAWS = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameAWS,
|
||||
Key: testContext.currentTest.mpuKeyNameAWS,
|
||||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -176,67 +179,64 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyNameNormalAzure,
|
||||
Key: testContext.currentTest.keyNameNormalAzure,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyNameNormalAzureMismatch,
|
||||
Key: testContext.currentTest.keyNameNormalAzureMismatch,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocationMismatch },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyNameFiveMbAzure,
|
||||
Key: testContext.currentTest.keyNameFiveMbAzure,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyNameFiveMbMem,
|
||||
Key: testContext.currentTest.keyNameFiveMbMem,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload(paramsAzure,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload ' +
|
||||
`on Azure: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(paramsMem,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload ' +
|
||||
`in memory: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadIdMem = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadIdMem = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(paramsAWS,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload ' +
|
||||
`on AWS: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadIdAWS = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadIdAWS = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
afterEach(function afterEachF(done) {
|
||||
afterEach(done => {
|
||||
const paramsAzure = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
const paramsMem = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameMem,
|
||||
UploadId: this.currentTest.uploadIdMem,
|
||||
Key: testContext.currentTest.mpuKeyNameMem,
|
||||
UploadId: testContext.currentTest.uploadIdMem,
|
||||
};
|
||||
const paramsAWS = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameAWS,
|
||||
UploadId: this.currentTest.uploadIdAWS,
|
||||
Key: testContext.currentTest.mpuKeyNameAWS,
|
||||
UploadId: testContext.currentTest.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload(paramsAzure,
|
||||
|
@ -247,60 +247,59 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
err => next(err)),
|
||||
], done);
|
||||
});
|
||||
it('should copy small part from Azure to MPU with Azure location',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameNormalAzure}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: this.test.mpuKeyNameAzure,
|
||||
uploadId: this.test.uploadId,
|
||||
md5: normalMD5,
|
||||
subPartSize: [normalBodySize],
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should copy small part from Azure to MPU with Azure location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${testContext.test.keyNameNormalAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: testContext.test.mpuKeyNameAzure,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: normalMD5,
|
||||
subPartSize: [normalBodySize],
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('should copy small part from Azure location with ' +
|
||||
'bucketMatch=false to MPU with Azure location',
|
||||
function ifF(done) {
|
||||
test('should copy small part from Azure location with ' +
|
||||
'bucketMatch=false to MPU with Azure location', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/` +
|
||||
`${this.test.keyNameNormalAzureMismatch}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${testContext.test.keyNameNormalAzureMismatch}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: this.test.mpuKeyNameAzure,
|
||||
uploadId: this.test.uploadId,
|
||||
mpuKeyNameAzure: testContext.test.mpuKeyNameAzure,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: normalMD5,
|
||||
subPartSize: [normalBodySize],
|
||||
};
|
||||
|
@ -309,141 +308,135 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should copy 5 Mb part from Azure to MPU with Azure location',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameFiveMbAzure}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: this.test.mpuKeyNameAzure,
|
||||
uploadId: this.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
subPartSize: [fiveMB],
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should copy 5 Mb part from Azure to MPU with Azure location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${testContext.test.keyNameFiveMbAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: testContext.test.mpuKeyNameAzure,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
subPartSize: [fiveMB],
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('should copy part from Azure to MPU with memory location',
|
||||
function ifF(done) {
|
||||
test(
|
||||
'should copy part from Azure to MPU with memory location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${testContext.test.keyNameNormalAzure}`,
|
||||
Key: testContext.test.mpuKeyNameMem,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadIdMem,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
s3.listParts({
|
||||
Bucket: memBucketName,
|
||||
Key: testContext.test.mpuKeyNameMem,
|
||||
UploadId: testContext.test.uploadIdMem,
|
||||
}, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
const resultCopy =
|
||||
JSON.parse(JSON.stringify(result));
|
||||
resultCopy.Bucket = memBucketName;
|
||||
resultCopy.Key = testContext.test.mpuKeyNameMem;
|
||||
resultCopy.UploadId = testContext.test.uploadIdMem;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
ETag: `"${normalMD5}"`,
|
||||
Size: normalBodySize }];
|
||||
assert.deepStrictEqual(res, resultCopy);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
test(
|
||||
'should copy part from Azure to MPU with AWS location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${testContext.test.keyNameNormalAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const awsBucket =
|
||||
config.locationConstraints[awsLocation]
|
||||
.details.bucketName;
|
||||
awsS3.listParts({
|
||||
Bucket: awsBucket,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
}, (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Bucket).toBe(awsBucket);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameAWS);
|
||||
expect(res.UploadId).toBe(testContext.test.uploadIdAWS);
|
||||
expect(res.Parts.length).toBe(1);
|
||||
expect(res.Parts[0].PartNumber).toBe(1);
|
||||
expect(res.Parts[0].ETag).toBe(`"${normalMD5}"`);
|
||||
expect(res.Parts[0].Size).toBe(normalBodySize);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
test('should copy part from Azure object with range to MPU ' +
|
||||
'with AWS location', done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameNormalAzure}`,
|
||||
Key: this.test.mpuKeyNameMem,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdMem,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
s3.listParts({
|
||||
Bucket: memBucketName,
|
||||
Key: this.test.mpuKeyNameMem,
|
||||
UploadId: this.test.uploadIdMem,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
const resultCopy =
|
||||
JSON.parse(JSON.stringify(result));
|
||||
resultCopy.Bucket = memBucketName;
|
||||
resultCopy.Key = this.test.mpuKeyNameMem;
|
||||
resultCopy.UploadId = this.test.uploadIdMem;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
ETag: `"${normalMD5}"`,
|
||||
Size: normalBodySize }];
|
||||
assert.deepStrictEqual(res, resultCopy);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy part from Azure to MPU with AWS location',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameNormalAzure}`,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const awsBucket =
|
||||
config.locationConstraints[awsLocation]
|
||||
.details.bucketName;
|
||||
awsS3.listParts({
|
||||
Bucket: awsBucket,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, awsBucket);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameAWS);
|
||||
assert.strictEqual(res.UploadId,
|
||||
this.test.uploadIdAWS);
|
||||
assert.strictEqual(res.Parts.length, 1);
|
||||
assert.strictEqual(res.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(res.Parts[0].ETag,
|
||||
`"${normalMD5}"`);
|
||||
assert.strictEqual(res.Parts[0].Size,
|
||||
normalBodySize);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy part from Azure object with range to MPU ' +
|
||||
'with AWS location', function ifF(done) {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameNormalAzure}`,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
`${azureContainerName}/${testContext.test.keyNameNormalAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
CopySourceRange: 'bytes=0-5',
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${sixBytesMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${sixBytesMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
|
@ -452,51 +445,44 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
.details.bucketName;
|
||||
awsS3.listParts({
|
||||
Bucket: awsBucket,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, awsBucket);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameAWS);
|
||||
assert.strictEqual(res.UploadId,
|
||||
this.test.uploadIdAWS);
|
||||
assert.strictEqual(res.Parts.length, 1);
|
||||
assert.strictEqual(res.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(res.Parts[0].ETag,
|
||||
`"${sixBytesMD5}"`);
|
||||
assert.strictEqual(res.Parts[0].Size, 6);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Bucket).toBe(awsBucket);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameAWS);
|
||||
expect(res.UploadId).toBe(testContext.test.uploadIdAWS);
|
||||
expect(res.Parts.length).toBe(1);
|
||||
expect(res.Parts[0].PartNumber).toBe(1);
|
||||
expect(res.Parts[0].ETag).toBe(`"${sixBytesMD5}"`);
|
||||
expect(res.Parts[0].Size).toBe(6);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy 5 Mb part from a memory location to MPU with ' +
|
||||
'Azure location',
|
||||
function ifF(done) {
|
||||
test('should copy 5 Mb part from a memory location to MPU with ' +
|
||||
'Azure location', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameFiveMbMem}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${azureContainerName}/${testContext.test.keyNameFiveMbMem}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure: this.test.mpuKeyNameAzure,
|
||||
uploadId: this.test.uploadId,
|
||||
mpuKeyNameAzure: testContext.test.mpuKeyNameAzure,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
subPartSize: [fiveMB],
|
||||
};
|
||||
|
@ -506,45 +492,42 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
});
|
||||
|
||||
describe('with existing part', () => {
|
||||
beforeEach(function beF(done) {
|
||||
beforeEach(done => {
|
||||
const params = {
|
||||
Body: oneKbBody,
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
s3.uploadPart(params, done);
|
||||
});
|
||||
it('should copy part from Azure to Azure with existing ' +
|
||||
'parts', function ifF(done) {
|
||||
test('should copy part from Azure to Azure with existing ' +
|
||||
'parts', done => {
|
||||
const resultCopy = JSON.parse(JSON.stringify(result));
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/${this.test.keyNameNormalAzure}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${azureContainerName}/${testContext.test.keyNameNormalAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 2,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null,
|
||||
'uploadPartCopy: Expected success, got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listParts({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
UploadId: testContext.test.uploadId,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'listParts: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
resultCopy.Bucket = azureContainerName;
|
||||
resultCopy.Key = this.test.mpuKeyNameAzure;
|
||||
resultCopy.UploadId = this.test.uploadId;
|
||||
resultCopy.Key = testContext.test.mpuKeyNameAzure;
|
||||
resultCopy.UploadId = testContext.test.uploadId;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
|
@ -559,21 +542,16 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to AZURE', function describeF() {
|
|||
next();
|
||||
}),
|
||||
next => azureClient.listBlocks(azureContainerName,
|
||||
this.test.mpuKeyNameAzure, 'all', (err, res) => {
|
||||
assert.equal(err, null, 'listBlocks: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
testContext.test.mpuKeyNameAzure, 'all', (err, res) => {
|
||||
expect(err).toEqual(null);
|
||||
const partName = azureMpuUtils.getBlockId(
|
||||
this.test.uploadId, 1, 0);
|
||||
testContext.test.uploadId, 1, 0);
|
||||
const partName2 = azureMpuUtils.getBlockId(
|
||||
this.test.uploadId, 2, 0);
|
||||
assert.strictEqual(res.UncommittedBlocks[0].Name,
|
||||
partName);
|
||||
assert.equal(res.UncommittedBlocks[0].Size,
|
||||
oneKb);
|
||||
assert.strictEqual(res.UncommittedBlocks[1].Name,
|
||||
partName2);
|
||||
assert.equal(res.UncommittedBlocks[1].Size,
|
||||
11);
|
||||
testContext.test.uploadId, 2, 0);
|
||||
expect(res.UncommittedBlocks[0].Name).toBe(partName);
|
||||
expect(res.UncommittedBlocks[0].Size).toEqual(oneKb);
|
||||
expect(res.UncommittedBlocks[1].Name).toBe(partName2);
|
||||
expect(res.UncommittedBlocks[1].Size).toEqual(11);
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -605,15 +583,21 @@ function describeF() {
|
|||
});
|
||||
});
|
||||
describe('Basic test with large object: ', () => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.keyNameOneHundredAndFiveMbAzure =
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.keyNameOneHundredAndFiveMbAzure =
|
||||
`onehundredandfivembazure${uniqName(keyObjectAzure)}`;
|
||||
this.currentTest.mpuKeyNameAzure =
|
||||
testContext.currentTest.mpuKeyNameAzure =
|
||||
`mpukeyname${uniqName(keyObjectAzure)}`;
|
||||
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -621,52 +605,49 @@ function describeF() {
|
|||
err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyNameOneHundredAndFiveMbAzure,
|
||||
Key: testContext.currentTest.keyNameOneHundredAndFiveMbAzure,
|
||||
Body: oneHundredAndFiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload(params, (err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload: ' +
|
||||
`Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
afterEach(function afterEachF(done) {
|
||||
afterEach(done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
s3.abortMultipartUpload(params, done);
|
||||
});
|
||||
|
||||
it('should copy 105 MB part from Azure to MPU with Azure ' +
|
||||
'location', function ifF(done) {
|
||||
test('should copy 105 MB part from Azure to MPU with Azure ' +
|
||||
'location', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${azureContainerName}/` +
|
||||
`${this.test.keyNameOneHundredAndFiveMbAzure}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${testContext.test.keyNameOneHundredAndFiveMbAzure}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag,
|
||||
`"${oneHundredAndFiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${oneHundredAndFiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
azureContainerName,
|
||||
mpuKeyNameAzure:
|
||||
this.test.mpuKeyNameAzure,
|
||||
uploadId: this.test.uploadId,
|
||||
testContext.test.mpuKeyNameAzure,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: oneHundredAndFiveMbMD5,
|
||||
subPartSize: [100 * 1024 * 1024, 5 * 1024 * 1024],
|
||||
};
|
||||
|
@ -709,15 +690,21 @@ function describeF() {
|
|||
});
|
||||
describe('Basic test with complete MPU from AWS to Azure location: ',
|
||||
() => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.keyNameAws =
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.keyNameAws =
|
||||
`onehundredandfivembazure${uniqName(keyObjectAWS)}`;
|
||||
this.currentTest.mpuKeyNameAzure =
|
||||
testContext.currentTest.mpuKeyNameAzure =
|
||||
`mpukeyname${uniqName(keyObjectAzure)}`;
|
||||
|
||||
const createMpuParams = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.mpuKeyNameAzure,
|
||||
Key: testContext.currentTest.mpuKeyNameAzure,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -727,57 +714,54 @@ function describeF() {
|
|||
err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: awsBucketName,
|
||||
Key: this.currentTest.keyNameAws,
|
||||
Key: testContext.currentTest.keyNameAws,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload(createMpuParams,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload: ' +
|
||||
`Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy two 5 MB part from Azure to MPU with Azure ' +
|
||||
'location', function ifF(done) {
|
||||
test('should copy two 5 MB part from Azure to MPU with Azure ' +
|
||||
'location', done => {
|
||||
const uploadParams = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${awsBucketName}/` +
|
||||
`${this.test.keyNameAws}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${testContext.test.keyNameAws}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
const uploadParams2 = {
|
||||
Bucket: azureContainerName,
|
||||
CopySource:
|
||||
`${awsBucketName}/` +
|
||||
`${this.test.keyNameAws}`,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
`${testContext.test.keyNameAws}`,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
PartNumber: 2,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(uploadParams, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.uploadPartCopy(uploadParams2, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const completeMpuParams = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.mpuKeyNameAzure,
|
||||
Key: testContext.test.mpuKeyNameAzure,
|
||||
MultipartUpload: {
|
||||
Parts: [
|
||||
{
|
||||
|
@ -790,15 +774,13 @@ function describeF() {
|
|||
},
|
||||
],
|
||||
},
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
s3.completeMultipartUpload(completeMpuParams,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'completeMultipartUpload:' +
|
||||
` Expected success, got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, azureContainerName);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameAzure);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Bucket).toBe(azureContainerName);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameAzure);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -81,7 +81,7 @@ function assertCopyPart(infos, cb) {
|
|||
}, (err, res) => {
|
||||
assert.ifError(err, 'GCP listParts: Expected success,' +
|
||||
`got error: ${err}`);
|
||||
assert.strictEqual(res.Contents[0].ETag, `"${md5}"`);
|
||||
expect(res.Contents[0].ETag).toBe(`"${md5}"`);
|
||||
next();
|
||||
}),
|
||||
], cb);
|
||||
|
@ -119,36 +119,42 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
});
|
||||
|
||||
describe('Basic test: ', () => {
|
||||
beforeEach(function beforeFn(done) {
|
||||
this.currentTest.keyNameNormalGcp =
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.keyNameNormalGcp =
|
||||
`normalgcp${uniqName(keyObjectGcp)}`;
|
||||
this.currentTest.keyNameNormalGcpMismatch =
|
||||
testContext.currentTest.keyNameNormalGcpMismatch =
|
||||
`normalgcpmismatch${uniqName(keyObjectGcp)}`;
|
||||
|
||||
this.currentTest.keyNameFiveMbGcp =
|
||||
testContext.currentTest.keyNameFiveMbGcp =
|
||||
`fivembgcp${uniqName(keyObjectGcp)}`;
|
||||
this.currentTest.keyNameFiveMbMem =
|
||||
testContext.currentTest.keyNameFiveMbMem =
|
||||
`fivembmem${uniqName(keyObjectMemory)}`;
|
||||
|
||||
this.currentTest.mpuKeyNameGcp =
|
||||
testContext.currentTest.mpuKeyNameGcp =
|
||||
`mpukeyname${uniqName(keyObjectGcp)}`;
|
||||
this.currentTest.mpuKeyNameMem =
|
||||
testContext.currentTest.mpuKeyNameMem =
|
||||
`mpukeyname${uniqName(keyObjectMemory)}`;
|
||||
this.currentTest.mpuKeyNameAWS =
|
||||
testContext.currentTest.mpuKeyNameAWS =
|
||||
`mpukeyname${uniqName(keyObjectAWS)}`;
|
||||
const paramsGcp = {
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.mpuKeyNameGcp,
|
||||
Key: testContext.currentTest.mpuKeyNameGcp,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
};
|
||||
const paramsMem = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameMem,
|
||||
Key: testContext.currentTest.mpuKeyNameMem,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
const paramsAWS = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameAWS,
|
||||
Key: testContext.currentTest.mpuKeyNameAWS,
|
||||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -158,26 +164,26 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.keyNameNormalGcp,
|
||||
Key: testContext.currentTest.keyNameNormalGcp,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.keyNameNormalGcpMismatch,
|
||||
Key: testContext.currentTest.keyNameNormalGcpMismatch,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
gcpLocationMismatch },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.keyNameFiveMbGcp,
|
||||
Key: testContext.currentTest.keyNameFiveMbGcp,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.keyNameFiveMbMem,
|
||||
Key: testContext.currentTest.keyNameFiveMbMem,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
}, err => next(err)),
|
||||
|
@ -185,41 +191,41 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
(err, res) => {
|
||||
assert.ifError(err, 'createMultipartUpload ' +
|
||||
`on gcp: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(paramsMem,
|
||||
(err, res) => {
|
||||
assert.ifError(err, 'createMultipartUpload ' +
|
||||
`in memory: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadIdMem = res.UploadId;
|
||||
testContext.currentTest.uploadIdMem = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(paramsAWS,
|
||||
(err, res) => {
|
||||
assert.ifError(err, 'createMultipartUpload ' +
|
||||
`on AWS: Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadIdAWS = res.UploadId;
|
||||
testContext.currentTest.uploadIdAWS = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
afterEach(function afterFn(done) {
|
||||
afterEach(done => {
|
||||
const paramsGcp = {
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.mpuKeyNameGcp,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.mpuKeyNameGcp,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
const paramsMem = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameMem,
|
||||
UploadId: this.currentTest.uploadIdMem,
|
||||
Key: testContext.currentTest.mpuKeyNameMem,
|
||||
UploadId: testContext.currentTest.uploadIdMem,
|
||||
};
|
||||
const paramsAWS = {
|
||||
Bucket: memBucketName,
|
||||
Key: this.currentTest.mpuKeyNameAWS,
|
||||
UploadId: this.currentTest.uploadIdAWS,
|
||||
Key: testContext.currentTest.mpuKeyNameAWS,
|
||||
UploadId: testContext.currentTest.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.abortMultipartUpload(paramsGcp,
|
||||
|
@ -231,28 +237,60 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should copy small part from GCP to MPU with GCP location',
|
||||
function itFn(done) {
|
||||
test(
|
||||
'should copy small part from GCP to MPU with GCP location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${testContext.test.keyNameNormalGcp}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: testContext.test.mpuKeyNameGcp,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: normalMD5,
|
||||
totalSize: normalBodySize,
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
test('should copy small part from GCP with bucketMatch=false to ' +
|
||||
'MPU with GCP location', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcp}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
`${bucket}/${testContext.test.keyNameNormalGcpMismatch}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: this.test.mpuKeyNameGcp,
|
||||
uploadId: this.test.uploadId,
|
||||
keyName: testContext.test.mpuKeyNameGcp,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: normalMD5,
|
||||
totalSize: normalBodySize,
|
||||
};
|
||||
|
@ -261,125 +299,97 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should copy small part from GCP with bucketMatch=false to ' +
|
||||
'MPU with GCP location',
|
||||
function itFn(done) {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcpMismatch}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: this.test.mpuKeyNameGcp,
|
||||
uploadId: this.test.uploadId,
|
||||
md5: normalMD5,
|
||||
totalSize: normalBodySize,
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should copy 5 Mb part from GCP to MPU with GCP location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${testContext.test.keyNameFiveMbGcp}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: testContext.test.mpuKeyNameGcp,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
totalSize: fiveMB,
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('should copy 5 Mb part from GCP to MPU with GCP location',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameFiveMbGcp}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: this.test.mpuKeyNameGcp,
|
||||
uploadId: this.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
totalSize: fiveMB,
|
||||
};
|
||||
assertCopyPart(infos, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'should copy part from GCP to MPU with memory location',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${bucket}/${testContext.test.keyNameNormalGcp}`,
|
||||
Key: testContext.test.mpuKeyNameMem,
|
||||
PartNumber: 1,
|
||||
UploadId: testContext.test.uploadIdMem,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
s3.listParts({
|
||||
Bucket: memBucketName,
|
||||
Key: testContext.test.mpuKeyNameMem,
|
||||
UploadId: testContext.test.uploadIdMem,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
const resultCopy =
|
||||
JSON.parse(JSON.stringify(result));
|
||||
resultCopy.Bucket = memBucketName;
|
||||
resultCopy.Key = testContext.test.mpuKeyNameMem;
|
||||
resultCopy.UploadId = testContext.test.uploadIdMem;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
ETag: `"${normalMD5}"`,
|
||||
Size: normalBodySize }];
|
||||
assert.deepStrictEqual(res, resultCopy);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('should copy part from GCP to MPU with memory location',
|
||||
function ifF(done) {
|
||||
test('should copy part from GCP to MPU with AWS location', done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcp}`,
|
||||
Key: this.test.mpuKeyNameMem,
|
||||
`${bucket}/${testContext.test.keyNameNormalGcp}`,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdMem,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
s3.listParts({
|
||||
Bucket: memBucketName,
|
||||
Key: this.test.mpuKeyNameMem,
|
||||
UploadId: this.test.uploadIdMem,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
const resultCopy =
|
||||
JSON.parse(JSON.stringify(result));
|
||||
resultCopy.Bucket = memBucketName;
|
||||
resultCopy.Key = this.test.mpuKeyNameMem;
|
||||
resultCopy.UploadId = this.test.uploadIdMem;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
ETag: `"${normalMD5}"`,
|
||||
Size: normalBodySize }];
|
||||
assert.deepStrictEqual(res, resultCopy);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy part from GCP to MPU with AWS location',
|
||||
function ifF(done) {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcp}`,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
|
@ -388,45 +398,41 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
.details.bucketName;
|
||||
awsS3.listParts({
|
||||
Bucket: awsBucket,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, awsBucket);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameAWS);
|
||||
assert.strictEqual(res.UploadId,
|
||||
this.test.uploadIdAWS);
|
||||
assert.strictEqual(res.Parts.length, 1);
|
||||
assert.strictEqual(res.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(res.Parts[0].ETag,
|
||||
`"${normalMD5}"`);
|
||||
assert.strictEqual(res.Parts[0].Size,
|
||||
normalBodySize);
|
||||
expect(res.Bucket).toBe(awsBucket);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameAWS);
|
||||
expect(res.UploadId).toBe(testContext.test.uploadIdAWS);
|
||||
expect(res.Parts.length).toBe(1);
|
||||
expect(res.Parts[0].PartNumber).toBe(1);
|
||||
expect(res.Parts[0].ETag).toBe(`"${normalMD5}"`);
|
||||
expect(res.Parts[0].Size).toBe(normalBodySize);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy part from GCP object with range to MPU ' +
|
||||
'with AWS location', function ifF(done) {
|
||||
test('should copy part from GCP object with range to MPU ' +
|
||||
'with AWS location', done => {
|
||||
const params = {
|
||||
Bucket: memBucketName,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcp}`,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
`${bucket}/${testContext.test.keyNameNormalGcp}`,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
CopySourceRange: 'bytes=0-5',
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${sixBytesMD5}"`);
|
||||
expect(res.ETag).toBe(`"${sixBytesMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
|
@ -435,51 +441,47 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
.details.bucketName;
|
||||
awsS3.listParts({
|
||||
Bucket: awsBucket,
|
||||
Key: this.test.mpuKeyNameAWS,
|
||||
UploadId: this.test.uploadIdAWS,
|
||||
Key: testContext.test.mpuKeyNameAWS,
|
||||
UploadId: testContext.test.uploadIdAWS,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err,
|
||||
'listParts: Expected success,' +
|
||||
` got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, awsBucket);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameAWS);
|
||||
assert.strictEqual(res.UploadId,
|
||||
this.test.uploadIdAWS);
|
||||
assert.strictEqual(res.Parts.length, 1);
|
||||
assert.strictEqual(res.Parts[0].PartNumber, 1);
|
||||
assert.strictEqual(res.Parts[0].ETag,
|
||||
`"${sixBytesMD5}"`);
|
||||
assert.strictEqual(res.Parts[0].Size, 6);
|
||||
expect(res.Bucket).toBe(awsBucket);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameAWS);
|
||||
expect(res.UploadId).toBe(testContext.test.uploadIdAWS);
|
||||
expect(res.Parts.length).toBe(1);
|
||||
expect(res.Parts[0].PartNumber).toBe(1);
|
||||
expect(res.Parts[0].ETag).toBe(`"${sixBytesMD5}"`);
|
||||
expect(res.Parts[0].Size).toBe(6);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy 5 Mb part from a memory location to MPU with ' +
|
||||
'GCP location',
|
||||
function ifF(done) {
|
||||
test('should copy 5 Mb part from a memory location to MPU with ' +
|
||||
'GCP location', done => {
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameFiveMbMem}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
`${bucket}/${testContext.test.keyNameFiveMbMem}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const infos = {
|
||||
bucketName: bucket,
|
||||
keyName: this.test.mpuKeyNameGcp,
|
||||
uploadId: this.test.uploadId,
|
||||
keyName: testContext.test.mpuKeyNameGcp,
|
||||
uploadId: testContext.test.uploadId,
|
||||
md5: fiveMbMD5,
|
||||
totalSize: fiveMB,
|
||||
};
|
||||
|
@ -489,45 +491,45 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
});
|
||||
|
||||
describe('with existing part', () => {
|
||||
beforeEach(function beF(done) {
|
||||
beforeEach(done => {
|
||||
const params = {
|
||||
Body: oneKbBody,
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.mpuKeyNameGcp,
|
||||
Key: testContext.currentTest.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
};
|
||||
s3.uploadPart(params, done);
|
||||
});
|
||||
it('should copy part from GCP to GCP with existing ' +
|
||||
'parts', function ifF(done) {
|
||||
test('should copy part from GCP to GCP with existing ' +
|
||||
'parts', done => {
|
||||
const resultCopy = JSON.parse(JSON.stringify(result));
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${bucket}/${this.test.keyNameNormalGcp}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
`${bucket}/${testContext.test.keyNameNormalGcp}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 2,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(params, (err, res) => {
|
||||
assert.ifError(err,
|
||||
'uploadPartCopy: Expected success, got ' +
|
||||
`error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${normalMD5}"`);
|
||||
expect(res.ETag).toBe(`"${normalMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.listParts({
|
||||
Bucket: bucket,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
UploadId: testContext.test.uploadId,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err, 'listParts: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
resultCopy.Bucket = bucket;
|
||||
resultCopy.Key = this.test.mpuKeyNameGcp;
|
||||
resultCopy.UploadId = this.test.uploadId;
|
||||
resultCopy.Key = testContext.test.mpuKeyNameGcp;
|
||||
resultCopy.UploadId = testContext.test.uploadId;
|
||||
resultCopy.Parts =
|
||||
[{ PartNumber: 1,
|
||||
LastModified: res.Parts[0].LastModified,
|
||||
|
@ -543,15 +545,13 @@ describeSkipIfNotMultipleOrCeph('Put Copy Part to GCP', function describeFn() {
|
|||
}),
|
||||
next => gcpClient.listParts({
|
||||
Bucket: gcpBucketMPU,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
UploadId: this.test.uploadId,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
UploadId: testContext.test.uploadId,
|
||||
}, (err, res) => {
|
||||
assert.ifError(err, 'GCP listParts: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(
|
||||
res.Contents[0].ETag, `"${oneKbMD5}"`);
|
||||
assert.strictEqual(
|
||||
res.Contents[1].ETag, `"${normalMD5}"`);
|
||||
expect(res.Contents[0].ETag).toBe(`"${oneKbMD5}"`);
|
||||
expect(res.Contents[1].ETag).toBe(`"${normalMD5}"`);
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
|
@ -592,15 +592,21 @@ function describeF() {
|
|||
});
|
||||
describe('Basic test with complete MPU from AWS to GCP location: ',
|
||||
() => {
|
||||
beforeEach(function beF(done) {
|
||||
this.currentTest.keyNameAws =
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done => {
|
||||
testContext.currentTest.keyNameAws =
|
||||
`onehundredandfivembgcp${uniqName(keyObjectAWS)}`;
|
||||
this.currentTest.mpuKeyNameGcp =
|
||||
testContext.currentTest.mpuKeyNameGcp =
|
||||
`mpukeyname${uniqName(keyObjectGcp)}`;
|
||||
|
||||
const createMpuParams = {
|
||||
Bucket: bucket,
|
||||
Key: this.currentTest.mpuKeyNameGcp,
|
||||
Key: testContext.currentTest.mpuKeyNameGcp,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -610,57 +616,54 @@ function describeF() {
|
|||
err => next(err)),
|
||||
next => s3.putObject({
|
||||
Bucket: awsBucketName,
|
||||
Key: this.currentTest.keyNameAws,
|
||||
Key: testContext.currentTest.keyNameAws,
|
||||
Body: fiveMbBody,
|
||||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
}, err => next(err)),
|
||||
next => s3.createMultipartUpload(createMpuParams,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'createMultipartUpload: ' +
|
||||
`Expected success, got error: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should copy two 5 MB part from GCP to MPU with GCP' +
|
||||
'location', function ifF(done) {
|
||||
test('should copy two 5 MB part from GCP to MPU with GCP' +
|
||||
'location', done => {
|
||||
const uploadParams = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${awsBucketName}/` +
|
||||
`${this.test.keyNameAws}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
`${testContext.test.keyNameAws}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 1,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
const uploadParams2 = {
|
||||
Bucket: bucket,
|
||||
CopySource:
|
||||
`${awsBucketName}/` +
|
||||
`${this.test.keyNameAws}`,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
`${testContext.test.keyNameAws}`,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
PartNumber: 2,
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.uploadPartCopy(uploadParams, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => s3.uploadPartCopy(uploadParams2, (err, res) => {
|
||||
assert.equal(err, null, 'uploadPartCopy: Expected ' +
|
||||
`success, got error: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${fiveMbMD5}"`);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.ETag).toBe(`"${fiveMbMD5}"`);
|
||||
next(err);
|
||||
}),
|
||||
next => {
|
||||
const completeMpuParams = {
|
||||
Bucket: bucket,
|
||||
Key: this.test.mpuKeyNameGcp,
|
||||
Key: testContext.test.mpuKeyNameGcp,
|
||||
MultipartUpload: {
|
||||
Parts: [
|
||||
{
|
||||
|
@ -673,15 +676,13 @@ function describeF() {
|
|||
},
|
||||
],
|
||||
},
|
||||
UploadId: this.test.uploadId,
|
||||
UploadId: testContext.test.uploadId,
|
||||
};
|
||||
s3.completeMultipartUpload(completeMpuParams,
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'completeMultipartUpload:' +
|
||||
` Expected success, got error: ${err}`);
|
||||
assert.strictEqual(res.Bucket, bucket);
|
||||
assert.strictEqual(res.Key,
|
||||
this.test.mpuKeyNameGcp);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Bucket).toBe(bucket);
|
||||
expect(res.Key).toBe(testContext.test.mpuKeyNameGcp);
|
||||
next();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -44,15 +44,11 @@ const tagObj = { key1: 'value1', key2: 'value2' };
|
|||
|
||||
function getAndAssertObjectTags(tagParams, callback) {
|
||||
return s3.getObjectTagging(tagParams, (err, res) => {
|
||||
assert.strictEqual(res.TagSet.length, 2);
|
||||
assert.strictEqual(res.TagSet[0].Key,
|
||||
putTags.TagSet[0].Key);
|
||||
assert.strictEqual(res.TagSet[0].Value,
|
||||
putTags.TagSet[0].Value);
|
||||
assert.strictEqual(res.TagSet[1].Key,
|
||||
putTags.TagSet[1].Key);
|
||||
assert.strictEqual(res.TagSet[1].Value,
|
||||
putTags.TagSet[1].Value);
|
||||
expect(res.TagSet.length).toBe(2);
|
||||
expect(res.TagSet[0].Key).toBe(putTags.TagSet[0].Key);
|
||||
expect(res.TagSet[0].Value).toBe(putTags.TagSet[0].Value);
|
||||
expect(res.TagSet[1].Key).toBe(putTags.TagSet[1].Key);
|
||||
expect(res.TagSet[1].Value).toBe(putTags.TagSet[1].Value);
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
|
@ -61,18 +57,18 @@ function getAndAssertObjectTags(tagParams, callback) {
|
|||
function awsGet(key, tagCheck, isEmpty, isMpu, callback) {
|
||||
process.stdout.write('Getting object from AWS\n');
|
||||
getAwsRetry({ key }, 0, (err, res) => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
if (isEmpty) {
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else if (isMpu) {
|
||||
assert.strictEqual(res.ETag, `"${mpuMD5}"`);
|
||||
expect(res.ETag).toBe(`"${mpuMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
}
|
||||
if (tagCheck) {
|
||||
assert.strictEqual(res.TagCount, '2');
|
||||
expect(res.TagCount).toBe('2');
|
||||
} else {
|
||||
assert.strictEqual(res.TagCount, undefined);
|
||||
expect(res.TagCount).toBe(undefined);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
|
@ -82,18 +78,17 @@ function azureGet(key, tagCheck, isEmpty, callback) {
|
|||
process.stdout.write('Getting object from Azure\n');
|
||||
azureClient.getBlobProperties(azureContainerName, key,
|
||||
(err, res) => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const resMD5 = convertMD5(res.contentSettings.contentMD5);
|
||||
if (isEmpty) {
|
||||
assert.strictEqual(resMD5, `${emptyMD5}`);
|
||||
expect(resMD5).toBe(`${emptyMD5}`);
|
||||
} else {
|
||||
assert.strictEqual(resMD5, `${correctMD5}`);
|
||||
expect(resMD5).toBe(`${correctMD5}`);
|
||||
}
|
||||
if (tagCheck) {
|
||||
assert.strictEqual(res.metadata.tags,
|
||||
JSON.stringify(tagObj));
|
||||
expect(res.metadata.tags).toBe(JSON.stringify(tagObj));
|
||||
} else {
|
||||
assert.strictEqual(res.metadata.tags, undefined);
|
||||
expect(res.metadata.tags).toBe(undefined);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
|
@ -103,20 +98,19 @@ function getObject(key, backend, tagCheck, isEmpty, isMpu, callback) {
|
|||
function get(cb) {
|
||||
process.stdout.write('Getting object\n');
|
||||
s3.getObject({ Bucket: bucket, Key: key }, (err, res) => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
if (isEmpty) {
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
} else if (isMpu) {
|
||||
assert.strictEqual(res.ETag, `"${mpuMD5}"`);
|
||||
expect(res.ETag).toBe(`"${mpuMD5}"`);
|
||||
} else {
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
}
|
||||
assert.strictEqual(res.Metadata['scal-location-constraint'],
|
||||
backend);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(backend);
|
||||
if (tagCheck) {
|
||||
assert.strictEqual(res.TagCount, '2');
|
||||
expect(res.TagCount).toBe('2');
|
||||
} else {
|
||||
assert.strictEqual(res.TagCount, undefined);
|
||||
expect(res.TagCount).toBe(undefined);
|
||||
}
|
||||
return cb();
|
||||
});
|
||||
|
@ -135,14 +129,14 @@ function getObject(key, backend, tagCheck, isEmpty, isMpu, callback) {
|
|||
function mpuWaterfall(params, cb) {
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, data) => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
next(null, data.UploadId);
|
||||
}),
|
||||
(uploadId, next) => {
|
||||
const partParams = { Bucket: bucket, Key: params.Key, PartNumber: 1,
|
||||
UploadId: uploadId, Body: body };
|
||||
s3.uploadPart(partParams, (err, result) => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
next(null, uploadId, result.ETag);
|
||||
});
|
||||
},
|
||||
|
@ -153,12 +147,12 @@ function mpuWaterfall(params, cb) {
|
|||
},
|
||||
UploadId: uploadId };
|
||||
s3.completeMultipartUpload(compParams, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
next();
|
||||
});
|
||||
},
|
||||
], err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -197,21 +191,19 @@ function testSuite() {
|
|||
testBackends.forEach(backend => {
|
||||
const itSkipIfAzureOrCeph = backend === 'azurebackend' ||
|
||||
isCEPH ? it.skip : it;
|
||||
it(`should put an object with tags to ${backend} backend`,
|
||||
done => {
|
||||
test(`should put an object with tags to ${backend} backend`, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Tagging: tagString,
|
||||
Metadata: { 'scal-location-constraint': backend } },
|
||||
putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, true, false, false, done);
|
||||
});
|
||||
});
|
||||
|
||||
it(`should put a 0 byte object with tags to ${backend} backend`,
|
||||
done => {
|
||||
test(`should put a 0 byte object with tags to ${backend} backend`, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = {
|
||||
Bucket: bucket,
|
||||
|
@ -221,30 +213,30 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, true, true, false, done);
|
||||
});
|
||||
});
|
||||
|
||||
it(`should put tags to preexisting object in ${backend} ` +
|
||||
test(`should put tags to preexisting object in ${backend} ` +
|
||||
'backend', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Metadata:
|
||||
{ 'scal-location-constraint': backend } }, putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const putTagParams = { Bucket: bucket, Key: key,
|
||||
Tagging: putTags };
|
||||
process.stdout.write('Putting object tags\n');
|
||||
s3.putObjectTagging(putTagParams, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, true, false, false, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put tags to preexisting 0 byte object in ' +
|
||||
test('should put tags to preexisting 0 byte object in ' +
|
||||
`${backend} backend`, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = {
|
||||
|
@ -254,12 +246,12 @@ function testSuite() {
|
|||
};
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const putTagParams = { Bucket: bucket, Key: key,
|
||||
Tagging: putTags };
|
||||
process.stdout.write('Putting object tags\n');
|
||||
s3.putObjectTagging(putTagParams, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, true, true, false, done);
|
||||
});
|
||||
});
|
||||
|
@ -278,31 +270,30 @@ function testSuite() {
|
|||
Tagging: putTags };
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObjectTagging(putTagParams, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, true, false, true, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return error putting tags to correct object ' +
|
||||
test('should not return error putting tags to correct object ' +
|
||||
'version in AWS, even if a delete marker was created directly ' +
|
||||
'on AWS before tags are put',
|
||||
done => {
|
||||
'on AWS before tags are put', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Metadata:
|
||||
{ 'scal-location-constraint': awsLocation } }, putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Deleting object from AWS\n');
|
||||
awsS3.deleteObject({ Bucket: awsBucket, Key: key }, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const putTagParams = { Bucket: bucket, Key: key,
|
||||
Tagging: putTags };
|
||||
process.stdout.write('Putting object tags\n');
|
||||
s3.putObjectTagging(putTagParams, err => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -312,22 +303,21 @@ function testSuite() {
|
|||
|
||||
describe('getObjectTagging', () => {
|
||||
testBackends.forEach(backend => {
|
||||
it(`should get tags from object on ${backend} backend`,
|
||||
done => {
|
||||
test(`should get tags from object on ${backend} backend`, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Tagging: tagString,
|
||||
Metadata: { 'scal-location-constraint': backend } },
|
||||
putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const tagParams = { Bucket: bucket, Key: key };
|
||||
getAndAssertObjectTags(tagParams, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return error on getting tags from object that has ' +
|
||||
test('should not return error on getting tags from object that has ' +
|
||||
'had a delete marker put directly on AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Tagging: tagString,
|
||||
|
@ -335,10 +325,10 @@ function testSuite() {
|
|||
putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Deleting object from AWS\n');
|
||||
awsS3.deleteObject({ Bucket: awsBucket, Key: key }, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const tagParams = { Bucket: bucket, Key: key };
|
||||
getAndAssertObjectTags(tagParams, done);
|
||||
});
|
||||
|
@ -348,25 +338,24 @@ function testSuite() {
|
|||
|
||||
describe('deleteObjectTagging', () => {
|
||||
testBackends.forEach(backend => {
|
||||
it(`should delete tags from object on ${backend} backend`,
|
||||
done => {
|
||||
test(`should delete tags from object on ${backend} backend`, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Tagging: tagString,
|
||||
Metadata: { 'scal-location-constraint': backend } },
|
||||
putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const tagParams = { Bucket: bucket, Key: key };
|
||||
s3.deleteObjectTagging(tagParams, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
getObject(key, backend, false, false, false, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return error on deleting tags from object that ' +
|
||||
test('should not return error on deleting tags from object that ' +
|
||||
'has had delete markers put directly on AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = Object.assign({ Key: key, Tagging: tagString,
|
||||
|
@ -374,13 +363,13 @@ function testSuite() {
|
|||
putParams);
|
||||
process.stdout.write('Putting object\n');
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Deleting object from AWS\n');
|
||||
awsS3.deleteObject({ Bucket: awsBucket, Key: key }, err => {
|
||||
assert.equal(err, null);
|
||||
expect(err).toEqual(null);
|
||||
const tagParams = { Bucket: bucket, Key: key };
|
||||
s3.deleteObjectTagging(tagParams, err => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: should delete a tag set on the ' +
|
||||
test('versioning not configured: should delete a tag set on the ' +
|
||||
'latest version if no version is specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -56,7 +56,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning not configured: should delete a tag set on the ' +
|
||||
test('versioning not configured: should delete a tag set on the ' +
|
||||
'version if specified (null)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -69,7 +69,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should delete a tag set on the latest ' +
|
||||
test('versioning suspended: should delete a tag set on the latest ' +
|
||||
'version if no version is specified', done => {
|
||||
const data = [undefined, 'test1', 'test2'];
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
|
@ -83,7 +83,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should delete a tag set on a specific ' +
|
||||
test('versioning suspended: should delete a tag set on a specific ' +
|
||||
'version (null)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -98,7 +98,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled then suspended: should delete a tag set on ' +
|
||||
test('versioning enabled then suspended: should delete a tag set on ' +
|
||||
'a specific (non-null) version if specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -119,7 +119,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should delete a tag set on the latest ' +
|
||||
test('versioning enabled: should delete a tag set on the latest ' +
|
||||
'version if no version is specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -133,22 +133,24 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should delete a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => delTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedVersionId: versionId }, next),
|
||||
next => awsGetAssertTags({ key, expectedTags: {} }, next),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'versioning enabled: should delete a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => delTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedVersionId: versionId }, next),
|
||||
next => awsGetAssertTags({ key, expectedTags: {} }, next),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('versioning enabled: should delete a tag set on a specific ' +
|
||||
test('versioning enabled: should delete a tag set on a specific ' +
|
||||
'version that is not the latest version', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -171,7 +173,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended then enabled: should delete a tag set on ' +
|
||||
test('versioning suspended then enabled: should delete a tag set on ' +
|
||||
'a specific version (null) if specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -191,9 +193,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return an ServiceUnavailable if trying to delete ' +
|
||||
'tags from object that was deleted from AWS directly',
|
||||
done => {
|
||||
test('should return an ServiceUnavailable if trying to delete ' +
|
||||
'tags from object that was deleted from AWS directly', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
|
@ -205,9 +206,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return an ServiceUnavailable if trying to delete ' +
|
||||
'tags from object that was deleted from AWS directly',
|
||||
done => {
|
||||
test('should return an ServiceUnavailable if trying to delete ' +
|
||||
'tags from object that was deleted from AWS directly', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
|
|
|
@ -45,7 +45,7 @@ function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('versioning not configured: should put/get a tag set on the ' +
|
||||
test('versioning not configured: should put/get a tag set on the ' +
|
||||
'latest version if no version is specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -59,7 +59,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning not configured: should put/get a tag set on a ' +
|
||||
test('versioning not configured: should put/get a tag set on a ' +
|
||||
'specific version if specified (null)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -74,7 +74,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should put/get a tag set on the latest ' +
|
||||
test('versioning suspended: should put/get a tag set on the latest ' +
|
||||
'version if no version is specified', done => {
|
||||
const data = [undefined, 'test1', 'test2'];
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
|
@ -89,7 +89,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning suspended: should put/get a tag set on a specific ' +
|
||||
test('versioning suspended: should put/get a tag set on a specific ' +
|
||||
'version (null)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -105,7 +105,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled then suspended: should put/get a tag set on ' +
|
||||
test('versioning enabled then suspended: should put/get a tag set on ' +
|
||||
'a specific (non-null) version if specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -126,7 +126,7 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should put/get a tag set on the latest ' +
|
||||
test('versioning enabled: should put/get a tag set on the latest ' +
|
||||
'version if no version is specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -141,39 +141,43 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('versioning enabled: should put/get a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => getTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedTags: tags,
|
||||
expectedVersionId: versionId }, next),
|
||||
(versionId, next) => awsGetAssertTags({ key,
|
||||
expectedTags: tags }, next),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'versioning enabled: should put/get a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => getTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedTags: tags,
|
||||
expectedVersionId: versionId }, next),
|
||||
(versionId, next) => awsGetAssertTags({ key,
|
||||
expectedTags: tags }, next),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('versioning enabled: should put/get a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => delTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedVersionId: versionId }, next),
|
||||
next => awsGetAssertTags({ key, expectedTags: {} }, next),
|
||||
], done);
|
||||
});
|
||||
test(
|
||||
'versioning enabled: should put/get a tag set on a specific version',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
(putData, next) => putTaggingAndAssert(s3, { bucket, key, tags,
|
||||
versionId: putData.VersionId,
|
||||
expectedVersionId: putData.VersionId }, next),
|
||||
(versionId, next) => delTaggingAndAssert(s3, { bucket, key,
|
||||
versionId, expectedVersionId: versionId }, next),
|
||||
next => awsGetAssertTags({ key, expectedTags: {} }, next),
|
||||
], done);
|
||||
}
|
||||
);
|
||||
|
||||
it('versioning enabled: should put/get a tag set on a specific ' +
|
||||
test('versioning enabled: should put/get a tag set on a specific ' +
|
||||
'version that is not the latest version', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -197,7 +201,7 @@ function testSuite() {
|
|||
});
|
||||
|
||||
|
||||
it('versioning suspended then enabled: should put/get a tag set on ' +
|
||||
test('versioning suspended then enabled: should put/get a tag set on ' +
|
||||
'a specific version (null) if specified', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
|
@ -217,9 +221,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get tags for an object even if it was deleted from ' +
|
||||
'AWS directly (we rely on s3 metadata)',
|
||||
done => {
|
||||
test('should get tags for an object even if it was deleted from ' +
|
||||
'AWS directly (we rely on s3 metadata)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
|
@ -234,9 +237,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return an ServiceUnavailable if trying to put ' +
|
||||
'tags from object that was deleted from AWS directly',
|
||||
done => {
|
||||
test('should return an ServiceUnavailable if trying to put ' +
|
||||
'tags from object that was deleted from AWS directly', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
|
@ -248,9 +250,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should get tags for an version even if it was deleted from ' +
|
||||
'AWS directly (we rely on s3 metadata)',
|
||||
done => {
|
||||
test('should get tags for an version even if it was deleted from ' +
|
||||
'AWS directly (we rely on s3 metadata)', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => enableVersioning(s3, bucket, next),
|
||||
|
@ -268,9 +269,8 @@ function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return an ServiceUnavailable if trying to put ' +
|
||||
'tags on version that was deleted from AWS directly',
|
||||
done => {
|
||||
test('should return an ServiceUnavailable if trying to put ' +
|
||||
'tags on version that was deleted from AWS directly', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
async.waterfall([
|
||||
next => s3.putObject({ Bucket: bucket, Key: key }, next),
|
||||
|
|
|
@ -27,28 +27,24 @@ const retryTimeout = 10000;
|
|||
|
||||
function getAwsSuccess(key, awsMD5, location, cb) {
|
||||
return getAwsRetry({ key }, 0, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, got error ' +
|
||||
`on direct AWS call: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (location === awsLocationEncryption) {
|
||||
// doesn't check ETag because it's different
|
||||
// with every PUT with encryption
|
||||
assert.strictEqual(res.ServerSideEncryption, 'AES256');
|
||||
expect(res.ServerSideEncryption).toBe('AES256');
|
||||
}
|
||||
if (process.env.ENABLE_KMS_ENCRYPTION !== 'true') {
|
||||
assert.strictEqual(res.ETag, `"${awsMD5}"`);
|
||||
expect(res.ETag).toBe(`"${awsMD5}"`);
|
||||
}
|
||||
assert.strictEqual(res.Metadata['scal-location-constraint'],
|
||||
location);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(location);
|
||||
return cb(res);
|
||||
});
|
||||
}
|
||||
|
||||
function getAwsError(key, expectedError, cb) {
|
||||
return getAwsRetry({ key }, 0, err => {
|
||||
assert.notStrictEqual(err, undefined,
|
||||
'Expected error but did not find one');
|
||||
assert.strictEqual(err.code, expectedError,
|
||||
`Expected error code ${expectedError} but got ${err.code}`);
|
||||
expect(err).not.toBe(undefined);
|
||||
expect(err.code).toBe(expectedError);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -63,17 +59,15 @@ function awsGetCheck(objectKey, s3MD5, awsMD5, location, cb) {
|
|||
s3.getObject({ Bucket: bucket, Key: objectKey }, s3GetCallback);
|
||||
}, retryTimeout);
|
||||
}
|
||||
assert.strictEqual(err, null, 'Expected success, got error ' +
|
||||
`on call to AWS through S3: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${s3MD5}"`);
|
||||
assert.strictEqual(res.Metadata['scal-location-constraint'],
|
||||
location);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${s3MD5}"`);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(location);
|
||||
process.stdout.write('Getting object from AWS\n');
|
||||
return getAwsSuccess(objectKey, awsMD5, location, cb);
|
||||
});
|
||||
}
|
||||
|
||||
describe('MultipleBackend put object', function testSuite() {
|
||||
describe('MultipleBackend put object', () => {
|
||||
this.timeout(250000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(() => {
|
||||
|
@ -103,16 +97,17 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return an error to put request without a valid bucket name',
|
||||
test(
|
||||
'should return an error to put request without a valid bucket name',
|
||||
done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
s3.putObject({ Bucket: '', Key: key }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'MethodNotAllowed');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('MethodNotAllowed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
describeSkipIfNotMultiple('with set location from "x-amz-meta-scal-' +
|
||||
'location-constraint" header', function describe() {
|
||||
|
@ -120,117 +115,106 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
this.retries(2);
|
||||
}
|
||||
|
||||
it('should return an error to put request without a valid ' +
|
||||
test('should return an error to put request without a valid ' +
|
||||
'location constraint', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': 'fail-region' } };
|
||||
s3.putObject(params, err => {
|
||||
assert.notEqual(err, null, 'Expected failure but got ' +
|
||||
'success');
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to mem', done => {
|
||||
test('should put an object to mem', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: key }, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put a 0-byte object to mem', done => {
|
||||
test('should put a 0-byte object to mem', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Metadata: { 'scal-location-constraint': memLocation },
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${emptyMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${emptyMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put a 0-byte object to AWS', done => {
|
||||
test('should put a 0-byte object to AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Metadata: { 'scal-location-constraint': awsLocation },
|
||||
};
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, emptyMD5, emptyMD5, awsLocation,
|
||||
() => done());
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to file', done => {
|
||||
test('should put an object to file', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': fileLocation },
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: key }, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to AWS', done => {
|
||||
test('should put an object to AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, correctMD5, correctMD5, awsLocation,
|
||||
() => done());
|
||||
});
|
||||
});
|
||||
|
||||
it('should encrypt body only if bucket encrypted putting ' +
|
||||
'object to AWS',
|
||||
done => {
|
||||
test('should encrypt body only if bucket encrypted putting ' +
|
||||
'object to AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return getAwsSuccess(key, correctMD5, awsLocation,
|
||||
() => done());
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should put an object to AWS with encryption', done => {
|
||||
test('should put an object to AWS with encryption', done => {
|
||||
// Test refuses to skip using itSkipCeph so just mark it passed
|
||||
if (isCEPH) {
|
||||
return done();
|
||||
|
@ -241,14 +225,13 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
Metadata: { 'scal-location-constraint':
|
||||
awsLocationEncryption } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, correctMD5, correctMD5,
|
||||
awsLocationEncryption, () => done());
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a version id putting object to ' +
|
||||
test('should return a version id putting object to ' +
|
||||
'to AWS with versioning enabled', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body: body,
|
||||
|
@ -259,9 +242,8 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
VersioningConfiguration: versioningEnabled,
|
||||
}, err => next(err)),
|
||||
next => s3.putObject(params, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
assert(res.VersionId);
|
||||
expect(err).toBe(null);
|
||||
expect(res.VersionId).toBeTruthy();
|
||||
next(null, res.ETag);
|
||||
}),
|
||||
(eTag, next) => getAwsSuccess(key, correctMD5, awsLocation,
|
||||
|
@ -269,67 +251,59 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should put a large object to AWS', done => {
|
||||
test('should put a large object to AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: bigBody,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected sucess, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, bigS3MD5, bigAWSMD5, awsLocation,
|
||||
() => done());
|
||||
});
|
||||
});
|
||||
|
||||
it('should put objects with same key to AWS ' +
|
||||
test('should put objects with same key to AWS ' +
|
||||
'then file, and object should only be present in file', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': awsLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata =
|
||||
{ 'scal-location-constraint': fileLocation };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(
|
||||
res.Metadata['scal-location-constraint'],
|
||||
fileLocation);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(fileLocation);
|
||||
return getAwsError(key, 'NoSuchKey', done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put objects with same key to file ' +
|
||||
test('should put objects with same key to file ' +
|
||||
'then AWS, and object should only be present on AWS', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': fileLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata = {
|
||||
'scal-location-constraint': awsLocation };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, correctMD5, correctMD5,
|
||||
awsLocation, () => done());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put two objects to AWS with same ' +
|
||||
test('should put two objects to AWS with same ' +
|
||||
'key, and newest object should be returned', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
|
@ -337,17 +311,15 @@ describe('MultipleBackend put object', function testSuite() {
|
|||
Metadata: { 'scal-location-constraint': awsLocation,
|
||||
'unique-header': 'first object' } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata = { 'scal-location-constraint': awsLocation,
|
||||
'unique-header': 'second object' };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, correctMD5, correctMD5,
|
||||
awsLocation, result => {
|
||||
assert.strictEqual(result.Metadata
|
||||
['unique-header'], 'second object');
|
||||
expect(result.Metadata
|
||||
['unique-header']).toBe('second object');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -378,69 +350,63 @@ describeSkipIfNotMultiple('MultipleBackend put object based on bucket location',
|
|||
});
|
||||
});
|
||||
|
||||
it('should put an object to mem with no location header',
|
||||
done => {
|
||||
test('should put an object to mem with no location header', done => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
return s3.createBucket({ Bucket: bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: memLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Error creating bucket: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Putting object\n');
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body: body };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: key }, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to file with no location header', done => {
|
||||
test('should put an object to file with no location header', done => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
return s3.createBucket({ Bucket: bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: fileLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Error creating bucket: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Putting object\n');
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body: body };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
s3.getObject({ Bucket: bucket, Key: key }, (err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to AWS with no location header', done => {
|
||||
test('should put an object to AWS with no location header', done => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
return s3.createBucket({ Bucket: bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: awsLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Error creating bucket: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Putting object\n');
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body: body };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return awsGetCheck(key, correctMD5, correctMD5, undefined,
|
||||
() => done());
|
||||
});
|
||||
|
@ -451,11 +417,11 @@ describeSkipIfNotMultiple('MultipleBackend put object based on bucket location',
|
|||
|
||||
describe('MultipleBackend put based on request endpoint', () => {
|
||||
withV4(sigCfg => {
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
});
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucket)
|
||||
.then(() => {
|
||||
|
@ -468,18 +434,17 @@ describe('MultipleBackend put based on request endpoint', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should create bucket in corresponding backend', done => {
|
||||
test('should create bucket in corresponding backend', done => {
|
||||
process.stdout.write('Creating bucket');
|
||||
const request = s3.createBucket({ Bucket: bucket });
|
||||
request.on('build', () => {
|
||||
request.httpRequest.body = '';
|
||||
});
|
||||
request.send(err => {
|
||||
assert.strictEqual(err, null, `Error creating bucket: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: body }, err => {
|
||||
assert.strictEqual(err, null, 'Expected succes, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
const host = request.service.endpoint.hostname;
|
||||
let endpoint = config.restEndpoints[host];
|
||||
// s3 returns '' for us-east-1
|
||||
|
@ -487,14 +452,12 @@ describe('MultipleBackend put based on request endpoint', () => {
|
|||
endpoint = '';
|
||||
}
|
||||
s3.getBucketLocation({ Bucket: bucket }, (err, data) => {
|
||||
assert.strictEqual(err, null, 'Expected succes, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.strictEqual(data.LocationConstraint, endpoint);
|
||||
expect(err).toBe(null);
|
||||
expect(data.LocationConstraint).toBe(endpoint);
|
||||
s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected succes, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.strictEqual(res.ETag, `"${correctMD5}"`);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${correctMD5}"`);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -37,10 +37,9 @@ let s3;
|
|||
function azureGetCheck(objectKey, azureMD5, azureMetadata, cb) {
|
||||
azureClient.getBlobProperties(azureContainerName, objectKey,
|
||||
(err, res) => {
|
||||
assert.strictEqual(err, null, 'Expected success, got error ' +
|
||||
`on call to Azure: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const resMD5 = convertMD5(res.contentSettings.contentMD5);
|
||||
assert.strictEqual(resMD5, azureMD5);
|
||||
expect(resMD5).toBe(azureMD5);
|
||||
assert.deepStrictEqual(res.metadata, azureMetadata);
|
||||
return cb();
|
||||
});
|
||||
|
@ -50,7 +49,7 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend put object to AZURE', function
|
|||
describeF() {
|
||||
this.timeout(250000);
|
||||
withV4(sigCfg => {
|
||||
beforeEach(function beforeEachF() {
|
||||
beforeEach(() => {
|
||||
this.currentTest.keyName = uniqName(keyObject);
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
|
@ -69,6 +68,12 @@ describeF() {
|
|||
});
|
||||
});
|
||||
describe('with bucket location header', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(done =>
|
||||
s3.createBucket({ Bucket: azureContainerName,
|
||||
CreateBucketConfiguration: {
|
||||
|
@ -76,7 +81,7 @@ describeF() {
|
|||
},
|
||||
}, done));
|
||||
|
||||
it('should return a NotImplemented error if try to put ' +
|
||||
test('should return a NotImplemented error if try to put ' +
|
||||
'versioning to bucket with Azure location', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
|
@ -85,28 +90,34 @@ describeF() {
|
|||
},
|
||||
};
|
||||
s3.putBucketVersioning(params, err => {
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object to Azure, with no object location ' +
|
||||
'header, based on bucket location', function it(done) {
|
||||
test('should put an object to Azure, with no object location ' +
|
||||
'header, based on bucket location', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Body: normalBody,
|
||||
};
|
||||
async.waterfall([
|
||||
next => s3.putObject(params, err => setTimeout(() =>
|
||||
next(err), azureTimeout)),
|
||||
next => azureGetCheck(this.test.keyName, normalMD5, {},
|
||||
next => azureGetCheck(testContext.test.keyName, normalMD5, {},
|
||||
next),
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with no bucket location header', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
beforeEach(() =>
|
||||
s3.createBucketAsync({ Bucket: azureContainerName })
|
||||
.catch(err => {
|
||||
|
@ -115,51 +126,50 @@ describeF() {
|
|||
}));
|
||||
|
||||
keys.forEach(key => {
|
||||
it(`should put a ${key.describe} object to Azure`,
|
||||
function itF(done) {
|
||||
test(`should put a ${key.describe} object to Azure`, done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
Body: key.body,
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() =>
|
||||
azureGetCheck(this.test.keyName,
|
||||
azureGetCheck(testContext.test.keyName,
|
||||
key.MD5, azureMetadata,
|
||||
() => done()), azureTimeout);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put a object to Azure location with bucketMatch=false',
|
||||
function itF(done) {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocationMismatch },
|
||||
Body: normalBody,
|
||||
};
|
||||
const azureMetadataMismatch = {
|
||||
/* eslint-disable camelcase */
|
||||
scal_location_constraint: azureLocationMismatch,
|
||||
/* eslint-enable camelcase */
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
setTimeout(() =>
|
||||
azureGetCheck(
|
||||
`${azureContainerName}/${this.test.keyName}`,
|
||||
normalMD5, azureMetadataMismatch,
|
||||
() => done()), azureTimeout);
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should put a object to Azure location with bucketMatch=false',
|
||||
done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: testContext.test.keyName,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocationMismatch },
|
||||
Body: normalBody,
|
||||
};
|
||||
const azureMetadataMismatch = {
|
||||
/* eslint-disable camelcase */
|
||||
scal_location_constraint: azureLocationMismatch,
|
||||
/* eslint-enable camelcase */
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
expect(err).toEqual(null);
|
||||
setTimeout(() =>
|
||||
azureGetCheck(
|
||||
`${azureContainerName}/${testContext.test.keyName}`,
|
||||
normalMD5, azureMetadataMismatch,
|
||||
() => done()), azureTimeout);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return error ServiceUnavailable putting an invalid ' +
|
||||
test('should return error ServiceUnavailable putting an invalid ' +
|
||||
'key name to Azure', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
|
@ -168,36 +178,35 @@ describeF() {
|
|||
Body: normalBody,
|
||||
};
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error NotImplemented putting a ' +
|
||||
'version to Azure', function itF(done) {
|
||||
test('should return error NotImplemented putting a ' +
|
||||
'version to Azure', done => {
|
||||
s3.putBucketVersioning({
|
||||
Bucket: azureContainerName,
|
||||
VersioningConfiguration: versioningEnabled,
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
const params = { Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint':
|
||||
azureLocation } };
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put two objects to Azure with same ' +
|
||||
'key, and newest object should be returned', function itF(done) {
|
||||
test('should put two objects to Azure with same ' +
|
||||
'key, and newest object should be returned', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
};
|
||||
async.waterfall([
|
||||
|
@ -209,19 +218,18 @@ describeF() {
|
|||
},
|
||||
next => {
|
||||
setTimeout(() => {
|
||||
azureGetCheck(this.test.keyName, normalMD5,
|
||||
azureGetCheck(testContext.test.keyName, normalMD5,
|
||||
azureMetadata, next);
|
||||
}, azureTimeout);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put objects with same key to Azure ' +
|
||||
'then file, and object should only be present in file', function
|
||||
itF(done) {
|
||||
test('should put objects with same key to Azure ' +
|
||||
'then file, and object should only be present in file', done => {
|
||||
const params = {
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint': azureLocation } };
|
||||
async.waterfall([
|
||||
|
@ -234,28 +242,24 @@ describeF() {
|
|||
},
|
||||
next => s3.getObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(
|
||||
res.Metadata['scal-location-constraint'],
|
||||
fileLocation);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(fileLocation);
|
||||
next();
|
||||
}),
|
||||
next => azureClient.getBlobProperties(azureContainerName,
|
||||
this.test.keyName, err => {
|
||||
assert.strictEqual(err.code, 'NotFound');
|
||||
testContext.test.keyName, err => {
|
||||
expect(err.code).toBe('NotFound');
|
||||
next();
|
||||
}),
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should put objects with same key to file ' +
|
||||
'then Azure, and object should only be present on Azure',
|
||||
function itF(done) {
|
||||
test('should put objects with same key to file ' +
|
||||
'then Azure, and object should only be present on Azure', done => {
|
||||
const params = { Bucket: azureContainerName, Key:
|
||||
this.test.keyName,
|
||||
testContext.test.keyName,
|
||||
Body: normalBody,
|
||||
Metadata: { 'scal-location-constraint': fileLocation } };
|
||||
async.waterfall([
|
||||
|
@ -267,42 +271,42 @@ describeF() {
|
|||
s3.putObject(params, err => setTimeout(() =>
|
||||
next(err), azureTimeout));
|
||||
},
|
||||
next => azureGetCheck(this.test.keyName, normalMD5,
|
||||
next => azureGetCheck(testContext.test.keyName, normalMD5,
|
||||
azureMetadata, next),
|
||||
], done);
|
||||
});
|
||||
|
||||
describe('with ongoing MPU with same key name', () => {
|
||||
beforeEach(function beFn(done) {
|
||||
beforeEach(done => {
|
||||
s3.createMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyName,
|
||||
Key: testContext.currentTest.keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, `Err creating MPU: ${err}`);
|
||||
this.currentTest.uploadId = res.UploadId;
|
||||
expect(err).toEqual(null);
|
||||
testContext.currentTest.uploadId = res.UploadId;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function afFn(done) {
|
||||
afterEach(done => {
|
||||
s3.abortMultipartUpload({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.currentTest.keyName,
|
||||
UploadId: this.currentTest.uploadId,
|
||||
Key: testContext.currentTest.keyName,
|
||||
UploadId: testContext.currentTest.uploadId,
|
||||
}, err => {
|
||||
assert.equal(err, null, `Err aborting MPU: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return ServiceUnavailable', function itFn(done) {
|
||||
test('should return ServiceUnavailable', done => {
|
||||
s3.putObject({
|
||||
Bucket: azureContainerName,
|
||||
Key: this.test.keyName,
|
||||
Key: testContext.test.keyName,
|
||||
Metadata: { 'scal-location-constraint': azureLocation },
|
||||
}, err => {
|
||||
assert.strictEqual(err.code, 'ServiceUnavailable');
|
||||
expect(err.code).toBe('ServiceUnavailable');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,15 +23,13 @@ function checkGcp(key, gcpMD5, location, callback) {
|
|||
Bucket: gcpBucket,
|
||||
Key: key,
|
||||
}, (err, res) => {
|
||||
assert.equal(err, null, `Expected success, got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
if (res.Metadata && res.Metadata['scal-etag']) {
|
||||
assert.strictEqual(res.Metadata['scal-etag'], gcpMD5);
|
||||
expect(res.Metadata['scal-etag']).toBe(gcpMD5);
|
||||
} else {
|
||||
assert.strictEqual(
|
||||
res.ETag.substring(1, res.ETag.length - 1), gcpMD5);
|
||||
expect(res.ETag.substring(1, res.ETag.length - 1)).toBe(gcpMD5);
|
||||
}
|
||||
assert.strictEqual(res.Metadata['scal-location-constraint'],
|
||||
location);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(location);
|
||||
callback(res);
|
||||
});
|
||||
}
|
||||
|
@ -42,10 +40,8 @@ function checkGcpError(key, expectedError, callback) {
|
|||
Bucket: gcpBucket,
|
||||
Key: key,
|
||||
}, err => {
|
||||
assert.notStrictEqual(err, undefined,
|
||||
'Expected error but did not find one');
|
||||
assert.strictEqual(err.code, expectedError,
|
||||
`Expected error code ${expectedError} but got ${err.code}`);
|
||||
expect(err).not.toBe(undefined);
|
||||
expect(err.code).toBe(expectedError);
|
||||
callback();
|
||||
});
|
||||
}, 1000);
|
||||
|
@ -61,11 +57,9 @@ function gcpGetCheck(objectKey, s3MD5, gcpMD5, location, callback) {
|
|||
s3.getObject({ Bucket: bucket, Key: objectKey }, s3GetCallback);
|
||||
}, retryTimeout);
|
||||
}
|
||||
assert.strictEqual(err, null, 'Expected success, got error ' +
|
||||
`on call to GCP through S3: ${err}`);
|
||||
assert.strictEqual(res.ETag, `"${s3MD5}"`);
|
||||
assert.strictEqual(res.Metadata['scal-location-constraint'],
|
||||
location);
|
||||
expect(err).toBe(null);
|
||||
expect(res.ETag).toBe(`"${s3MD5}"`);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(location);
|
||||
process.stdout.write('Getting object from GCP\n');
|
||||
return checkGcp(objectKey, gcpMD5, location, callback);
|
||||
});
|
||||
|
@ -99,7 +93,7 @@ describeFn() {
|
|||
});
|
||||
|
||||
describe('with set location from "x-amz-meta-scal-' +
|
||||
'location-constraint" header', function describe() {
|
||||
'location-constraint" header', () => {
|
||||
if (!process.env.S3_END_TO_END) {
|
||||
this.retries(2);
|
||||
}
|
||||
|
@ -124,14 +118,13 @@ describeFn() {
|
|||
putTests.forEach(test => {
|
||||
const { location, Body } = test.input;
|
||||
const { s3MD5, gcpMD5 } = test.output;
|
||||
it(test.msg, done => {
|
||||
test(test.msg, done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body,
|
||||
Metadata: { 'scal-location-constraint': location },
|
||||
};
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return gcpGetCheck(key, s3MD5, gcpMD5, location,
|
||||
() => done());
|
||||
});
|
||||
|
@ -139,32 +132,27 @@ describeFn() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('with object rewrites', function describe() {
|
||||
describe('with object rewrites', () => {
|
||||
if (!process.env.S3_END_TO_END) {
|
||||
this.retries(2);
|
||||
}
|
||||
|
||||
it('should put objects with same key to GCP ' +
|
||||
test('should put objects with same key to GCP ' +
|
||||
'then file, and object should only be present in file', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': gcpLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata =
|
||||
{ 'scal-location-constraint': fileLocation };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
assert.strictEqual(
|
||||
res.Metadata['scal-location-constraint'],
|
||||
fileLocation);
|
||||
expect(err).toEqual(null);
|
||||
expect(res.Metadata['scal-location-constraint']).toBe(fileLocation);
|
||||
return checkGcpError(key, 'NoSuchKey',
|
||||
() => done());
|
||||
});
|
||||
|
@ -172,27 +160,25 @@ describeFn() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should put objects with same key to file ' +
|
||||
test('should put objects with same key to file ' +
|
||||
'then GCP, and object should only be present on GCP', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
Body: body,
|
||||
Metadata: { 'scal-location-constraint': fileLocation } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata = {
|
||||
'scal-location-constraint': gcpLocation };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return gcpGetCheck(key, correctMD5, correctMD5,
|
||||
gcpLocation, () => done());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put two objects to GCP with same ' +
|
||||
test('should put two objects to GCP with same ' +
|
||||
'key, and newest object should be returned', done => {
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
|
@ -200,17 +186,15 @@ describeFn() {
|
|||
Metadata: { 'scal-location-constraint': gcpLocation,
|
||||
'unique-header': 'first object' } };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
params.Metadata = { 'scal-location-constraint': gcpLocation,
|
||||
'unique-header': 'second object' };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return gcpGetCheck(key, correctMD5, correctMD5,
|
||||
gcpLocation, result => {
|
||||
assert.strictEqual(result.Metadata
|
||||
['unique-header'], 'second object');
|
||||
expect(result.Metadata
|
||||
['unique-header']).toBe('second object');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -241,20 +225,19 @@ describeSkipIfNotMultipleOrCeph('MultipleBackend put object' +
|
|||
});
|
||||
});
|
||||
|
||||
it('should put an object to GCP with no location header', done => {
|
||||
test('should put an object to GCP with no location header', done => {
|
||||
process.stdout.write('Creating bucket\n');
|
||||
return s3.createBucket({ Bucket: bucket,
|
||||
CreateBucketConfiguration: {
|
||||
LocationConstraint: gcpLocation,
|
||||
},
|
||||
}, err => {
|
||||
assert.equal(err, null, `Error creating bucket: ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
process.stdout.write('Putting object\n');
|
||||
const key = `somekey-${genUniqID()}`;
|
||||
const params = { Bucket: bucket, Key: key, Body: body };
|
||||
return s3.putObject(params, err => {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${err}`);
|
||||
expect(err).toEqual(null);
|
||||
return gcpGetCheck(key, correctMD5, correctMD5, undefined,
|
||||
() => done());
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ let s3;
|
|||
|
||||
describe('Requests to ip endpoint not in config', () => {
|
||||
withV4(sigCfg => {
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
// change endpoint to endpoint with ip address
|
||||
// not in config
|
||||
|
@ -21,7 +21,7 @@ describe('Requests to ip endpoint not in config', () => {
|
|||
s3 = bucketUtil.s3;
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucket)
|
||||
.then(() => {
|
||||
|
@ -34,15 +34,14 @@ describe('Requests to ip endpoint not in config', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should accept put bucket request ' +
|
||||
test('should accept put bucket request ' +
|
||||
'to IP address endpoint that is not in config using ' +
|
||||
'path style',
|
||||
done => {
|
||||
s3.createBucket({ Bucket: bucket }, err => {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
'path style', done => {
|
||||
s3.createBucket({ Bucket: bucket }, err => {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
const itSkipIfE2E = process.env.S3_END_TO_END ? it.skip : it;
|
||||
// skipping in E2E since in E2E 127.0.0.3 resolving to
|
||||
|
@ -56,37 +55,35 @@ describe('Requests to ip endpoint not in config', () => {
|
|||
(err, res) => {
|
||||
assert.ifError(err);
|
||||
// us-east-1 is returned as empty string
|
||||
assert.strictEqual(res
|
||||
.LocationConstraint, '');
|
||||
expect(res
|
||||
.LocationConstraint).toBe('');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept put object request ' +
|
||||
test('should accept put object request ' +
|
||||
'to IP address endpoint that is not in config using ' +
|
||||
'path style and use the bucket location for the object',
|
||||
done => {
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: body },
|
||||
err => {
|
||||
assert.ifError(err);
|
||||
return s3.headObject({ Bucket: bucket, Key: key },
|
||||
err => {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
'path style and use the bucket location for the object', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: key, Body: body },
|
||||
err => {
|
||||
assert.ifError(err);
|
||||
return s3.headObject({ Bucket: bucket, Key: key },
|
||||
err => {
|
||||
assert.ifError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept get object request ' +
|
||||
test('should accept get object request ' +
|
||||
'to IP address endpoint that is not in config using ' +
|
||||
'path style',
|
||||
done => {
|
||||
s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(res.ETag, expectedETag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
'path style', done => {
|
||||
s3.getObject({ Bucket: bucket, Key: key },
|
||||
(err, res) => {
|
||||
assert.ifError(err);
|
||||
expect(res.ETag).toBe(expectedETag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -60,12 +60,12 @@ if (config.backends.data === 'multiple') {
|
|||
|
||||
function _assertErrorResult(err, expectedError, desc) {
|
||||
if (!expectedError) {
|
||||
assert.strictEqual(err, null, `got error for ${desc}: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
return;
|
||||
}
|
||||
assert(err, `expected ${expectedError} but found no error`);
|
||||
assert.strictEqual(err.code, expectedError);
|
||||
assert.strictEqual(err.statusCode, errors[expectedError].code);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(expectedError);
|
||||
expect(err.statusCode).toBe(errors[expectedError].code);
|
||||
}
|
||||
|
||||
const utils = {
|
||||
|
@ -213,8 +213,7 @@ utils.putToAwsBackend = (s3, bucket, key, body, cb) => {
|
|||
utils.enableVersioning = (s3, bucket, cb) => {
|
||||
s3.putBucketVersioning({ Bucket: bucket,
|
||||
VersioningConfiguration: versioningEnabled }, err => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`enabling versioning, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
@ -222,8 +221,7 @@ utils.enableVersioning = (s3, bucket, cb) => {
|
|||
utils.suspendVersioning = (s3, bucket, cb) => {
|
||||
s3.putBucketVersioning({ Bucket: bucket,
|
||||
VersioningConfiguration: versioningSuspended }, err => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`enabling versioning, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
@ -232,8 +230,7 @@ utils.mapToAwsPuts = (s3, bucket, key, dataArray, cb) => {
|
|||
async.mapSeries(dataArray, (data, next) => {
|
||||
utils.putToAwsBackend(s3, bucket, key, data, next);
|
||||
}, (err, results) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`putting object, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
cb(null, results);
|
||||
});
|
||||
};
|
||||
|
@ -259,27 +256,23 @@ utils.getAndAssertResult = (s3, params, cb) => {
|
|||
if (expectedError) {
|
||||
return cb();
|
||||
}
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`getting object, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (body) {
|
||||
assert(data.Body, 'expected object body in response');
|
||||
assert.equal(data.Body.length, data.ContentLength,
|
||||
`received data of length ${data.Body.length} does not ` +
|
||||
'equal expected based on ' +
|
||||
`content length header of ${data.ContentLength}`);
|
||||
expect(data.Body).toBeTruthy();
|
||||
expect(data.Body.length).toEqual(data.ContentLength);
|
||||
const expectedMD5 = utils.expectedETag(body, false);
|
||||
const resultMD5 = utils.expectedETag(data.Body, false);
|
||||
assert.strictEqual(resultMD5, expectedMD5);
|
||||
expect(resultMD5).toBe(expectedMD5);
|
||||
}
|
||||
if (!expectedVersionId) {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, expectedVersionId);
|
||||
expect(data.VersionId).toBe(expectedVersionId);
|
||||
}
|
||||
if (expectedTagCount && expectedTagCount === '0') {
|
||||
assert.strictEqual(data.TagCount, undefined);
|
||||
expect(data.TagCount).toBe(undefined);
|
||||
} else if (expectedTagCount) {
|
||||
assert.strictEqual(data.TagCount, expectedTagCount);
|
||||
expect(data.TagCount).toBe(expectedTagCount);
|
||||
}
|
||||
return cb();
|
||||
});
|
||||
|
@ -314,11 +307,10 @@ utils.getAwsRetry = (params, retryNumber, assertCb) => {
|
|||
|
||||
utils.awsGetLatestVerId = (key, body, cb) =>
|
||||
utils.getAwsRetry({ key }, 0, (err, result) => {
|
||||
assert.strictEqual(err, null, 'Expected success ' +
|
||||
`getting object from AWS, got error ${err}`);
|
||||
expect(err).toBe(null);
|
||||
const resultMD5 = utils.expectedETag(result.Body, false);
|
||||
const expectedMD5 = utils.expectedETag(body, false);
|
||||
assert.strictEqual(resultMD5, expectedMD5, 'expected different body');
|
||||
expect(resultMD5).toBe(expectedMD5);
|
||||
return cb(null, result.VersionId);
|
||||
});
|
||||
|
||||
|
@ -346,11 +338,11 @@ utils.tagging.putTaggingAndAssert = (s3, params, cb) => {
|
|||
if (expectedError) {
|
||||
return cb();
|
||||
}
|
||||
assert.strictEqual(err, null, `got error for putting tags: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (expectedVersionId) {
|
||||
assert.strictEqual(data.VersionId, expectedVersionId);
|
||||
expect(data.VersionId).toBe(expectedVersionId);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
}
|
||||
return cb(null, data.VersionId);
|
||||
});
|
||||
|
@ -367,11 +359,11 @@ utils.tagging.getTaggingAndAssert = (s3, params, cb) => {
|
|||
}
|
||||
const expectedTagResult = _getTaggingConfig(expectedTags);
|
||||
const expectedTagCount = `${Object.keys(expectedTags).length}`;
|
||||
assert.strictEqual(err, null, `got error for putting tags: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (expectedVersionId) {
|
||||
assert.strictEqual(data.VersionId, expectedVersionId);
|
||||
expect(data.VersionId).toBe(expectedVersionId);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
}
|
||||
assert.deepStrictEqual(data.TagSet, expectedTagResult.TagSet);
|
||||
if (getObject === false) {
|
||||
|
@ -391,11 +383,11 @@ utils.tagging.delTaggingAndAssert = (s3, params, cb) => {
|
|||
if (expectedError) {
|
||||
return cb();
|
||||
}
|
||||
assert.strictEqual(err, null, `got error for putting tags: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
if (expectedVersionId) {
|
||||
assert.strictEqual(data.VersionId, expectedVersionId);
|
||||
expect(data.VersionId).toBe(expectedVersionId);
|
||||
} else {
|
||||
assert.strictEqual(data.VersionId, undefined);
|
||||
expect(data.VersionId).toBe(undefined);
|
||||
}
|
||||
return utils.tagging.getTaggingAndAssert(s3, { bucket, key, versionId,
|
||||
expectedVersionId, expectedTags: {} }, () => cb());
|
||||
|
@ -407,8 +399,7 @@ utils.tagging.awsGetAssertTags = (params, cb) => {
|
|||
const expectedTagResult = _getTaggingConfig(expectedTags);
|
||||
awsS3.getObjectTagging({ Bucket: awsBucket, Key: key,
|
||||
VersionId: versionId }, (err, data) => {
|
||||
assert.strictEqual(err, null, 'got unexpected error getting ' +
|
||||
`tags directly from AWS: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
assert.deepStrictEqual(data.TagSet, expectedTagResult.TagSet);
|
||||
return cb();
|
||||
});
|
||||
|
|
|
@ -48,7 +48,7 @@ class ContinueRequestHandler {
|
|||
const options = this.getRequestOptions();
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
const req = transport.request(options, res => {
|
||||
assert.strictEqual(res.statusCode, statusCode);
|
||||
expect(res.statusCode).toBe(statusCode);
|
||||
return cb();
|
||||
});
|
||||
// Send the body either on the continue event, or immediately.
|
||||
|
@ -64,18 +64,18 @@ class ContinueRequestHandler {
|
|||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
const req = transport.request(options);
|
||||
// At this point we have only sent the header.
|
||||
assert(req.output.length === 1);
|
||||
expect(req.output.length === 1).toBeTruthy();
|
||||
const headerLen = req.output[0].length;
|
||||
req.on('continue', () => {
|
||||
// Has only the header been sent?
|
||||
assert.strictEqual(req.socket.bytesWritten, headerLen);
|
||||
expect(req.socket.bytesWritten).toBe(headerLen);
|
||||
// Send the body since the continue event has been emitted.
|
||||
return req.end(body);
|
||||
});
|
||||
req.on('close', () => {
|
||||
const expected = body.length + headerLen;
|
||||
// Has the entire body been sent?
|
||||
assert.strictEqual(req.socket.bytesWritten, expected);
|
||||
expect(req.socket.bytesWritten).toBe(expected);
|
||||
return cb();
|
||||
});
|
||||
req.on('error', err => cb(err));
|
||||
|
@ -106,25 +106,25 @@ describe('PUT public object with 100-continue header', () => {
|
|||
bucketUtil.empty(bucket)
|
||||
.then(() => bucketUtil.deleteOne(bucket)));
|
||||
|
||||
it('should return 200 status code', done =>
|
||||
test('should return 200 status code', done =>
|
||||
continueRequest.hasStatusCode(200, done));
|
||||
|
||||
it('should return 200 status code with upper case value', done =>
|
||||
test('should return 200 status code with upper case value', done =>
|
||||
continueRequest.setExpectHeader('100-CONTINUE')
|
||||
.hasStatusCode(200, done));
|
||||
|
||||
it('should return 200 status code if incorrect value', done =>
|
||||
test('should return 200 status code if incorrect value', done =>
|
||||
continueRequest.setExpectHeader('101-continue')
|
||||
.hasStatusCode(200, done));
|
||||
|
||||
it('should return 403 status code if cannot authenticate', done =>
|
||||
test('should return 403 status code if cannot authenticate', done =>
|
||||
continueRequest.setRequestPath(invalidSignedURL)
|
||||
.hasStatusCode(403, done));
|
||||
|
||||
it('should wait for continue event before sending body', done =>
|
||||
test('should wait for continue event before sending body', done =>
|
||||
continueRequest.sendsBodyOnContinue(done));
|
||||
|
||||
it('should continue if a public user', done =>
|
||||
test('should continue if a public user', done =>
|
||||
continueRequest.setRequestPath(invalidSignedURL)
|
||||
.sendsBodyOnContinue(done));
|
||||
});
|
||||
|
|
|
@ -9,9 +9,9 @@ const key = 'key';
|
|||
const bodyFirstPart = Buffer.allocUnsafe(10).fill(0);
|
||||
|
||||
function checkError(err, code, message) {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, code);
|
||||
assert.strictEqual(err.message, message);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(code);
|
||||
expect(err.message).toBe(message);
|
||||
}
|
||||
|
||||
describe('Abort MPU', () => {
|
||||
|
@ -44,11 +44,9 @@ describe('Abort MPU', () => {
|
|||
UploadId: uploadId,
|
||||
})
|
||||
.then(() => bucketUtil.empty(bucket))
|
||||
.then(() => bucketUtil.deleteOne(bucket))
|
||||
);
|
||||
.then(() => bucketUtil.deleteOne(bucket)));
|
||||
|
||||
it('should return InvalidRequest error if aborting without key',
|
||||
done => {
|
||||
test('should return InvalidRequest error if aborting without key', done => {
|
||||
s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: '',
|
||||
|
|
|
@ -37,10 +37,10 @@ function uploadPart(n, uploadId, s3, next) {
|
|||
// NOTE: This test has a history of failing in end-to-end Integration tests.
|
||||
// See Integration#449 for more details. A possible cause for its flakiness
|
||||
// could be poor system resources.
|
||||
describe('large mpu', function tester() {
|
||||
describe('large mpu', () => {
|
||||
this.timeout(600000);
|
||||
let s3;
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
// disable node sdk retries and timeout to prevent InvalidPart
|
||||
|
@ -53,7 +53,7 @@ describe('large mpu', function tester() {
|
|||
s3.createBucket({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3.deleteObject({ Bucket: bucket, Key: key }, err => {
|
||||
if (err) {
|
||||
process.stdout.write('err deleting object in after: ', err);
|
||||
|
@ -118,8 +118,7 @@ describe('large mpu', function tester() {
|
|||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
assert.strictEqual(data.ETag,
|
||||
`"${finalETag}-${partCount}"`);
|
||||
expect(data.ETag).toBe(`"${finalETag}-${partCount}"`);
|
||||
return next();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -12,8 +12,7 @@ const bucket = `completempu${date}`;
|
|||
const key = 'key';
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,9 +33,9 @@ describe('Complete MPU', () => {
|
|||
checkNoError(err);
|
||||
const versionId = data.VersionId;
|
||||
if (expectedVid) {
|
||||
assert.notEqual(versionId, undefined);
|
||||
expect(versionId).not.toEqual(undefined);
|
||||
} else {
|
||||
assert.strictEqual(versionId, expectedVid);
|
||||
expect(versionId).toBe(expectedVid);
|
||||
}
|
||||
return s3.getObject({
|
||||
Bucket: bucket,
|
||||
|
@ -45,7 +44,7 @@ describe('Complete MPU', () => {
|
|||
(err, data) => {
|
||||
checkNoError(err);
|
||||
if (versionId) {
|
||||
assert.strictEqual(data.VersionId, versionId);
|
||||
expect(data.VersionId).toBe(versionId);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
@ -92,10 +91,9 @@ describe('Complete MPU', () => {
|
|||
.then(result => {
|
||||
uploadId = result.uploadId;
|
||||
eTag = result.eTag;
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
it('should complete an MPU with fewer parts than were ' +
|
||||
test('should complete an MPU with fewer parts than were ' +
|
||||
'originally put without returning a version id', done => {
|
||||
_completeMpuAndCheckVid(uploadId, eTag, undefined, done);
|
||||
});
|
||||
|
@ -111,10 +109,9 @@ describe('Complete MPU', () => {
|
|||
.then(result => {
|
||||
uploadId = result.uploadId;
|
||||
eTag = result.eTag;
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
it('should complete an MPU with fewer parts than were ' +
|
||||
test('should complete an MPU with fewer parts than were ' +
|
||||
'originally put and return a version id', done => {
|
||||
_completeMpuAndCheckVid(uploadId, eTag, true, done);
|
||||
});
|
||||
|
@ -130,10 +127,9 @@ describe('Complete MPU', () => {
|
|||
.then(result => {
|
||||
uploadId = result.uploadId;
|
||||
eTag = result.eTag;
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
it('should complete an MPU with fewer parts than were ' +
|
||||
test('should complete an MPU with fewer parts than were ' +
|
||||
'originally put and should not return a version id', done => {
|
||||
_completeMpuAndCheckVid(uploadId, eTag, undefined, done);
|
||||
});
|
||||
|
|
|
@ -21,14 +21,14 @@ describe('aws-node-sdk test bucket complete mpu', () => {
|
|||
let s3;
|
||||
|
||||
// setup test
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const config = getConfig('default', { signatureVersion: 'v4' });
|
||||
s3 = new S3(config);
|
||||
s3.createBucket({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
// delete bucket after testing
|
||||
after(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
afterAll(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
const itSkipIfAWS = process.env.AWS_ON_AIR ? it.skip : it;
|
||||
itSkipIfAWS('should not accept xml body larger than 1 MB', done => {
|
||||
|
@ -42,9 +42,8 @@ describe('aws-node-sdk test bucket complete mpu', () => {
|
|||
};
|
||||
s3.completeMultipartUpload(params, error => {
|
||||
if (error) {
|
||||
assert.strictEqual(error.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
error.code, 'InvalidRequest');
|
||||
expect(error.statusCode).toBe(400);
|
||||
expect(error.code).toBe('InvalidRequest');
|
||||
done();
|
||||
} else {
|
||||
done('accepted xml body larger than 1 MB');
|
||||
|
|
|
@ -21,13 +21,12 @@ const otherAccountS3 = otherAccountBucketUtility.s3;
|
|||
const oneHundredMBPlus11 = 110100481;
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
function checkError(err, code) {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, code);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(code);
|
||||
}
|
||||
|
||||
describe('Object Part Copy', () => {
|
||||
|
@ -91,11 +90,10 @@ describe('Object Part Copy', () => {
|
|||
}
|
||||
})
|
||||
.then(() => bucketUtil.deleteMany([sourceBucketName,
|
||||
destBucketName]))
|
||||
);
|
||||
destBucketName])));
|
||||
|
||||
|
||||
it('should copy a part from a source bucket to a different ' +
|
||||
test('should copy a part from a source bucket to a different ' +
|
||||
'destination bucket', done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
|
@ -105,13 +103,13 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
(err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag, etag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(etag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy a part from a source bucket to a different ' +
|
||||
test('should copy a part from a source bucket to a different ' +
|
||||
'destination bucket and complete the MPU', done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
|
@ -121,8 +119,8 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
(err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag, etag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(etag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
s3.completeMultipartUpload({
|
||||
Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
|
@ -134,17 +132,16 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
}, (err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
// AWS confirmed final ETag for MPU
|
||||
assert.strictEqual(res.ETag,
|
||||
'"db77ebbae9e9f5a244a26b86193ad818-1"');
|
||||
expect(res.ETag).toBe('"db77ebbae9e9f5a244a26b86193ad818-1"');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return EntityTooLarge error if attempt to copy ' +
|
||||
test('should return EntityTooLarge error if attempt to copy ' +
|
||||
'object larger than max and do not specify smaller ' +
|
||||
'range in request', done => {
|
||||
s3.putObject({
|
||||
|
@ -166,7 +163,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return EntityTooLarge error if attempt to copy ' +
|
||||
test('should return EntityTooLarge error if attempt to copy ' +
|
||||
'object larger than max and specify too large ' +
|
||||
'range in request', done => {
|
||||
s3.putObject({
|
||||
|
@ -189,7 +186,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should succeed if attempt to copy ' +
|
||||
test('should succeed if attempt to copy ' +
|
||||
'object larger than max but specify acceptable ' +
|
||||
'range in request', done => {
|
||||
s3.putObject({
|
||||
|
@ -212,7 +209,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should copy a 0 byte object part from a source bucket to a ' +
|
||||
test('should copy a 0 byte object part from a source bucket to a ' +
|
||||
'different destination bucket and complete the MPU', done => {
|
||||
const emptyFileETag = '"d41d8cd98f00b204e9800998ecf8427e"';
|
||||
s3.putObject({
|
||||
|
@ -228,8 +225,8 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
(err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag, emptyFileETag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(emptyFileETag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
s3.completeMultipartUpload({
|
||||
Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
|
@ -241,18 +238,17 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
}, (err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
// AWS confirmed final ETag for MPU
|
||||
assert.strictEqual(res.ETag,
|
||||
'"59adb24ef3cdbe0297f05b395827453f-1"');
|
||||
expect(res.ETag).toBe('"59adb24ef3cdbe0297f05b395827453f-1"');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy a part using a range header from a source bucket ' +
|
||||
test('should copy a part using a range header from a source bucket ' +
|
||||
'to a different destination bucket and complete the MPU', done => {
|
||||
const rangeETag = '"ac1be00f1f162e20d58099eec2ea1c70"';
|
||||
// AWS confirmed final ETag for MPU
|
||||
|
@ -266,8 +262,8 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
(err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag, rangeETag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(rangeETag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
s3.completeMultipartUpload({
|
||||
Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
|
@ -279,17 +275,17 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
}, (err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
assert.strictEqual(res.ETag, finalMpuETag);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
expect(res.ETag).toBe(finalMpuETag);
|
||||
s3.getObject({
|
||||
Bucket: destBucketName,
|
||||
Key: destObjName,
|
||||
}, (err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag, finalMpuETag);
|
||||
assert.strictEqual(res.ContentLength, '4');
|
||||
assert.strictEqual(res.Body.toString(), 'I am');
|
||||
expect(res.ETag).toBe(finalMpuETag);
|
||||
expect(res.ContentLength).toBe('4');
|
||||
expect(res.Body.toString()).toBe('I am');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -376,7 +372,7 @@ describe('Object Part Copy', () => {
|
|||
}
|
||||
}));
|
||||
|
||||
it('should copy a part from a source bucket to a different ' +
|
||||
test('should copy a part from a source bucket to a different ' +
|
||||
'destination bucket', done => {
|
||||
process.stdout.write('Entered first mpu test');
|
||||
return s3.uploadPartCopy({ Bucket: destBucketName,
|
||||
|
@ -387,14 +383,13 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
(err, res) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(res.ETag,
|
||||
totalMpuObjectHash);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(totalMpuObjectHash);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy two parts from a source bucket to a different ' +
|
||||
test('should copy two parts from a source bucket to a different ' +
|
||||
'destination bucket and complete the MPU', () => {
|
||||
process.stdout.write('Putting first part in MPU test');
|
||||
return s3.uploadPartCopyAsync({ Bucket: destBucketName,
|
||||
|
@ -403,8 +398,8 @@ describe('Object Part Copy', () => {
|
|||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, totalMpuObjectHash);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(totalMpuObjectHash);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Putting second part in MPU test');
|
||||
return s3.uploadPartCopyAsync({ Bucket: destBucketName,
|
||||
|
@ -413,8 +408,8 @@ describe('Object Part Copy', () => {
|
|||
PartNumber: 2,
|
||||
UploadId: uploadId,
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, totalMpuObjectHash);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(totalMpuObjectHash);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Completing MPU');
|
||||
return s3.completeMultipartUploadAsync({
|
||||
|
@ -429,19 +424,18 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
});
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
// combined ETag returned by AWS (combination of part ETags
|
||||
// with number of parts at the end)
|
||||
assert.strictEqual(res.ETag,
|
||||
'"5bba96810ff449d94aa8f5c5a859b0cb-2"');
|
||||
expect(res.ETag).toBe('"5bba96810ff449d94aa8f5c5a859b0cb-2"');
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should copy two parts with range headers from a source ' +
|
||||
test('should copy two parts with range headers from a source ' +
|
||||
'bucket to a different destination bucket and ' +
|
||||
'complete the MPU', () => {
|
||||
process.stdout.write('Putting first part in MPU range test');
|
||||
|
@ -458,8 +452,8 @@ describe('Object Part Copy', () => {
|
|||
UploadId: uploadId,
|
||||
CopySourceRange: 'bytes=5242890-15242880',
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, part1ETag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(part1ETag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Putting second part in MPU test');
|
||||
return s3.uploadPartCopyAsync({ Bucket: destBucketName,
|
||||
|
@ -469,8 +463,8 @@ describe('Object Part Copy', () => {
|
|||
UploadId: uploadId,
|
||||
CopySourceRange: 'bytes=15242891-30242991',
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, part2ETag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(part2ETag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Completing MPU');
|
||||
return s3.completeMultipartUploadAsync({
|
||||
|
@ -485,9 +479,9 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
});
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
assert.strictEqual(res.ETag, finalCombinedETag);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
expect(res.ETag).toBe(finalCombinedETag);
|
||||
}).then(() => {
|
||||
process.stdout.write('Getting new object');
|
||||
return s3.getObjectAsync({
|
||||
|
@ -495,8 +489,8 @@ describe('Object Part Copy', () => {
|
|||
Key: destObjName,
|
||||
});
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ContentLength, '25000092');
|
||||
assert.strictEqual(res.ETag, finalCombinedETag);
|
||||
expect(res.ContentLength).toBe('25000092');
|
||||
expect(res.ETag).toBe(finalCombinedETag);
|
||||
})
|
||||
.catch(err => {
|
||||
checkNoError(err);
|
||||
|
@ -504,7 +498,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should overwrite an existing part by copying a part', () => {
|
||||
test('should overwrite an existing part by copying a part', () => {
|
||||
// AWS response etag for this completed MPU
|
||||
const finalObjETag = '"db77ebbae9e9f5a244a26b86193ad818-1"';
|
||||
process.stdout.write('Putting first part in MPU test');
|
||||
|
@ -514,8 +508,8 @@ describe('Object Part Copy', () => {
|
|||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, totalMpuObjectHash);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(totalMpuObjectHash);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Overwriting first part in MPU test');
|
||||
return s3.uploadPartCopyAsync({ Bucket: destBucketName,
|
||||
|
@ -524,8 +518,8 @@ describe('Object Part Copy', () => {
|
|||
PartNumber: 1,
|
||||
UploadId: uploadId });
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, etag);
|
||||
assert(res.LastModified);
|
||||
expect(res.ETag).toBe(etag);
|
||||
expect(res.LastModified).toBeTruthy();
|
||||
}).then(() => {
|
||||
process.stdout.write('Completing MPU');
|
||||
return s3.completeMultipartUploadAsync({
|
||||
|
@ -539,9 +533,9 @@ describe('Object Part Copy', () => {
|
|||
},
|
||||
});
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Bucket, destBucketName);
|
||||
assert.strictEqual(res.Key, destObjName);
|
||||
assert.strictEqual(res.ETag, finalObjETag);
|
||||
expect(res.Bucket).toBe(destBucketName);
|
||||
expect(res.Key).toBe(destObjName);
|
||||
expect(res.ETag).toBe(finalObjETag);
|
||||
}).then(() => {
|
||||
process.stdout.write('Getting object put by MPU with ' +
|
||||
'overwrite part');
|
||||
|
@ -550,27 +544,27 @@ describe('Object Part Copy', () => {
|
|||
Key: destObjName,
|
||||
});
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.ETag, finalObjETag);
|
||||
expect(res.ETag).toBe(finalObjETag);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error if no such upload initiated',
|
||||
done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/${sourceObjName}`,
|
||||
PartNumber: 1,
|
||||
UploadId: 'madeupuploadid444233232',
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'NoSuchUpload');
|
||||
done();
|
||||
});
|
||||
test('should return an error if no such upload initiated', done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/${sourceObjName}`,
|
||||
PartNumber: 1,
|
||||
UploadId: 'madeupuploadid444233232',
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'NoSuchUpload');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error if attempt to copy from nonexistent bucket',
|
||||
test(
|
||||
'should return an error if attempt to copy from nonexistent bucket',
|
||||
done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `nobucket453234/${sourceObjName}`,
|
||||
|
@ -581,9 +575,11 @@ describe('Object Part Copy', () => {
|
|||
checkError(err, 'NoSuchBucket');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return an error if attempt to copy to nonexistent bucket',
|
||||
test(
|
||||
'should return an error if attempt to copy to nonexistent bucket',
|
||||
done => {
|
||||
s3.uploadPartCopy({ Bucket: 'nobucket453234', Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/${sourceObjName}`,
|
||||
|
@ -594,33 +590,32 @@ describe('Object Part Copy', () => {
|
|||
checkError(err, 'NoSuchBucket');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return an error if attempt to copy nonexistent object',
|
||||
done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/nokey`,
|
||||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'NoSuchKey');
|
||||
done();
|
||||
});
|
||||
test('should return an error if attempt to copy nonexistent object', done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/nokey`,
|
||||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error if use invalid part number',
|
||||
done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/nokey`,
|
||||
PartNumber: 10001,
|
||||
UploadId: uploadId,
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'InvalidArgument');
|
||||
done();
|
||||
});
|
||||
test('should return an error if use invalid part number', done => {
|
||||
s3.uploadPartCopy({ Bucket: destBucketName, Key: destObjName,
|
||||
CopySource: `${sourceBucketName}/nokey`,
|
||||
PartNumber: 10001,
|
||||
UploadId: uploadId,
|
||||
},
|
||||
err => {
|
||||
checkError(err, 'InvalidArgument');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('copying parts by another account', () => {
|
||||
const otherAccountBucket = 'otheraccountbucket42342342342';
|
||||
|
@ -663,10 +658,9 @@ describe('Object Part Copy', () => {
|
|||
throw err;
|
||||
}
|
||||
}).then(() => otherAccountBucketUtility
|
||||
.deleteOne(otherAccountBucket))
|
||||
);
|
||||
.deleteOne(otherAccountBucket)));
|
||||
|
||||
it('should not allow an account without read persmission on the ' +
|
||||
test('should not allow an account without read persmission on the ' +
|
||||
'source object to copy the object', done => {
|
||||
otherAccountS3.uploadPartCopy({ Bucket: otherAccountBucket,
|
||||
Key: otherAccountKey,
|
||||
|
@ -680,7 +674,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not allow an account without write persmission on the ' +
|
||||
test('should not allow an account without write persmission on the ' +
|
||||
'destination bucket to upload part copy the object', done => {
|
||||
otherAccountS3.putObject({ Bucket: otherAccountBucket,
|
||||
Key: otherAccountKey, Body: '' }, () => {
|
||||
|
@ -697,7 +691,7 @@ describe('Object Part Copy', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow an account with read permission on the ' +
|
||||
test('should allow an account with read permission on the ' +
|
||||
'source object and write permission on the destination ' +
|
||||
'bucket to upload part copy the object', done => {
|
||||
s3.putObjectAcl({ Bucket: sourceBucketName,
|
||||
|
|
|
@ -233,8 +233,7 @@ function _checkHeaders(action, params, origin, expectedHeaders, callback) {
|
|||
function _runAssertions(resHeaders, cb) {
|
||||
if (expectedHeaders) {
|
||||
Object.keys(expectedHeaders).forEach(key => {
|
||||
assert.deepEqual(resHeaders[key], expectedHeaders[key],
|
||||
`error header: ${key}`);
|
||||
expect(resHeaders[key]).toEqual(expectedHeaders[key]);
|
||||
});
|
||||
} else {
|
||||
// if no headersResponse provided, should not have these headers
|
||||
|
@ -243,8 +242,7 @@ function _checkHeaders(action, params, origin, expectedHeaders, callback) {
|
|||
'access-control-allow-methods',
|
||||
'access-control-allow-credentials',
|
||||
'vary'].forEach(key => {
|
||||
assert.strictEqual(resHeaders[key], undefined,
|
||||
`Error: ${key} should not have value`);
|
||||
expect(resHeaders[key]).toBe(undefined);
|
||||
});
|
||||
}
|
||||
cb();
|
||||
|
@ -297,7 +295,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
});
|
||||
|
||||
describe('on non-existing bucket', () => {
|
||||
it('should not respond to request with CORS headers, even ' +
|
||||
test('should not respond to request with CORS headers, even ' +
|
||||
'if request was sent with Origin header', done => {
|
||||
_checkHeaders(s3.listObjects, { Bucket: 'nonexistingbucket' },
|
||||
allowedOrigin, null, done);
|
||||
|
@ -305,7 +303,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
});
|
||||
|
||||
describe('on bucket without CORS configuration', () => {
|
||||
it('should not respond to request with CORS headers, even ' +
|
||||
test('should not respond to request with CORS headers, even ' +
|
||||
'if request was sent with Origin header', done => {
|
||||
_checkHeaders(s3.listObjects, { Bucket: bucket },
|
||||
allowedOrigin, null, done);
|
||||
|
@ -340,24 +338,24 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
});
|
||||
|
||||
describe('when request Origin/method match CORS configuration', () => {
|
||||
it('should not respond with CORS headers to GET service (list ' +
|
||||
test('should not respond with CORS headers to GET service (list ' +
|
||||
'buckets), even if Origin/method match CORS rule', done => {
|
||||
// no bucket specified in this request
|
||||
_checkHeaders(s3.listBuckets, {}, allowedOrigin,
|
||||
null, done);
|
||||
});
|
||||
|
||||
it('should not respond with CORS headers after deleting bucket, ' +
|
||||
test('should not respond with CORS headers after deleting bucket, ' +
|
||||
'even if Origin/method match CORS rule', done => {
|
||||
s3.deleteBucket({ Bucket: bucket }, err => {
|
||||
assert.strictEqual(err, null, `Unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
_checkHeaders(s3.listObjects, { Bucket: bucket },
|
||||
allowedOrigin, null, done);
|
||||
});
|
||||
});
|
||||
|
||||
apiMethods.forEach(method => {
|
||||
it(`should respond to ${method.description} with CORS ` +
|
||||
test(`should respond to ${method.description} with CORS ` +
|
||||
'headers (access-control-allow-origin, access-control-allow-' +
|
||||
'methods, access-control-allow-credentials and vary)', done => {
|
||||
_checkHeaders(method.action, method.params, allowedOrigin,
|
||||
|
@ -368,7 +366,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
|
||||
describe('when request Origin does not match CORS rule', () => {
|
||||
apiMethods.forEach(method => {
|
||||
it(`should not respond to ${method.description} with ` +
|
||||
test(`should not respond to ${method.description} with ` +
|
||||
'CORS headers', done => {
|
||||
_checkHeaders(method.action, method.params,
|
||||
notAllowedOrigin, null, done);
|
||||
|
@ -392,7 +390,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('when request method does not match CORS rule ' +
|
||||
test('when request method does not match CORS rule ' +
|
||||
'should not respond with CORS headers', done => {
|
||||
_checkHeaders(s3.listObjects, { Bucket: bucket },
|
||||
allowedOrigin, null, done);
|
||||
|
@ -433,16 +431,13 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
ACL: 'public-read',
|
||||
}, next),
|
||||
], err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Unexpected err ${err} in beforeEach`);
|
||||
expect(err).toBe(null);
|
||||
done(err);
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(done =>
|
||||
s3.deleteObject({ Bucket: bucket, Key: 'index.html' }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Unexpected err ${err} in afterEach`);
|
||||
expect(err).toBe(null);
|
||||
s3.deleteBucket({ Bucket: bucket }, err => {
|
||||
if (err) {
|
||||
process.stdout.write(`Error in afterEach ${err}`);
|
||||
|
@ -450,34 +445,29 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
}
|
||||
return _waitForAWS(done);
|
||||
});
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
it('should respond with CORS headers at website endpoint (GET)',
|
||||
done => {
|
||||
test('should respond with CORS headers at website endpoint (GET)', done => {
|
||||
const headers = { Origin: allowedOrigin };
|
||||
methodRequest({ method: 'GET', bucket, headers, headersResponse,
|
||||
code: 200, isWebsite: true }, done);
|
||||
});
|
||||
|
||||
it('should respond with CORS headers at website endpoint (GET) ' +
|
||||
'even in case of error',
|
||||
done => {
|
||||
test('should respond with CORS headers at website endpoint (GET) ' +
|
||||
'even in case of error', done => {
|
||||
const headers = { Origin: allowedOrigin };
|
||||
methodRequest({ method: 'GET', bucket, objectKey: 'test',
|
||||
headers, headersResponse, code: 404, isWebsite: true }, done);
|
||||
});
|
||||
|
||||
it('should respond with CORS headers at website endpoint (GET) ' +
|
||||
'even in case of redirect',
|
||||
done => {
|
||||
test('should respond with CORS headers at website endpoint (GET) ' +
|
||||
'even in case of redirect', done => {
|
||||
const headers = { Origin: allowedOrigin };
|
||||
methodRequest({ method: 'GET', bucket, objectKey: 'redirect',
|
||||
headers, headersResponse, code: 301, isWebsite: true }, done);
|
||||
});
|
||||
|
||||
it('should respond with CORS headers at website endpoint (HEAD)',
|
||||
done => {
|
||||
test('should respond with CORS headers at website endpoint (HEAD)', done => {
|
||||
const headers = { Origin: allowedOrigin };
|
||||
methodRequest({ method: 'HEAD', bucket, headers, headersResponse,
|
||||
code: 200, isWebsite: true }, done);
|
||||
|
@ -506,7 +496,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
s3.putBucketCors(corsParams, done);
|
||||
});
|
||||
|
||||
it('should not return access-control-allow-headers response ' +
|
||||
test('should not return access-control-allow-headers response ' +
|
||||
'header even if request matches CORS rule and other access-' +
|
||||
'control headers are returned', done => {
|
||||
const headers = {
|
||||
|
@ -518,10 +508,9 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
headersOmitted, code: 200 }, done);
|
||||
});
|
||||
|
||||
it('Request with matching Origin/method but additional headers ' +
|
||||
test('Request with matching Origin/method but additional headers ' +
|
||||
'that violate CORS rule:\n\t should still respond with access-' +
|
||||
'control headers (headers are only checked in preflight requests)',
|
||||
done => {
|
||||
'control headers (headers are only checked in preflight requests)', done => {
|
||||
const headers = {
|
||||
Origin: allowedOrigin,
|
||||
Test: 'test',
|
||||
|
@ -553,7 +542,7 @@ describe('Cross Origin Resource Sharing requests', () => {
|
|||
s3.putBucketCors(corsParams, done);
|
||||
});
|
||||
|
||||
it(`should respond with ${elem.header} header ` +
|
||||
test(`should respond with ${elem.header} header ` +
|
||||
'if request matches CORS rule', done => {
|
||||
const headers = { Origin: allowedOrigin };
|
||||
const headersResponse = {
|
||||
|
|
|
@ -29,19 +29,19 @@ function _waitForAWS(callback, err) {
|
|||
}
|
||||
|
||||
describe('Preflight CORS request on non-existing bucket', () => {
|
||||
it('should respond no such bucket if bucket does not exist', done => {
|
||||
test('should respond no such bucket if bucket does not exist', done => {
|
||||
const headers = {
|
||||
Origin: allowedOrigin,
|
||||
};
|
||||
methodRequest({ method: 'GET', bucket, headers, code: 'NoSuchBucket',
|
||||
headersResponse: null }, done);
|
||||
});
|
||||
it('should return BadRequest for OPTIONS request without origin', done => {
|
||||
test('should return BadRequest for OPTIONS request without origin', done => {
|
||||
const headers = {};
|
||||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 'BadRequest',
|
||||
headersResponse: null }, done);
|
||||
});
|
||||
it('should return BadRequest for OPTIONS request without ' +
|
||||
test('should return BadRequest for OPTIONS request without ' +
|
||||
'Access-Control-Request-Method', done => {
|
||||
const headers = {
|
||||
Origin: allowedOrigin,
|
||||
|
@ -63,7 +63,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow GET on bucket without cors configuration even if ' +
|
||||
test('should allow GET on bucket without cors configuration even if ' +
|
||||
'Origin header sent', done => {
|
||||
const headers = {
|
||||
Origin: allowedOrigin,
|
||||
|
@ -71,7 +71,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'GET', bucket, headers, code: 200,
|
||||
headersResponse: null }, done);
|
||||
});
|
||||
it('should allow HEAD on bucket without cors configuration even if ' +
|
||||
test('should allow HEAD on bucket without cors configuration even if ' +
|
||||
'Origin header sent', done => {
|
||||
const headers = {
|
||||
Origin: allowedOrigin,
|
||||
|
@ -79,7 +79,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'HEAD', bucket, headers, code: 200,
|
||||
headersResponse: null }, done);
|
||||
});
|
||||
it('should respond AccessForbidden for OPTIONS request on bucket without ' +
|
||||
test('should respond AccessForbidden for OPTIONS request on bucket without ' +
|
||||
'CORSConfiguration', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -115,7 +115,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
|
||||
methods.forEach(method => {
|
||||
it('should respond with 200 and access control headers to ' +
|
||||
test('should respond with 200 and access control headers to ' +
|
||||
'OPTIONS request from allowed origin and allowed method ' +
|
||||
`"${method}"`, done => {
|
||||
const headers = {
|
||||
|
@ -132,7 +132,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
headersResponse }, done);
|
||||
});
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
'not allowed origin', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -143,7 +143,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers,
|
||||
code: 'AccessForbidden', headersResponse: null }, done);
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request with ' +
|
||||
test('should respond AccessForbidden to OPTIONS request with ' +
|
||||
'not allowed Access-Control-Request-Headers', done => {
|
||||
const headers = {
|
||||
'Origin': 'http://www.forbiddenwebsite.com',
|
||||
|
@ -178,7 +178,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('should respond with 200 and access control headers to OPTIONS ' +
|
||||
test('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin and method "GET"', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -193,7 +193,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request with allowed ' +
|
||||
test('should respond AccessForbidden to OPTIONS request with allowed ' +
|
||||
'method but not from allowed origin', done => {
|
||||
const headers = {
|
||||
'Origin': 'http://www.forbiddenwebsite.com',
|
||||
|
@ -202,9 +202,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers,
|
||||
code: 'AccessForbidden', headersResponse: null }, done);
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request from allowed ' +
|
||||
'origin and method but with not allowed Access-Control-Request-Headers',
|
||||
done => {
|
||||
test('should respond AccessForbidden to OPTIONS request from allowed ' +
|
||||
'origin and method but with not allowed Access-Control-Request-Headers', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -215,7 +214,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
code: 'AccessForbidden', headersResponse: null }, done);
|
||||
});
|
||||
['PUT', 'POST', 'DELETE'].forEach(method => {
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed origin but not allowed method "${method}"`, done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -249,9 +248,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('should respond with 200 and access control headers to ' +
|
||||
`OPTIONS request from allowed origin and method "${allowedMethod}"`,
|
||||
done => {
|
||||
test('should respond with 200 and access control headers to ' +
|
||||
`OPTIONS request from allowed origin and method "${allowedMethod}"`, done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
'Access-Control-Request-Method': allowedMethod,
|
||||
|
@ -264,7 +262,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
'allowed origin and method but with not allowed Access-Control-' +
|
||||
'Request-Headers', done => {
|
||||
const headers = {
|
||||
|
@ -278,7 +276,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
methods.filter(method => method !== allowedMethod)
|
||||
.forEach(method => {
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed origin but not allowed method "${method}"`, done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -317,9 +315,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
|
||||
[originWithoutWildcard, originReplaceWildcard]
|
||||
.forEach(acceptableOrigin => {
|
||||
it('should return 200 and CORS header to OPTIONS request ' +
|
||||
`from allowed method and origin "${acceptableOrigin}"`,
|
||||
done => {
|
||||
test('should return 200 and CORS header to OPTIONS request ' +
|
||||
`from allowed method and origin "${acceptableOrigin}"`, done => {
|
||||
const headers = {
|
||||
'Origin': acceptableOrigin,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -335,9 +332,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
});
|
||||
if (!origin.endsWith('*')) {
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed method and origin "${originWithoutWildcard}test"`,
|
||||
done => {
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed method and origin "${originWithoutWildcard}test"`, done => {
|
||||
const headers = {
|
||||
'Origin': `${originWithoutWildcard}test`,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -347,9 +343,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
}
|
||||
if (!origin.startsWith('*')) {
|
||||
it('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed method and origin "test${originWithoutWildcard}"`,
|
||||
done => {
|
||||
test('should respond AccessForbidden to OPTIONS request from ' +
|
||||
`allowed method and origin "test${originWithoutWildcard}"`, done => {
|
||||
const headers = {
|
||||
'Origin': `test${originWithoutWildcard}`,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -397,7 +392,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('if OPTIONS request matches rule with multiple origins, response ' +
|
||||
test('if OPTIONS request matches rule with multiple origins, response ' +
|
||||
'access-control-request-origin header value should be request Origin ' +
|
||||
'(not list of AllowedOrigins)', done => {
|
||||
const headers = {
|
||||
|
@ -413,7 +408,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('if OPTIONS request matches rule with origin containing wildcard, ' +
|
||||
test('if OPTIONS request matches rule with origin containing wildcard, ' +
|
||||
'response access-control-request-origin header value should be ' +
|
||||
'request Origin (not value containing wildcard)', done => {
|
||||
const requestOrigin = originContainingWildcard.replace('*', 'test');
|
||||
|
@ -430,7 +425,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('if OPTIONS request matches rule that allows all origins, ' +
|
||||
test('if OPTIONS request matches rule that allows all origins, ' +
|
||||
'e.g. "*", response access-control-request-origin header should ' +
|
||||
'return "*"', done => {
|
||||
const headers = {
|
||||
|
@ -475,7 +470,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('should respond with 200 and access control headers to OPTIONS ' +
|
||||
test('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin and method, even without request ' +
|
||||
'Access-Control-Request-Headers header value', done => {
|
||||
const headers = {
|
||||
|
@ -490,7 +485,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should respond with 200 and access control headers to OPTIONS ' +
|
||||
test('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin and method with Access-Control-' +
|
||||
'Request-Headers \'Content-Type\'', done => {
|
||||
const headers = {
|
||||
|
@ -507,10 +502,9 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should respond AccessForbidden to OPTIONS request from allowed ' +
|
||||
test('should respond AccessForbidden to OPTIONS request from allowed ' +
|
||||
'origin and method but not allowed Access-Control-Request-Headers ' +
|
||||
'in addition to Content-Type',
|
||||
done => {
|
||||
'in addition to Content-Type', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -561,10 +555,9 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('should return request access-control-request-headers value, ' +
|
||||
test('should return request access-control-request-headers value, ' +
|
||||
'not list of AllowedHeaders from rule or corresponding AllowedHeader ' +
|
||||
'value containing wildcard',
|
||||
done => {
|
||||
'value containing wildcard', done => {
|
||||
const requestHeaderValue = 'amz-meta-header-test, content-type';
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -580,9 +573,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should return lowercase version of request Access-Control-' +
|
||||
'Request-Method header value if it contains any upper-case values',
|
||||
done => {
|
||||
test('should return lowercase version of request Access-Control-' +
|
||||
'Request-Method header value if it contains any upper-case values', done => {
|
||||
const requestHeaderValue = 'Content-Type';
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -599,10 +591,9 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should remove empty comma-separated values derived from request ' +
|
||||
test('should remove empty comma-separated values derived from request ' +
|
||||
'Access-Control-Request-Method header and separate values with ' +
|
||||
'spaces when responding with Access-Control-Allow-Headers header',
|
||||
done => {
|
||||
'spaces when responding with Access-Control-Allow-Headers header', done => {
|
||||
const requestHeaderValue = 'content-type,,expires';
|
||||
const expectedValue = 'content-type, expires';
|
||||
const headers = {
|
||||
|
@ -619,7 +610,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', bucket, headers, code: 200,
|
||||
headersResponse }, done);
|
||||
});
|
||||
it('should return request Access-Control-Request-Headers value ' +
|
||||
test('should return request Access-Control-Request-Headers value ' +
|
||||
'even if rule allows all headers (e.g. "*"), unlike access-control-' +
|
||||
'allow-origin value', done => {
|
||||
const requestHeaderValue = 'puppies';
|
||||
|
@ -676,9 +667,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin, allowed method and existing object key',
|
||||
done => {
|
||||
test('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin, allowed method and existing object key', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -692,7 +682,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
methodRequest({ method: 'OPTIONS', objectKey, bucket, headers,
|
||||
code: 200, headersResponse }, done);
|
||||
});
|
||||
it('should respond with 200 and access control headers to OPTIONS ' +
|
||||
test('should respond with 200 and access control headers to OPTIONS ' +
|
||||
'request from allowed origin, allowed method, even with non-existing ' +
|
||||
'object key', done => {
|
||||
const headers = {
|
||||
|
@ -730,7 +720,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('with fake auth credentials: should respond with 200 and access ' +
|
||||
test('with fake auth credentials: should respond with 200 and access ' +
|
||||
'control headers even if request has fake auth credentials', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -746,7 +736,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
headersResponse }, done);
|
||||
});
|
||||
|
||||
it('with cookies: should send identical response as to request ' +
|
||||
test('with cookies: should send identical response as to request ' +
|
||||
'without cookies (200 and access control headers)', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
@ -792,9 +782,8 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('if OPTIONS request matches CORS rule with ExposeHeader\'s, ' +
|
||||
'response should include Access-Control-Expose-Headers header',
|
||||
done => {
|
||||
test('if OPTIONS request matches CORS rule with ExposeHeader\'s, ' +
|
||||
'response should include Access-Control-Expose-Headers header', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
'Access-Control-Request-Method': 'GET',
|
||||
|
@ -836,7 +825,7 @@ describe('Preflight CORS request with existing bucket', () => {
|
|||
s3.deleteBucketCors({ Bucket: bucket }, done);
|
||||
});
|
||||
|
||||
it('if OPTIONS request matches CORS rule with max age seconds, ' +
|
||||
test('if OPTIONS request matches CORS rule with max age seconds, ' +
|
||||
'response should include Access-Control-Max-Age header', done => {
|
||||
const headers = {
|
||||
'Origin': allowedOrigin,
|
||||
|
|
|
@ -27,25 +27,21 @@ describe('DELETE multipart', () => {
|
|||
UploadId: uploadId }, err => {
|
||||
const statusCode =
|
||||
request.response.httpResponse.statusCode;
|
||||
assert.strictEqual(statusCode, statusCodeExpected,
|
||||
`Found unexpected statusCode ${statusCode}`);
|
||||
expect(statusCode).toBe(statusCodeExpected);
|
||||
if (statusCode === 204) {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected no err but found ${err}`);
|
||||
expect(err).toBe(null);
|
||||
return callback(err);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
|
||||
it('on bucket that does not exist: should return NoSuchBucket',
|
||||
done => {
|
||||
test('on bucket that does not exist: should return NoSuchBucket', done => {
|
||||
const uploadId = 'nonexistinguploadid';
|
||||
s3.abortMultipartUpload({ Bucket: bucket, Key: key,
|
||||
UploadId: uploadId }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected NoSuchBucket but found no err');
|
||||
assert.strictEqual(err.code, 'NoSuchBucket');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('NoSuchBucket');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -61,8 +57,7 @@ describe('DELETE multipart', () => {
|
|||
.catch(err => {
|
||||
process.stdout.write(`Error in beforeEach: ${err}\n`);
|
||||
throw err;
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
|
@ -101,10 +96,9 @@ describe('DELETE multipart', () => {
|
|||
PartNumber: 1,
|
||||
UploadId: uploadId,
|
||||
});
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
it('should return 204 for abortMultipartUpload', done => {
|
||||
test('should return 204 for abortMultipartUpload', done => {
|
||||
_assertStatusCode(uploadId, 204,
|
||||
done);
|
||||
});
|
||||
|
|
|
@ -20,9 +20,9 @@ const taggingConfig = { TagSet: [
|
|||
] };
|
||||
|
||||
function _checkError(err, code, statusCode) {
|
||||
assert(err, 'Expected error but found none');
|
||||
assert.strictEqual(err.code, code);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(code);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
}
|
||||
|
||||
describe('DELETE object taggings', () => {
|
||||
|
@ -52,7 +52,7 @@ describe('DELETE object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should delete tag set', done => {
|
||||
test('should delete tag set', done => {
|
||||
s3.putObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -62,32 +62,34 @@ describe('DELETE object taggings', () => {
|
|||
s3.deleteObjectTagging({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
assert.ifError(err, `Found unexpected err ${err}`);
|
||||
assert.strictEqual(Object.keys(data).length, 0);
|
||||
expect(Object.keys(data).length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete a non-existing tag set', done => {
|
||||
test('should delete a non-existing tag set', done => {
|
||||
s3.deleteObjectTagging({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
assert.ifError(err, `Found unexpected err ${err}`);
|
||||
assert.strictEqual(Object.keys(data).length, 0);
|
||||
expect(Object.keys(data).length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return NoSuchKey deleting tag set to a non-existing object',
|
||||
done => {
|
||||
s3.deleteObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: 'nonexisting',
|
||||
}, err => {
|
||||
_checkError(err, 'NoSuchKey', 404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return 403 AccessDenied deleting tag set with another ' +
|
||||
test(
|
||||
'should return NoSuchKey deleting tag set to a non-existing object',
|
||||
done => {
|
||||
s3.deleteObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: 'nonexisting',
|
||||
}, err => {
|
||||
_checkError(err, 'NoSuchKey', 404);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
test('should return 403 AccessDenied deleting tag set with another ' +
|
||||
'account', done => {
|
||||
otherAccountS3.deleteObjectTagging({ Bucket: bucketName, Key:
|
||||
objectName }, err => {
|
||||
|
@ -96,9 +98,8 @@ describe('DELETE object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied deleting tag set with a different ' +
|
||||
'account to an object with ACL "public-read-write"',
|
||||
done => {
|
||||
test('should return 403 AccessDenied deleting tag set with a different ' +
|
||||
'account to an object with ACL "public-read-write"', done => {
|
||||
s3.putObjectAcl({ Bucket: bucketName, Key: objectName,
|
||||
ACL: 'public-read-write' }, err => {
|
||||
if (err) {
|
||||
|
@ -112,9 +113,8 @@ describe('DELETE object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied deleting tag set to an object' +
|
||||
' in a bucket created with a different account',
|
||||
done => {
|
||||
test('should return 403 AccessDenied deleting tag set to an object' +
|
||||
' in a bucket created with a different account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
'public-read-write' }, err => next(err)),
|
||||
|
@ -128,7 +128,7 @@ describe('DELETE object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should delete tag set to an object in a bucket created with same ' +
|
||||
test('should delete tag set to an object in a bucket created with same ' +
|
||||
'account even though object put by other account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('DELETE object', () => {
|
|||
const s3 = bucketUtil.s3;
|
||||
const testfile = Buffer.alloc(1024 * 1024 * 54, 0);
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
process.stdout.write('creating bucket\n');
|
||||
return s3.createBucketAsync({ Bucket: bucketName })
|
||||
.then(() => {
|
||||
|
@ -59,7 +59,7 @@ describe('DELETE object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucketName)
|
||||
.then(() => {
|
||||
|
@ -72,10 +72,9 @@ describe('DELETE object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should delete a object uploaded in parts successfully', done => {
|
||||
test('should delete a object uploaded in parts successfully', done => {
|
||||
s3.deleteObject({ Bucket: bucketName, Key: objectName }, err => {
|
||||
assert.strictEqual(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,17 +22,16 @@ const etag = `"${etagTrim}"`;
|
|||
const partSize = 1024 * 1024 * 5; // 5MB minumum required part size.
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
function checkError(err, code) {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, code);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(code);
|
||||
}
|
||||
|
||||
function checkContentLength(contentLengthHeader, expectedSize) {
|
||||
assert.strictEqual(Number.parseInt(contentLengthHeader, 10), expectedSize);
|
||||
expect(Number.parseInt(contentLengthHeader, 10)).toBe(expectedSize);
|
||||
}
|
||||
|
||||
function dateFromNow(diff) {
|
||||
|
@ -68,10 +67,7 @@ describe('GET object', () => {
|
|||
checkContentLength(data.ContentLength, len);
|
||||
const md5Hash = crypto.createHash('md5');
|
||||
const md5HashExpected = crypto.createHash('md5');
|
||||
assert.strictEqual(
|
||||
md5Hash.update(data.Body).digest('hex'),
|
||||
md5HashExpected.update(body).digest('hex')
|
||||
);
|
||||
expect(md5Hash.update(data.Body).digest('hex')).toBe(md5HashExpected.update(body).digest('hex'));
|
||||
return cb();
|
||||
});
|
||||
}
|
||||
|
@ -186,14 +182,14 @@ describe('GET object', () => {
|
|||
});
|
||||
}
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
// Create a bucket to put object to get later
|
||||
s3.createBucket({ Bucket: bucketName }, done);
|
||||
});
|
||||
|
||||
after(done => {
|
||||
afterAll(done => {
|
||||
s3.deleteObject({ Bucket: bucketName, Key: objectName }, err => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -203,30 +199,29 @@ describe('GET object', () => {
|
|||
});
|
||||
|
||||
|
||||
it('should return an error to get request without a valid bucket name',
|
||||
test(
|
||||
'should return an error to get request without a valid bucket name',
|
||||
done => {
|
||||
s3.getObject({ Bucket: '', Key: 'somekey' }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'MethodNotAllowed');
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('MethodNotAllowed');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return NoSuchKey error when no such object',
|
||||
done => {
|
||||
s3.getObject({ Bucket: bucketName, Key: 'nope' }, err => {
|
||||
assert.notEqual(err, null,
|
||||
'Expected failure but got success');
|
||||
assert.strictEqual(err.code, 'NoSuchKey');
|
||||
return done();
|
||||
});
|
||||
test('should return NoSuchKey error when no such object', done => {
|
||||
s3.getObject({ Bucket: bucketName, Key: 'nope' }, err => {
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Additional headers: [Cache-Control, Content-Disposition, ' +
|
||||
'Content-Encoding, Expires, Accept-Ranges]', () => {
|
||||
describe('if specified in put object request', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -238,36 +233,32 @@ describe('GET object', () => {
|
|||
};
|
||||
s3.putObject(params, err => done(err));
|
||||
});
|
||||
it('should return additional headers', done => {
|
||||
test('should return additional headers', done => {
|
||||
s3.getObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(res.CacheControl,
|
||||
cacheControl);
|
||||
assert.strictEqual(res.ContentDisposition,
|
||||
contentDisposition);
|
||||
expect(res.CacheControl).toBe(cacheControl);
|
||||
expect(res.ContentDisposition).toBe(contentDisposition);
|
||||
// Should remove V4 streaming value 'aws-chunked'
|
||||
// to be compatible with AWS behavior
|
||||
assert.strictEqual(res.ContentEncoding,
|
||||
'gzip');
|
||||
assert.strictEqual(res.ContentType, contentType);
|
||||
assert.strictEqual(res.Expires,
|
||||
new Date(expires).toGMTString());
|
||||
assert.strictEqual(res.AcceptRanges, 'bytes');
|
||||
expect(res.ContentEncoding).toBe('gzip');
|
||||
expect(res.ContentType).toBe(contentType);
|
||||
expect(res.Expires).toBe(new Date(expires).toGMTString());
|
||||
expect(res.AcceptRanges).toBe('bytes');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('if response content headers are set in query', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
s3.putObject({ Bucket: bucketName, Key: objectName },
|
||||
err => done(err));
|
||||
});
|
||||
|
||||
it('should return additional headers even if not set in ' +
|
||||
test('should return additional headers even if not set in ' +
|
||||
'put object request', done => {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
|
@ -283,16 +274,12 @@ describe('GET object', () => {
|
|||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(res.CacheControl,
|
||||
cacheControl);
|
||||
assert.strictEqual(res.ContentDisposition,
|
||||
contentDisposition);
|
||||
assert.strictEqual(res.ContentEncoding,
|
||||
contentEncoding);
|
||||
assert.strictEqual(res.ContentLanguage,
|
||||
contentLanguage);
|
||||
assert.strictEqual(res.ContentType, contentType);
|
||||
assert.strictEqual(res.Expires, expires);
|
||||
expect(res.CacheControl).toBe(cacheControl);
|
||||
expect(res.ContentDisposition).toBe(contentDisposition);
|
||||
expect(res.ContentEncoding).toBe(contentEncoding);
|
||||
expect(res.ContentLanguage).toBe(contentLanguage);
|
||||
expect(res.ContentType).toBe(contentType);
|
||||
expect(res.Expires).toBe(expires);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -300,7 +287,7 @@ describe('GET object', () => {
|
|||
});
|
||||
|
||||
describe('x-amz-website-redirect-location header', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -308,14 +295,14 @@ describe('GET object', () => {
|
|||
};
|
||||
s3.putObject(params, err => done(err));
|
||||
});
|
||||
it('should return website redirect header if specified in ' +
|
||||
test('should return website redirect header if specified in ' +
|
||||
'objectPUT request', done => {
|
||||
s3.getObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(res.WebsiteRedirectLocation, '/');
|
||||
expect(res.WebsiteRedirectLocation).toBe('/');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -342,14 +329,13 @@ describe('GET object', () => {
|
|||
s3.putObject(params, done);
|
||||
});
|
||||
|
||||
it('should not return "x-amz-tagging-count" if no tag ' +
|
||||
'associated with the object',
|
||||
done => {
|
||||
test('should not return "x-amz-tagging-count" if no tag ' +
|
||||
'associated with the object', done => {
|
||||
s3.getObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(data.TagCount, undefined);
|
||||
expect(data.TagCount).toBe(undefined);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -358,14 +344,13 @@ describe('GET object', () => {
|
|||
beforeEach(done => {
|
||||
s3.putObjectTagging(paramsTagging, done);
|
||||
});
|
||||
it('should return "x-amz-tagging-count" header that provides ' +
|
||||
'the count of number of tags associated with the object',
|
||||
done => {
|
||||
test('should return "x-amz-tagging-count" header that provides ' +
|
||||
'the count of number of tags associated with the object', done => {
|
||||
s3.getObject(params, (err, data) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.equal(data.TagCount, 1);
|
||||
expect(data.TagCount).toEqual(1);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
@ -377,177 +362,161 @@ describe('GET object', () => {
|
|||
beforeEach(done => {
|
||||
s3.putObject(params, done);
|
||||
});
|
||||
it('If-Match: returns no error when ETag match, with double ' +
|
||||
'quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfMatch: etag }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when ETag match, with double ' +
|
||||
'quotes around ETag', done => {
|
||||
requestGet({ IfMatch: etag }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when one of ETags match, with ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfMatch:
|
||||
`non-matching,${etag}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when one of ETags match, with ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestGet({ IfMatch:
|
||||
`non-matching,${etag}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when ETag match, without double ' +
|
||||
'quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfMatch: etagTrim }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when ETag match, without double ' +
|
||||
'quotes around ETag', done => {
|
||||
requestGet({ IfMatch: etagTrim }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when one of ETags match, without ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfMatch:
|
||||
`non-matching,${etagTrim}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when one of ETags match, without ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestGet({ IfMatch:
|
||||
`non-matching,${etagTrim}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when ETag match with *', done => {
|
||||
test('If-Match: returns no error when ETag match with *', done => {
|
||||
requestGet({ IfMatch: '*' }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns PreconditionFailed when ETag does not match',
|
||||
done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching ETag',
|
||||
}, err => {
|
||||
checkError(err, 'PreconditionFailed');
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns PreconditionFailed when ETag does not match', done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching ETag',
|
||||
}, err => {
|
||||
checkError(err, 'PreconditionFailed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns no error when ETag does not match',
|
||||
done => {
|
||||
test('If-None-Match: returns no error when ETag does not match', done => {
|
||||
requestGet({ IfNoneMatch: 'non-matching' }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns no error when all ETags do not match',
|
||||
done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching,' +
|
||||
'non-matching-either',
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns no error when all ETags do not match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching,' +
|
||||
'non-matching-either',
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when ETag match, with ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfNoneMatch: etag }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns NotModified when ETag match, with ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestGet({ IfNoneMatch: etag }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'with double quotes around ETag',
|
||||
done => {
|
||||
requestGet({
|
||||
IfNoneMatch: `non-matching,${etag}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'with double quotes around ETag', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: `non-matching,${etag}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when value is "*"',
|
||||
done => {
|
||||
requestGet({
|
||||
IfNoneMatch: '*',
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns NotModified when value is "*"', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: '*',
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when ETag match, without ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestGet({ IfNoneMatch: etagTrim }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns NotModified when ETag match, without ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestGet({ IfNoneMatch: etagTrim }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'without double quotes around ETag',
|
||||
done => {
|
||||
requestGet({
|
||||
IfNoneMatch: `non-matching,${etagTrim}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'without double quotes around ETag', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: `non-matching,${etagTrim}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Modified-Since: returns no error if Last modified date is ' +
|
||||
'greater',
|
||||
done => {
|
||||
requestGet({ IfModifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is lesser',
|
||||
done => {
|
||||
requestGet({ IfModifiedSince: dateFromNow(1) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is equal',
|
||||
done => {
|
||||
s3.headObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
checkNoError(err);
|
||||
const lastModified = dateConvert(data.LastModified);
|
||||
requestGet({ IfModifiedSince: lastModified }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns no error when lastModified date ' +
|
||||
'is greater',
|
||||
done => {
|
||||
requestGet({ IfUnmodifiedSince: dateFromNow(1) },
|
||||
test('If-Modified-Since: returns no error if Last modified date is ' +
|
||||
'greater', done => {
|
||||
requestGet({ IfModifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns no error when lastModified ' +
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
test.skip('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is lesser', done => {
|
||||
requestGet({ IfModifiedSince: dateFromNow(1) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is equal', done => {
|
||||
s3.headObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
checkNoError(err);
|
||||
const lastModified = dateConvert(data.LastModified);
|
||||
requestGet({ IfModifiedSince: lastModified }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('If-Unmodified-Since: returns no error when lastModified date ' +
|
||||
'is greater', done => {
|
||||
requestGet({ IfUnmodifiedSince: dateFromNow(1) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-Unmodified-Since: returns no error when lastModified ' +
|
||||
'date is equal', done => {
|
||||
s3.headObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
|
@ -561,29 +530,27 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns PreconditionFailed when ' +
|
||||
'lastModified date is lesser',
|
||||
done => {
|
||||
requestGet({ IfUnmodifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkError(err, 'PreconditionFailed');
|
||||
done();
|
||||
});
|
||||
test('If-Unmodified-Since: returns PreconditionFailed when ' +
|
||||
'lastModified date is lesser', done => {
|
||||
requestGet({ IfUnmodifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkError(err, 'PreconditionFailed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match & If-Unmodified-Since: returns no error when match ' +
|
||||
'Etag and lastModified is greater',
|
||||
done => {
|
||||
requestGet({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match & If-Unmodified-Since: returns no error when match ' +
|
||||
'Etag and lastModified is greater', done => {
|
||||
requestGet({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match match & If-Unmodified-Since match', done => {
|
||||
test('If-Match match & If-Unmodified-Since match', done => {
|
||||
requestGet({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -593,7 +560,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Unmodified-Since not match', done => {
|
||||
test('If-Match not match & If-Unmodified-Since not match', done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -603,7 +570,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Unmodified-Since match', done => {
|
||||
test('If-Match not match & If-Unmodified-Since match', done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -615,7 +582,7 @@ describe('GET object', () => {
|
|||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-Match match & If-Modified-Since not match', done => {
|
||||
test.skip('If-Match match & If-Modified-Since not match', done => {
|
||||
requestGet({
|
||||
IfMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -625,7 +592,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match match & If-Modified-Since match', done => {
|
||||
test('If-Match match & If-Modified-Since match', done => {
|
||||
requestGet({
|
||||
IfMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -635,7 +602,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Modified-Since not match', done => {
|
||||
test('If-Match not match & If-Modified-Since not match', done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -645,7 +612,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Modified-Since match', done => {
|
||||
test('If-Match not match & If-Modified-Since match', done => {
|
||||
requestGet({
|
||||
IfMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -655,20 +622,18 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match & If-Modified-Since: returns NotModified when ' +
|
||||
'Etag does not match and lastModified is greater',
|
||||
done => {
|
||||
requestGet({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match & If-Modified-Since: returns NotModified when ' +
|
||||
'Etag does not match and lastModified is greater', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Modified-Since not match',
|
||||
done => {
|
||||
test('If-None-Match not match & If-Modified-Since not match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -678,7 +643,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Modified-Since match', done => {
|
||||
test('If-None-Match match & If-Modified-Since match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -690,8 +655,7 @@ describe('GET object', () => {
|
|||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-None-Match match & If-Modified-Since not match',
|
||||
done => {
|
||||
test.skip('If-None-Match match & If-Modified-Since not match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -701,7 +665,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Unmodified-Since match', done => {
|
||||
test('If-None-Match match & If-Unmodified-Since match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -711,7 +675,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Unmodified-Since not match', done => {
|
||||
test('If-None-Match match & If-Unmodified-Since not match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -721,7 +685,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Unmodified-Since match', done => {
|
||||
test('If-None-Match not match & If-Unmodified-Since match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -731,8 +695,7 @@ describe('GET object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Unmodified-Since not match',
|
||||
done => {
|
||||
test('If-None-Match not match & If-Unmodified-Since not match', done => {
|
||||
requestGet({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -749,7 +712,8 @@ describe('GET object', () => {
|
|||
const invalidPartNumbers = [-1, 0, 10001];
|
||||
|
||||
orderedPartNumbers.forEach(num =>
|
||||
it(`should get the body of part ${num} when ordered MPU`,
|
||||
test(
|
||||
`should get the body of part ${num} when ordered MPU`,
|
||||
done => completeMPU(orderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
return requestGet({ PartNumber: num }, (err, data) => {
|
||||
|
@ -758,17 +722,16 @@ describe('GET object', () => {
|
|||
const md5Hash = crypto.createHash('md5');
|
||||
const md5HashExpected = crypto.createHash('md5');
|
||||
const expected = Buffer.alloc(partSize).fill(num);
|
||||
assert.strictEqual(
|
||||
md5Hash.update(data.Body).digest('hex'),
|
||||
md5HashExpected.update(expected).digest('hex')
|
||||
);
|
||||
expect(md5Hash.update(data.Body).digest('hex')).toBe(md5HashExpected.update(expected).digest('hex'));
|
||||
return done();
|
||||
});
|
||||
})));
|
||||
})
|
||||
));
|
||||
|
||||
// Use the orderedPartNumbers to retrieve parts with GetObject.
|
||||
orderedPartNumbers.forEach(num =>
|
||||
it(`should get the body of part ${num} when unordered MPU`,
|
||||
test(
|
||||
`should get the body of part ${num} when unordered MPU`,
|
||||
done => completeMPU(unOrderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
return requestGet({ PartNumber: num }, (err, data) => {
|
||||
|
@ -778,25 +741,25 @@ describe('GET object', () => {
|
|||
const md5HashExpected = crypto.createHash('md5');
|
||||
const expected = Buffer.alloc(partSize)
|
||||
.fill(unOrderedPartNumbers[num - 1]);
|
||||
assert.strictEqual(
|
||||
md5Hash.update(data.Body).digest('hex'),
|
||||
md5HashExpected.update(expected).digest('hex')
|
||||
);
|
||||
expect(md5Hash.update(data.Body).digest('hex')).toBe(md5HashExpected.update(expected).digest('hex'));
|
||||
return done();
|
||||
});
|
||||
})));
|
||||
})
|
||||
));
|
||||
|
||||
invalidPartNumbers.forEach(num =>
|
||||
it(`should not accept a partNumber that is not 1-10000: ${num}`,
|
||||
done => completeMPU(orderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
return requestGet({ PartNumber: num }, err => {
|
||||
checkError(err, 'InvalidArgument');
|
||||
done();
|
||||
});
|
||||
})));
|
||||
test(
|
||||
`should not accept a partNumber that is not 1-10000: ${num}`,
|
||||
done => completeMPU(orderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
return requestGet({ PartNumber: num }, err => {
|
||||
checkError(err, 'InvalidArgument');
|
||||
done();
|
||||
});
|
||||
})
|
||||
));
|
||||
|
||||
it('should not accept a part number greater than the total parts ' +
|
||||
test('should not accept a part number greater than the total parts ' +
|
||||
'uploaded for an MPU', done =>
|
||||
completeMPU(orderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
|
@ -806,7 +769,8 @@ describe('GET object', () => {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should accept a part number of 1 for regular put object',
|
||||
test(
|
||||
'should accept a part number of 1 for regular put object',
|
||||
done => s3.putObject({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -817,15 +781,13 @@ describe('GET object', () => {
|
|||
const md5Hash = crypto.createHash('md5');
|
||||
const md5HashExpected = crypto.createHash('md5');
|
||||
const expected = Buffer.alloc(10);
|
||||
assert.strictEqual(
|
||||
md5Hash.update(data.Body).digest('hex'),
|
||||
md5HashExpected.update(expected).digest('hex')
|
||||
);
|
||||
expect(md5Hash.update(data.Body).digest('hex')).toBe(md5HashExpected.update(expected).digest('hex'));
|
||||
done();
|
||||
});
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
it('should accept a part number that is a string', done =>
|
||||
test('should accept a part number that is a string', done =>
|
||||
s3.putObject({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -837,15 +799,12 @@ describe('GET object', () => {
|
|||
const md5Hash = crypto.createHash('md5');
|
||||
const md5HashExpected = crypto.createHash('md5');
|
||||
const expected = Buffer.alloc(10);
|
||||
assert.strictEqual(
|
||||
md5Hash.update(data.Body).digest('hex'),
|
||||
md5HashExpected.update(expected).digest('hex')
|
||||
);
|
||||
expect(md5Hash.update(data.Body).digest('hex')).toBe(md5HashExpected.update(expected).digest('hex'));
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not accept a part number greater than 1 for regular ' +
|
||||
test('should not accept a part number greater than 1 for regular ' +
|
||||
'put object', done =>
|
||||
s3.putObject({
|
||||
Bucket: bucketName,
|
||||
|
@ -859,7 +818,7 @@ describe('GET object', () => {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should not accept both PartNumber and Range as params', done =>
|
||||
test('should not accept both PartNumber and Range as params', done =>
|
||||
completeMPU(orderedPartNumbers, err => {
|
||||
checkNoError(err);
|
||||
return requestGet({
|
||||
|
@ -907,13 +866,15 @@ describe('GET object', () => {
|
|||
Key: copyPartKey,
|
||||
}, done));
|
||||
|
||||
it('should retrieve a part copied from an MPU', done =>
|
||||
test('should retrieve a part copied from an MPU', done =>
|
||||
checkGetObjectPart(copyPartKey, 1, partOneSize, partOneBody,
|
||||
done));
|
||||
|
||||
it('should retrieve a part put after part copied from MPU',
|
||||
test(
|
||||
'should retrieve a part put after part copied from MPU',
|
||||
done => checkGetObjectPart(copyPartKey, 2, partSize,
|
||||
partTwoBody, done));
|
||||
partTwoBody, done)
|
||||
);
|
||||
});
|
||||
|
||||
describe('uploadPartCopy overwrite', () => {
|
||||
|
@ -980,35 +941,33 @@ describe('GET object', () => {
|
|||
Key: copyPartKey,
|
||||
}, done));
|
||||
|
||||
it('should retrieve a part that overwrote another part ' +
|
||||
test('should retrieve a part that overwrote another part ' +
|
||||
'originally copied from an MPU', done =>
|
||||
checkGetObjectPart(copyPartKey, 1, partSize, partOneBody,
|
||||
done));
|
||||
|
||||
it('should retrieve a part copied from an MPU after the ' +
|
||||
'original part was overwritten',
|
||||
done => checkGetObjectPart(copyPartKey, 2, partTwoSize,
|
||||
partTwoBody, done));
|
||||
test('should retrieve a part copied from an MPU after the ' +
|
||||
'original part was overwritten', done => checkGetObjectPart(copyPartKey, 2, partTwoSize,
|
||||
partTwoBody, done));
|
||||
});
|
||||
});
|
||||
|
||||
describe('absent x-amz-website-redirect-location header', () => {
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
};
|
||||
s3.putObject(params, err => done(err));
|
||||
});
|
||||
it('should return website redirect header if specified in ' +
|
||||
test('should return website redirect header if specified in ' +
|
||||
'objectPUT request', done => {
|
||||
s3.getObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(res.WebsiteRedirectLocation,
|
||||
undefined);
|
||||
expect(res.WebsiteRedirectLocation).toBe(undefined);
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('GET multipart upload object [Cache-Control, Content-Disposition, ' +
|
|||
// a UNIX timestamp for Expires header
|
||||
const expires = new Date();
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -58,7 +58,7 @@ describe('GET multipart upload object [Cache-Control, Content-Disposition, ' +
|
|||
throw err;
|
||||
});
|
||||
});
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('Emptying bucket\n');
|
||||
return bucketUtil.empty(bucketName)
|
||||
.then(() => {
|
||||
|
@ -70,9 +70,8 @@ describe('GET multipart upload object [Cache-Control, Content-Disposition, ' +
|
|||
throw err;
|
||||
});
|
||||
});
|
||||
it('should return additional headers when get request is performed ' +
|
||||
'on MPU, when they are specified in creation of MPU',
|
||||
() => {
|
||||
test('should return additional headers when get request is performed ' +
|
||||
'on MPU, when they are specified in creation of MPU', () => {
|
||||
const params = { Bucket: bucketName, Key: 'key', PartNumber: 1,
|
||||
UploadId: uploadId };
|
||||
return s3.uploadPartAsync(params)
|
||||
|
@ -108,10 +107,10 @@ describe('GET multipart upload object [Cache-Control, Content-Disposition, ' +
|
|||
throw err;
|
||||
})
|
||||
.then(res => {
|
||||
assert.strictEqual(res.CacheControl, cacheControl);
|
||||
assert.strictEqual(res.ContentDisposition, contentDisposition);
|
||||
assert.strictEqual(res.ContentEncoding, 'gzip');
|
||||
assert.strictEqual(res.Expires, expires.toGMTString());
|
||||
expect(res.CacheControl).toBe(cacheControl);
|
||||
expect(res.ContentDisposition).toBe(contentDisposition);
|
||||
expect(res.ContentEncoding).toBe('gzip');
|
||||
expect(res.Expires).toBe(expires.toGMTString());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,9 +20,9 @@ const taggingConfig = { TagSet: [
|
|||
] };
|
||||
|
||||
function _checkError(err, code, statusCode) {
|
||||
assert(err, 'Expected error but found none');
|
||||
assert.strictEqual(err.code, code);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(code);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
}
|
||||
|
||||
describe('GET object taggings', () => {
|
||||
|
@ -54,7 +54,7 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return appropriate tags after putting tags', done => {
|
||||
test('should return appropriate tags after putting tags', done => {
|
||||
s3.putObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -70,7 +70,7 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return no tag after putting and deleting tags', done => {
|
||||
test('should return no tag after putting and deleting tags', done => {
|
||||
async.waterfall([
|
||||
next => s3.putObjectTagging({
|
||||
Bucket: bucketName,
|
||||
|
@ -88,7 +88,7 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return empty array after putting no tag', done => {
|
||||
test('should return empty array after putting no tag', done => {
|
||||
s3.getObjectTagging({ Bucket: bucketName, Key: objectName },
|
||||
(err, data) => {
|
||||
assert.ifError(err, `getObjectTagging error: ${err}`);
|
||||
|
@ -97,8 +97,7 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return NoSuchKey getting tag to a non-existing object',
|
||||
done => {
|
||||
test('should return NoSuchKey getting tag to a non-existing object', done => {
|
||||
s3.getObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: 'nonexisting',
|
||||
|
@ -108,18 +107,19 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied getting tag with another account',
|
||||
done => {
|
||||
otherAccountS3.getObjectTagging({ Bucket: bucketName, Key:
|
||||
objectName }, err => {
|
||||
_checkError(err, 'AccessDenied', 403);
|
||||
done();
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should return 403 AccessDenied getting tag with another account',
|
||||
done => {
|
||||
otherAccountS3.getObjectTagging({ Bucket: bucketName, Key:
|
||||
objectName }, err => {
|
||||
_checkError(err, 'AccessDenied', 403);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return 403 AccessDenied getting tag with a different ' +
|
||||
'account to an object with ACL "public-read-write"',
|
||||
done => {
|
||||
test('should return 403 AccessDenied getting tag with a different ' +
|
||||
'account to an object with ACL "public-read-write"', done => {
|
||||
s3.putObjectAcl({ Bucket: bucketName, Key: objectName,
|
||||
ACL: 'public-read-write' }, err => {
|
||||
if (err) {
|
||||
|
@ -133,9 +133,8 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied getting tag to an object ' +
|
||||
'in a bucket created with a different account',
|
||||
done => {
|
||||
test('should return 403 AccessDenied getting tag to an object ' +
|
||||
'in a bucket created with a different account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
'public-read-write' }, err => next(err)),
|
||||
|
@ -149,7 +148,7 @@ describe('GET object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should get tag to an object in a bucket created with same ' +
|
||||
test('should get tag to an object in a bucket created with same ' +
|
||||
'account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
|
|
|
@ -14,8 +14,8 @@ const endRangeTest = (inputRange, expectedRange, cb) => {
|
|||
};
|
||||
|
||||
s3.getObject(params, (err, data) => {
|
||||
assert.strictEqual(data.ContentLength, '90');
|
||||
assert.strictEqual(data.ContentRange, expectedRange);
|
||||
expect(data.ContentLength).toBe('90');
|
||||
expect(data.ContentRange).toBe(expectedRange);
|
||||
assert.deepStrictEqual(data.Body, Buffer.allocUnsafe(90).fill(1));
|
||||
cb();
|
||||
});
|
||||
|
@ -58,15 +58,11 @@ describe('aws-node-sdk range test of large end position', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should get the final 90 bytes of a 2890 byte object for a byte ' +
|
||||
'range of 2800-',
|
||||
done => endRangeTest('bytes=2800-', 'bytes 2800-2889/2890', done)
|
||||
);
|
||||
test('should get the final 90 bytes of a 2890 byte object for a byte ' +
|
||||
'range of 2800-', done => endRangeTest('bytes=2800-', 'bytes 2800-2889/2890', done));
|
||||
|
||||
it('should get the final 90 bytes of a 2890 byte object for a byte ' +
|
||||
'range of 2800-Number.MAX_SAFE_INTEGER',
|
||||
done => endRangeTest(`bytes=2800-${Number.MAX_SAFE_INTEGER}`,
|
||||
'bytes 2800-2889/2890', done)
|
||||
);
|
||||
test('should get the final 90 bytes of a 2890 byte object for a byte ' +
|
||||
'range of 2800-Number.MAX_SAFE_INTEGER', done => endRangeTest(`bytes=2800-${Number.MAX_SAFE_INTEGER}`,
|
||||
'bytes 2800-2889/2890', done));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,44 +26,46 @@ describe('Initiate MPU', () => {
|
|||
|
||||
afterEach(() => bucketUtil.deleteOne(bucket));
|
||||
|
||||
it('should return InvalidRedirectLocation if initiate MPU ' +
|
||||
test('should return InvalidRedirectLocation if initiate MPU ' +
|
||||
'with x-amz-website-redirect-location header that does not start ' +
|
||||
'with \'http://\', \'https://\' or \'/\'', done => {
|
||||
const params = { Bucket: bucket, Key: key,
|
||||
WebsiteRedirectLocation: 'google.com' };
|
||||
s3.createMultipartUpload(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRedirectLocation');
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
expect(err.code).toBe('InvalidRedirectLocation');
|
||||
expect(err.statusCode).toBe(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error if initiating MPU w/ > 2KB user-defined md',
|
||||
done => {
|
||||
const metadata = genMaxSizeMetaHeaders();
|
||||
const params = { Bucket: bucket, Key: key, Metadata: metadata };
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, data) => {
|
||||
assert.strictEqual(err, null, `Unexpected err: ${err}`);
|
||||
next(null, data.UploadId);
|
||||
}),
|
||||
(uploadId, next) => s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
UploadId: uploadId,
|
||||
}, err => {
|
||||
assert.strictEqual(err, null, `Unexpected err: ${err}`);
|
||||
// add one more byte to push over limit for next call
|
||||
metadata.header0 = `${metadata.header0}${'0'}`;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(params, next),
|
||||
], err => {
|
||||
assert(err, 'Expected err but did not find one');
|
||||
assert.strictEqual(err.code, 'MetadataTooLarge');
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should return error if initiating MPU w/ > 2KB user-defined md',
|
||||
done => {
|
||||
const metadata = genMaxSizeMetaHeaders();
|
||||
const params = { Bucket: bucket, Key: key, Metadata: metadata };
|
||||
async.waterfall([
|
||||
next => s3.createMultipartUpload(params, (err, data) => {
|
||||
expect(err).toBe(null);
|
||||
next(null, data.UploadId);
|
||||
}),
|
||||
(uploadId, next) => s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
UploadId: uploadId,
|
||||
}, err => {
|
||||
expect(err).toBe(null);
|
||||
// add one more byte to push over limit for next call
|
||||
metadata.header0 = `${metadata.header0}${'0'}`;
|
||||
next();
|
||||
}),
|
||||
next => s3.createMultipartUpload(params, next),
|
||||
], err => {
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('MetadataTooLarge');
|
||||
expect(err.statusCode).toBe(400);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,8 +9,7 @@ const bodyFirstPart = Buffer.allocUnsafe(10).fill(0);
|
|||
const bodySecondPart = Buffer.allocUnsafe(20).fill(0);
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
describe('List parts', () => {
|
||||
|
@ -58,7 +57,7 @@ describe('List parts', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should only list the second part', done => {
|
||||
test('should only list the second part', done => {
|
||||
s3.listParts({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
|
@ -66,9 +65,9 @@ describe('List parts', () => {
|
|||
UploadId: uploadId },
|
||||
(err, data) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(data.Parts[0].PartNumber, 2);
|
||||
assert.strictEqual(data.Parts[0].Size, 20);
|
||||
assert.strictEqual(`${data.Parts[0].ETag}`, secondEtag);
|
||||
expect(data.Parts[0].PartNumber).toBe(2);
|
||||
expect(data.Parts[0].Size).toBe(20);
|
||||
expect(`${data.Parts[0].ETag}`).toBe(secondEtag);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -111,7 +110,7 @@ function test(s3, bucket, key, uploadId, cb) {
|
|||
UploadId: uploadId },
|
||||
(err, data) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(data.Key, key);
|
||||
expect(data.Key).toBe(key);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
@ -128,13 +127,14 @@ describe('List parts - object keys with special characters: `&`', () => {
|
|||
.then(res => {
|
||||
uploadId = res;
|
||||
return Promise.resolve();
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => deletePart(s3, bucketUtil, key, uploadId));
|
||||
|
||||
it('should list parts of an object with `&` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done));
|
||||
test(
|
||||
'should list parts of an object with `&` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -150,13 +150,14 @@ describe('List parts - object keys with special characters: `"`', () => {
|
|||
.then(res => {
|
||||
uploadId = res;
|
||||
return Promise.resolve();
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => deletePart(s3, bucketUtil, key, uploadId));
|
||||
|
||||
it('should list parts of an object with `"` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done));
|
||||
test(
|
||||
'should list parts of an object with `"` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -172,13 +173,14 @@ describe('List parts - object keys with special characters: `\'`', () => {
|
|||
.then(res => {
|
||||
uploadId = res;
|
||||
return Promise.resolve();
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => deletePart(s3, bucketUtil, key, uploadId));
|
||||
|
||||
it('should list parts of an object with `\'` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done));
|
||||
test(
|
||||
'should list parts of an object with `\'` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -194,13 +196,14 @@ describe('List parts - object keys with special characters: `<`', () => {
|
|||
.then(res => {
|
||||
uploadId = res;
|
||||
return Promise.resolve();
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => deletePart(s3, bucketUtil, key, uploadId));
|
||||
|
||||
it('should list parts of an object with `<` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done));
|
||||
test(
|
||||
'should list parts of an object with `<` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -216,12 +219,13 @@ describe('List parts - object keys with special characters: `>`', () => {
|
|||
.then(res => {
|
||||
uploadId = res;
|
||||
return Promise.resolve();
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
||||
afterEach(() => deletePart(s3, bucketUtil, key, uploadId));
|
||||
|
||||
it('should list parts of an object with `>` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done));
|
||||
test(
|
||||
'should list parts of an object with `>` in its key',
|
||||
done => test(s3, bucket, key, uploadId, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -108,15 +108,13 @@ describe('aws-node-sdk test suite of listMultipartUploads', () =>
|
|||
UploadId: data.uploadId,
|
||||
})
|
||||
.then(() => bucketUtil.empty(bucket))
|
||||
.then(() => bucketUtil.deleteOne(bucket))
|
||||
);
|
||||
.then(() => bucketUtil.deleteOne(bucket)));
|
||||
|
||||
it('should list ongoing multipart uploads', () =>
|
||||
test('should list ongoing multipart uploads', () =>
|
||||
s3.listMultipartUploadsAsync({ Bucket: bucket })
|
||||
.then(res => checkValues(res, data))
|
||||
);
|
||||
.then(res => checkValues(res, data)));
|
||||
|
||||
it('should list ongoing multipart uploads with params', () => {
|
||||
test('should list ongoing multipart uploads with params', () => {
|
||||
data.prefixVal = 'to';
|
||||
data.delimiter = 'test-delimiter';
|
||||
data.maxUploads = 1;
|
||||
|
@ -130,7 +128,7 @@ describe('aws-node-sdk test suite of listMultipartUploads', () =>
|
|||
.then(res => checkValues(res, data));
|
||||
});
|
||||
|
||||
it('should list 0 multipart uploads when MaxUploads is 0', () => {
|
||||
test('should list 0 multipart uploads when MaxUploads is 0', () => {
|
||||
data.maxUploads = 0;
|
||||
|
||||
return s3.listMultipartUploadsAsync({
|
||||
|
|
|
@ -8,13 +8,12 @@ const bucket = 'bucketlistparts';
|
|||
const object = 'toto';
|
||||
|
||||
function checkError(err, statusCode, code) {
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
assert.strictEqual(err.code, code);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
expect(err.code).toBe(code);
|
||||
}
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
const body = Buffer.alloc(1024 * 1024 * 5, 'a');
|
||||
|
@ -30,11 +29,17 @@ const testsOrder = [
|
|||
];
|
||||
|
||||
describe('More MPU tests', () => {
|
||||
let testContext;
|
||||
|
||||
beforeEach(() => {
|
||||
testContext = {};
|
||||
});
|
||||
|
||||
withV4(sigCfg => {
|
||||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
beforeEach(function beforeEachF(done) {
|
||||
beforeEach(done => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
async.waterfall([
|
||||
|
@ -42,7 +47,7 @@ describe('More MPU tests', () => {
|
|||
next => s3.createMultipartUpload({ Bucket: bucket,
|
||||
Key: object }, (err, data) => {
|
||||
checkNoError(err);
|
||||
this.currentTest.UploadId = data.UploadId;
|
||||
testContext.currentTest.UploadId = data.UploadId;
|
||||
return next();
|
||||
}),
|
||||
next => s3.uploadPart({
|
||||
|
@ -50,9 +55,9 @@ describe('More MPU tests', () => {
|
|||
Key: object,
|
||||
PartNumber: 1000,
|
||||
Body: body,
|
||||
UploadId: this.currentTest.UploadId }, (err, data) => {
|
||||
UploadId: testContext.currentTest.UploadId }, (err, data) => {
|
||||
checkNoError(err);
|
||||
this.currentTest.Etag = data.ETag;
|
||||
testContext.currentTest.Etag = data.ETag;
|
||||
return next();
|
||||
}),
|
||||
next => s3.uploadPart({
|
||||
|
@ -60,13 +65,13 @@ describe('More MPU tests', () => {
|
|||
Key: object,
|
||||
PartNumber: 3,
|
||||
Body: body,
|
||||
UploadId: this.currentTest.UploadId }, err => next(err)),
|
||||
UploadId: testContext.currentTest.UploadId }, err => next(err)),
|
||||
next => s3.uploadPart({
|
||||
Bucket: bucket,
|
||||
Key: object,
|
||||
PartNumber: 8,
|
||||
Body: body,
|
||||
UploadId: this.currentTest.UploadId }, err => next(err)),
|
||||
UploadId: testContext.currentTest.UploadId }, err => next(err)),
|
||||
], done);
|
||||
});
|
||||
|
||||
|
@ -78,8 +83,8 @@ describe('More MPU tests', () => {
|
|||
], done);
|
||||
});
|
||||
testsOrder.forEach(testOrder => {
|
||||
it('should complete MPU by concatenating the parts in ' +
|
||||
`the following order: ${testOrder.values}`, function itF(done) {
|
||||
test('should complete MPU by concatenating the parts in ' +
|
||||
`the following order: ${testOrder.values}`, done => {
|
||||
async.waterfall([
|
||||
next => s3.completeMultipartUpload({
|
||||
Bucket: bucket,
|
||||
|
@ -87,27 +92,27 @@ describe('More MPU tests', () => {
|
|||
MultipartUpload: {
|
||||
Parts: [
|
||||
{
|
||||
ETag: this.test.Etag,
|
||||
ETag: testContext.test.Etag,
|
||||
PartNumber: testOrder.values[0],
|
||||
},
|
||||
{
|
||||
ETag: this.test.Etag,
|
||||
ETag: testContext.test.Etag,
|
||||
PartNumber: testOrder.values[1],
|
||||
},
|
||||
{
|
||||
ETag: this.test.Etag,
|
||||
ETag: testContext.test.Etag,
|
||||
PartNumber: testOrder.values[2],
|
||||
},
|
||||
],
|
||||
},
|
||||
UploadId: this.test.UploadId }, next),
|
||||
UploadId: testContext.test.UploadId }, next),
|
||||
], err => {
|
||||
if (testOrder.err) {
|
||||
checkError(err, 400, 'InvalidPartOrder');
|
||||
return s3.abortMultipartUpload({
|
||||
Bucket: bucket,
|
||||
Key: object,
|
||||
UploadId: this.test.UploadId,
|
||||
UploadId: testContext.test.UploadId,
|
||||
}, done);
|
||||
}
|
||||
checkNoError(err);
|
||||
|
|
|
@ -11,13 +11,12 @@ const bucketName = 'multi-object-delete-234-634';
|
|||
const key = 'key';
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
function checkError(err, code) {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, code);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(code);
|
||||
}
|
||||
|
||||
function sortList(list) {
|
||||
|
@ -42,7 +41,7 @@ function createObjectsList(size) {
|
|||
return objects;
|
||||
}
|
||||
|
||||
describe('Multi-Object Delete Success', function success() {
|
||||
describe('Multi-Object Delete Success', () => {
|
||||
this.timeout(360000);
|
||||
let bucketUtil;
|
||||
let s3;
|
||||
|
@ -85,7 +84,7 @@ describe('Multi-Object Delete Success', function success() {
|
|||
|
||||
afterEach(() => s3.deleteBucketAsync({ Bucket: bucketName }));
|
||||
|
||||
it('should batch delete 1000 objects', () => {
|
||||
test('should batch delete 1000 objects', () => {
|
||||
const objects = createObjectsList(1000);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
|
@ -94,16 +93,16 @@ describe('Multi-Object Delete Success', function success() {
|
|||
Quiet: false,
|
||||
},
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Deleted.length, 1000);
|
||||
expect(res.Deleted.length).toBe(1000);
|
||||
// order of returned objects not sorted
|
||||
assert.deepStrictEqual(sortList(res.Deleted), sortList(objects));
|
||||
assert.strictEqual(res.Errors.length, 0);
|
||||
expect(res.Errors.length).toBe(0);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should batch delete 1000 objects quietly', () => {
|
||||
test('should batch delete 1000 objects quietly', () => {
|
||||
const objects = createObjectsList(1000);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
|
@ -112,8 +111,8 @@ describe('Multi-Object Delete Success', function success() {
|
|||
Quiet: true,
|
||||
},
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Deleted.length, 0);
|
||||
assert.strictEqual(res.Errors.length, 0);
|
||||
expect(res.Deleted.length).toBe(0);
|
||||
expect(res.Errors.length).toBe(0);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
|
@ -137,7 +136,8 @@ describe('Multi-Object Delete Error Responses', () => {
|
|||
|
||||
afterEach(() => s3.deleteBucketAsync({ Bucket: bucketName }));
|
||||
|
||||
it('should return error if request deletion of more than 1000 objects',
|
||||
test(
|
||||
'should return error if request deletion of more than 1000 objects',
|
||||
() => {
|
||||
const objects = createObjectsList(1001);
|
||||
return s3.deleteObjectsAsync({
|
||||
|
@ -148,38 +148,37 @@ describe('Multi-Object Delete Error Responses', () => {
|
|||
}).catch(err => {
|
||||
checkError(err, 'MalformedXML');
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return error if request deletion of 0 objects',
|
||||
() => {
|
||||
const objects = createObjectsList(0);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
Delete: {
|
||||
Objects: objects,
|
||||
},
|
||||
}).catch(err => {
|
||||
checkError(err, 'MalformedXML');
|
||||
});
|
||||
test('should return error if request deletion of 0 objects', () => {
|
||||
const objects = createObjectsList(0);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
Delete: {
|
||||
Objects: objects,
|
||||
},
|
||||
}).catch(err => {
|
||||
checkError(err, 'MalformedXML');
|
||||
});
|
||||
});
|
||||
|
||||
it('should return no error if try to delete non-existent objects',
|
||||
() => {
|
||||
const objects = createObjectsList(1000);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
Delete: {
|
||||
Objects: objects,
|
||||
},
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Deleted.length, 1000);
|
||||
assert.strictEqual(res.Errors.length, 0);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
test('should return no error if try to delete non-existent objects', () => {
|
||||
const objects = createObjectsList(1000);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
Delete: {
|
||||
Objects: objects,
|
||||
},
|
||||
}).then(res => {
|
||||
expect(res.Deleted.length).toBe(1000);
|
||||
expect(res.Errors.length).toBe(0);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error if no such bucket', () => {
|
||||
test('should return error if no such bucket', () => {
|
||||
const objects = createObjectsList(1);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: 'nosuchbucket2323292093',
|
||||
|
@ -193,12 +192,12 @@ describe('Multi-Object Delete Error Responses', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Multi-Object Delete Access', function access() {
|
||||
describe('Multi-Object Delete Access', () => {
|
||||
this.timeout(360000);
|
||||
let bucketUtil;
|
||||
let s3;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
const createObjects = [];
|
||||
bucketUtil = new BucketUtility('default', {
|
||||
signatureVersion: 'v4',
|
||||
|
@ -225,9 +224,9 @@ describe('Multi-Object Delete Access', function access() {
|
|||
});
|
||||
});
|
||||
|
||||
after(() => s3.deleteBucketAsync({ Bucket: bucketName }));
|
||||
afterAll(() => s3.deleteBucketAsync({ Bucket: bucketName }));
|
||||
|
||||
it('should return access denied error for each object where no acl ' +
|
||||
test('should return access denied error for each object where no acl ' +
|
||||
'permission', () => {
|
||||
const objects = createObjectsList(500);
|
||||
const errorList = createObjectsList(500);
|
||||
|
@ -243,16 +242,16 @@ describe('Multi-Object Delete Access', function access() {
|
|||
Quiet: false,
|
||||
},
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Deleted.length, 0);
|
||||
expect(res.Deleted.length).toBe(0);
|
||||
assert.deepStrictEqual(sortList(res.Errors), sortList(errorList));
|
||||
assert.strictEqual(res.Errors.length, 500);
|
||||
expect(res.Errors.length).toBe(500);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should batch delete objects where requester has permission', () => {
|
||||
test('should batch delete objects where requester has permission', () => {
|
||||
const objects = createObjectsList(500);
|
||||
return s3.deleteObjectsAsync({
|
||||
Bucket: bucketName,
|
||||
|
@ -261,8 +260,8 @@ describe('Multi-Object Delete Access', function access() {
|
|||
Quiet: false,
|
||||
},
|
||||
}).then(res => {
|
||||
assert.strictEqual(res.Deleted.length, 500);
|
||||
assert.strictEqual(res.Errors.length, 0);
|
||||
expect(res.Deleted.length).toBe(500);
|
||||
expect(res.Errors.length).toBe(0);
|
||||
}).catch(err => {
|
||||
checkNoError(err);
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,13 +9,12 @@ const bucketName = 'alexbucketnottaken';
|
|||
const objectName = 'someObject';
|
||||
|
||||
function checkNoError(err) {
|
||||
assert.equal(err, null,
|
||||
`Expected success, got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
}
|
||||
|
||||
function checkError(err, code) {
|
||||
assert.notEqual(err, null, 'Expected failure but got success');
|
||||
assert.strictEqual(err.code, code);
|
||||
expect(err).not.toEqual(null);
|
||||
expect(err.code).toBe(code);
|
||||
}
|
||||
|
||||
function dateFromNow(diff) {
|
||||
|
@ -36,7 +35,7 @@ describe('HEAD object, conditions', () => {
|
|||
let etagTrim;
|
||||
let lastModified;
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
return bucketUtil.empty(bucketName).then(() =>
|
||||
|
@ -72,189 +71,172 @@ describe('HEAD object, conditions', () => {
|
|||
|
||||
afterEach(() => bucketUtil.empty(bucketName));
|
||||
|
||||
after(() => bucketUtil.deleteOne(bucketName));
|
||||
afterAll(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
it('If-Match: returns no error when ETag match, with double quotes ' +
|
||||
'around ETag',
|
||||
done => {
|
||||
requestHead({ IfMatch: etag }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when ETag match, with double quotes ' +
|
||||
'around ETag', done => {
|
||||
requestHead({ IfMatch: etag }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when one of ETags match, with double ' +
|
||||
'quotes around ETag',
|
||||
done => {
|
||||
requestHead({ IfMatch: `non-matching,${etag}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when one of ETags match, with double ' +
|
||||
'quotes around ETag', done => {
|
||||
requestHead({ IfMatch: `non-matching,${etag}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when ETag match, without double ' +
|
||||
'quotes around ETag',
|
||||
done => {
|
||||
requestHead({ IfMatch: etagTrim }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when ETag match, without double ' +
|
||||
'quotes around ETag', done => {
|
||||
requestHead({ IfMatch: etagTrim }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when one of ETags match, without ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestHead({ IfMatch: `non-matching,${etagTrim}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns no error when one of ETags match, without ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestHead({ IfMatch: `non-matching,${etagTrim}` }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns no error when ETag match with *', done => {
|
||||
test('If-Match: returns no error when ETag match with *', done => {
|
||||
requestHead({ IfMatch: '*' }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match: returns PreconditionFailed when ETag does not match',
|
||||
done => {
|
||||
requestHead({ IfMatch: 'non-matching ETag' }, err => {
|
||||
checkError(err, errors.PreconditionFailed.code);
|
||||
done();
|
||||
});
|
||||
test('If-Match: returns PreconditionFailed when ETag does not match', done => {
|
||||
requestHead({ IfMatch: 'non-matching ETag' }, err => {
|
||||
checkError(err, errors.PreconditionFailed.code);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns no error when ETag does not match', done => {
|
||||
test('If-None-Match: returns no error when ETag does not match', done => {
|
||||
requestHead({ IfNoneMatch: 'non-matching' }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns no error when all ETags do not match',
|
||||
done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching,non-matching-either',
|
||||
}, err => {
|
||||
test('If-None-Match: returns no error when all ETags do not match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching,non-matching-either',
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-None-Match: returns NotModified when ETag match, with double ' +
|
||||
'quotes around ETag', done => {
|
||||
requestHead({ IfNoneMatch: etag }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-None-Match: returns NotModified when one of ETags match, with ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: `non-matching,${etag}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-None-Match: returns NotModified when ETag match, without ' +
|
||||
'double quotes around ETag', done => {
|
||||
requestHead({ IfNoneMatch: etagTrim }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'without double quotes around ETag', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: `non-matching,${etagTrim}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-Modified-Since: returns no error if Last modified date is ' +
|
||||
'greater', done => {
|
||||
requestHead({ IfModifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when ETag match, with double ' +
|
||||
'quotes around ETag',
|
||||
done => {
|
||||
requestHead({ IfNoneMatch: etag }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when one of ETags match, with ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestHead({
|
||||
IfNoneMatch: `non-matching,${etag}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when ETag match, without ' +
|
||||
'double quotes around ETag',
|
||||
done => {
|
||||
requestHead({ IfNoneMatch: etagTrim }, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match: returns NotModified when one of ETags match, ' +
|
||||
'without double quotes around ETag',
|
||||
done => {
|
||||
requestHead({
|
||||
IfNoneMatch: `non-matching,${etagTrim}`,
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Modified-Since: returns no error if Last modified date is ' +
|
||||
'greater',
|
||||
done => {
|
||||
requestHead({ IfModifiedSince: dateFromNow(-1) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is lesser',
|
||||
done => {
|
||||
requestHead({ IfModifiedSince: dateFromNow(1) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
test.skip('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is lesser', done => {
|
||||
requestHead({ IfModifiedSince: dateFromNow(1) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is equal',
|
||||
done => {
|
||||
requestHead({ IfModifiedSince: dateConvert(lastModified) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
test('If-Modified-Since: returns NotModified if Last modified ' +
|
||||
'date is equal', done => {
|
||||
requestHead({ IfModifiedSince: dateConvert(lastModified) },
|
||||
err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns no error when lastModified date is ' +
|
||||
'greater',
|
||||
done => {
|
||||
requestHead({ IfUnmodifiedSince: dateFromNow(1) }, err => {
|
||||
test('If-Unmodified-Since: returns no error when lastModified date is ' +
|
||||
'greater', done => {
|
||||
requestHead({ IfUnmodifiedSince: dateFromNow(1) }, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('If-Unmodified-Since: returns no error when lastModified ' +
|
||||
'date is equal', done => {
|
||||
requestHead({ IfUnmodifiedSince: dateConvert(lastModified) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns no error when lastModified ' +
|
||||
'date is equal',
|
||||
done => {
|
||||
requestHead({ IfUnmodifiedSince: dateConvert(lastModified) },
|
||||
err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
test('If-Unmodified-Since: returns PreconditionFailed when ' +
|
||||
'lastModified date is lesser', done => {
|
||||
requestHead({ IfUnmodifiedSince: dateFromNow(-1) }, err => {
|
||||
checkError(err, errors.PreconditionFailed.code);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Unmodified-Since: returns PreconditionFailed when ' +
|
||||
'lastModified date is lesser',
|
||||
done => {
|
||||
requestHead({ IfUnmodifiedSince: dateFromNow(-1) }, err => {
|
||||
checkError(err, errors.PreconditionFailed.code);
|
||||
done();
|
||||
});
|
||||
test('If-Match & If-Unmodified-Since: returns no error when match Etag ' +
|
||||
'and lastModified is greater', done => {
|
||||
requestHead({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match & If-Unmodified-Since: returns no error when match Etag ' +
|
||||
'and lastModified is greater',
|
||||
done => {
|
||||
requestHead({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkNoError(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-Match match & If-Unmodified-Since match', done => {
|
||||
test('If-Match match & If-Unmodified-Since match', done => {
|
||||
requestHead({
|
||||
IfMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -264,7 +246,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Unmodified-Since not match', done => {
|
||||
test('If-Match not match & If-Unmodified-Since not match', done => {
|
||||
requestHead({
|
||||
IfMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -274,7 +256,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Unmodified-Since match', done => {
|
||||
test('If-Match not match & If-Unmodified-Since match', done => {
|
||||
requestHead({
|
||||
IfMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -286,7 +268,7 @@ describe('HEAD object, conditions', () => {
|
|||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-Match match & If-Modified-Since not match', done => {
|
||||
test.skip('If-Match match & If-Modified-Since not match', done => {
|
||||
requestHead({
|
||||
IfMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -296,7 +278,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match match & If-Modified-Since match', done => {
|
||||
test('If-Match match & If-Modified-Since match', done => {
|
||||
requestHead({
|
||||
IfMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -306,7 +288,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Modified-Since not match', done => {
|
||||
test('If-Match not match & If-Modified-Since not match', done => {
|
||||
requestHead({
|
||||
IfMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -316,7 +298,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-Match not match & If-Modified-Since match', done => {
|
||||
test('If-Match not match & If-Modified-Since match', done => {
|
||||
requestHead({
|
||||
IfMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -326,19 +308,18 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match & If-Modified-Since: returns NotModified when Etag ' +
|
||||
'does not match and lastModified is greater',
|
||||
done => {
|
||||
requestHead({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
test('If-None-Match & If-Modified-Since: returns NotModified when Etag ' +
|
||||
'does not match and lastModified is greater', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
}, err => {
|
||||
checkError(err, 'NotModified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Modified-Since not match', done => {
|
||||
test('If-None-Match not match & If-Modified-Since not match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -348,7 +329,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Modified-Since match', done => {
|
||||
test('If-None-Match match & If-Modified-Since match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(-1),
|
||||
|
@ -360,7 +341,7 @@ describe('HEAD object, conditions', () => {
|
|||
|
||||
// Skipping this test, because real AWS does not provide error as
|
||||
// expected
|
||||
it.skip('If-None-Match match & If-Modified-Since not match', done => {
|
||||
test.skip('If-None-Match match & If-Modified-Since not match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfModifiedSince: dateFromNow(1),
|
||||
|
@ -370,7 +351,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Unmodified-Since match', done => {
|
||||
test('If-None-Match match & If-Unmodified-Since match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -380,7 +361,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match match & If-Unmodified-Since not match', done => {
|
||||
test('If-None-Match match & If-Unmodified-Since not match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: 'non-matching',
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -390,7 +371,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Unmodified-Since match', done => {
|
||||
test('If-None-Match not match & If-Unmodified-Since match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(1),
|
||||
|
@ -400,7 +381,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('If-None-Match not match & If-Unmodified-Since not match', done => {
|
||||
test('If-None-Match not match & If-Unmodified-Since not match', done => {
|
||||
requestHead({
|
||||
IfNoneMatch: etagTrim,
|
||||
IfUnmodifiedSince: dateFromNow(-1),
|
||||
|
@ -410,7 +391,7 @@ describe('HEAD object, conditions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('WebsiteRedirectLocation is set & it appears in response', done => {
|
||||
test('WebsiteRedirectLocation is set & it appears in response', done => {
|
||||
const redirBktwBody = {
|
||||
Bucket: bucketName,
|
||||
Key: 'redir_present',
|
||||
|
@ -425,18 +406,16 @@ describe('HEAD object, conditions', () => {
|
|||
checkNoError(err);
|
||||
s3.headObject(redirBkt, (err, data) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual(data.WebsiteRedirectLocation,
|
||||
'http://google.com');
|
||||
expect(data.WebsiteRedirectLocation).toBe('http://google.com');
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('WebsiteRedirectLocation is not set & is absent', done => {
|
||||
test('WebsiteRedirectLocation is not set & is absent', done => {
|
||||
requestHead({}, (err, data) => {
|
||||
checkNoError(err);
|
||||
assert.strictEqual('WebsiteRedirectLocation' in data,
|
||||
false, 'WebsiteRedirectLocation header is present.');
|
||||
expect('WebsiteRedirectLocation' in data).toBe(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('HEAD object, compatibility headers [Cache-Control, ' +
|
|||
// a UNIX timestamp for Expires header
|
||||
const expires = new Date();
|
||||
|
||||
before(() => {
|
||||
beforeAll(() => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
return bucketUtil.empty(bucketName).then(() =>
|
||||
|
@ -48,29 +48,25 @@ describe('HEAD object, compatibility headers [Cache-Control, ' +
|
|||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('deleting bucket');
|
||||
return bucketUtil.empty(bucketName).then(() =>
|
||||
bucketUtil.deleteOne(bucketName));
|
||||
});
|
||||
|
||||
it('should return additional headers if specified in objectPUT ' +
|
||||
test('should return additional headers if specified in objectPUT ' +
|
||||
'request', done => {
|
||||
s3.headObject({ Bucket: bucketName, Key: objectName },
|
||||
(err, res) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
assert.strictEqual(res.CacheControl,
|
||||
cacheControl);
|
||||
assert.strictEqual(res.ContentDisposition,
|
||||
contentDisposition);
|
||||
expect(res.CacheControl).toBe(cacheControl);
|
||||
expect(res.ContentDisposition).toBe(contentDisposition);
|
||||
// Should remove V4 streaming value 'aws-chunked'
|
||||
// to be compatible with AWS behavior
|
||||
assert.strictEqual(res.ContentEncoding,
|
||||
'gzip,');
|
||||
assert.strictEqual(res.Expires,
|
||||
expires.toUTCString());
|
||||
expect(res.ContentEncoding).toBe('gzip,');
|
||||
expect(res.Expires).toBe(expires.toUTCString());
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("Head object 'ReplicationStatus' value", () => {
|
|||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
assert.strictEqual(res.ReplicationStatus, expectedStatus);
|
||||
expect(res.ReplicationStatus).toBe(expectedStatus);
|
||||
return next();
|
||||
}),
|
||||
], cb);
|
||||
|
@ -41,8 +41,10 @@ describe("Head object 'ReplicationStatus' value", () => {
|
|||
next => s3.deleteBucket({ Bucket: sourceBucket }, next),
|
||||
], done));
|
||||
|
||||
it('should be `undefined` when there is no bucket replication config',
|
||||
done => checkHeadObj(`${keyPrefix}-foobar`, undefined, done));
|
||||
test(
|
||||
'should be `undefined` when there is no bucket replication config',
|
||||
done => checkHeadObj(`${keyPrefix}-foobar`, undefined, done)
|
||||
);
|
||||
|
||||
describe('With bucket replication config', () => {
|
||||
beforeEach(done => s3.putBucketReplication({
|
||||
|
@ -60,11 +62,15 @@ describe("Head object 'ReplicationStatus' value", () => {
|
|||
},
|
||||
}, done));
|
||||
|
||||
it("should be 'PENDING' when object key prefix applies",
|
||||
done => checkHeadObj(`${keyPrefix}-foobar`, 'PENDING', done));
|
||||
test(
|
||||
"should be 'PENDING' when object key prefix applies",
|
||||
done => checkHeadObj(`${keyPrefix}-foobar`, 'PENDING', done)
|
||||
);
|
||||
|
||||
it('should be `undefined` when object key prefix does not apply',
|
||||
done => checkHeadObj(`foobar-${keyPrefix}`, undefined, done));
|
||||
test(
|
||||
'should be `undefined` when object key prefix does not apply',
|
||||
done => checkHeadObj(`foobar-${keyPrefix}`, undefined, done)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('Put object with same key as prior object', () => {
|
|||
let s3;
|
||||
let bucketName;
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
bucketUtil = new BucketUtility('default', sigCfg);
|
||||
s3 = bucketUtil.s3;
|
||||
bucketUtil.createRandom(1)
|
||||
|
@ -45,9 +45,10 @@ describe('Put object with same key as prior object', () => {
|
|||
|
||||
afterEach(() => bucketUtil.empty(bucketName));
|
||||
|
||||
after(() => bucketUtil.deleteOne(bucketName));
|
||||
afterAll(() => bucketUtil.deleteOne(bucketName));
|
||||
|
||||
it('should overwrite all user metadata and data on overwrite put',
|
||||
test(
|
||||
'should overwrite all user metadata and data on overwrite put',
|
||||
() => s3.putObjectAsync({
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
|
@ -59,6 +60,7 @@ describe('Put object with same key as prior object', () => {
|
|||
assert.deepStrictEqual(res.Metadata, secondPutMetadata);
|
||||
assert.deepStrictEqual(res.Body.toString(),
|
||||
'Much different');
|
||||
}));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,9 +11,9 @@ const bucket = 'bucket2putstuffin4324242';
|
|||
const object = 'object2putstuffin';
|
||||
|
||||
function _checkError(err, code, statusCode) {
|
||||
assert(err, 'Expected error but found none');
|
||||
assert.strictEqual(err.code, code);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(code);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
}
|
||||
|
||||
function generateMultipleTagQuery(numberOfTag) {
|
||||
|
@ -56,88 +56,86 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should put an object and set the acl via query param',
|
||||
done => {
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
ACL: 'public-read', StorageClass: 'STANDARD' };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
assert.strictEqual(httpCode, '200 OK');
|
||||
s3.getObjectAcl({ Bucket: bucket, Key: 'key' },
|
||||
(err, result) => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
assert.deepStrictEqual(result.Grants[1], { Grantee:
|
||||
{ Type: 'Group', URI:
|
||||
'http://acs.amazonaws.com/groups/global/AllUsers',
|
||||
}, Permission: 'READ' });
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should put an object with key slash',
|
||||
done => {
|
||||
const params = { Bucket: bucket, Key: '/' };
|
||||
s3.putObject(params, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
test('should put an object and set the acl via query param', done => {
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
ACL: 'public-read', StorageClass: 'STANDARD' };
|
||||
const url = s3.getSignedUrl('putObject', params);
|
||||
provideRawOutput(['-verbose', '-X', 'PUT', url,
|
||||
'--upload-file', 'uploadFile'], httpCode => {
|
||||
expect(httpCode).toBe('200 OK');
|
||||
s3.getObjectAcl({ Bucket: bucket, Key: 'key' },
|
||||
(err, result) => {
|
||||
expect(err).toEqual(null);
|
||||
assert.deepStrictEqual(result.Grants[1], { Grantee:
|
||||
{ Type: 'Group', URI:
|
||||
'http://acs.amazonaws.com/groups/global/AllUsers',
|
||||
}, Permission: 'READ' });
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error if putting object w/ > 2KB user-defined md',
|
||||
test('should put an object with key slash', done => {
|
||||
const params = { Bucket: bucket, Key: '/' };
|
||||
s3.putObject(params, err => {
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test(
|
||||
'should return error if putting object w/ > 2KB user-defined md',
|
||||
done => {
|
||||
const metadata = genMaxSizeMetaHeaders();
|
||||
const params = { Bucket: bucket, Key: '/', Metadata: metadata };
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err, null, `Unexpected err: ${err}`);
|
||||
expect(err).toBe(null);
|
||||
// add one more byte to be over the limit
|
||||
metadata.header0 = `${metadata.header0}${'0'}`;
|
||||
s3.putObject(params, err => {
|
||||
assert(err, 'Expected err but did not find one');
|
||||
assert.strictEqual(err.code, 'MetadataTooLarge');
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe('MetadataTooLarge');
|
||||
expect(err.statusCode).toBe(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return Not Implemented error for obj. encryption using ' +
|
||||
test('should return Not Implemented error for obj. encryption using ' +
|
||||
'AWS-managed encryption keys', done => {
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
ServerSideEncryption: 'AES256' };
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return Not Implemented error for obj. encryption using ' +
|
||||
test('should return Not Implemented error for obj. encryption using ' +
|
||||
'customer-provided encryption keys', done => {
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
SSECustomerAlgorithm: 'AES256' };
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidRedirectLocation if putting object ' +
|
||||
test('should return InvalidRedirectLocation if putting object ' +
|
||||
'with x-amz-website-redirect-location header that does not start ' +
|
||||
'with \'http://\', \'https://\' or \'/\'', done => {
|
||||
const params = { Bucket: bucket, Key: 'key',
|
||||
WebsiteRedirectLocation: 'google.com' };
|
||||
s3.putObject(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidRedirectLocation');
|
||||
assert.strictEqual(err.statusCode, 400);
|
||||
expect(err.code).toBe('InvalidRedirectLocation');
|
||||
expect(err.statusCode).toBe(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe('Put object with tag set', () => {
|
||||
taggingTests.forEach(taggingTest => {
|
||||
it(taggingTest.it, done => {
|
||||
test(taggingTest.it, done => {
|
||||
const key = encodeURIComponent(taggingTest.tag.key);
|
||||
const value = encodeURIComponent(taggingTest.tag.value);
|
||||
const tagging = `${key}=${value}`;
|
||||
|
@ -148,12 +146,10 @@ describe('PUT object', () => {
|
|||
_checkError(err, taggingTest.error, 400);
|
||||
return done();
|
||||
}
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
return s3.getObjectTagging({ Bucket: bucket,
|
||||
Key: object }, (err, data) => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
assert.deepStrictEqual(data.TagSet[0], {
|
||||
Key: taggingTest.tag.key,
|
||||
Value: taggingTest.tag.value });
|
||||
|
@ -162,39 +158,33 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
it('should be able to put object with 10 tags',
|
||||
done => {
|
||||
test('should be able to put object with 10 tags', done => {
|
||||
const taggingConfig = generateMultipleTagQuery(10);
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: taggingConfig }, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to put an empty Tag set', done => {
|
||||
test('should be able to put an empty Tag set', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: '',
|
||||
}, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to put object with empty tags',
|
||||
done => {
|
||||
test('should be able to put object with empty tags', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: '&&&&&&&&&&&&&&&&&key1=value1' }, err => {
|
||||
assert.equal(err, null, 'Expected success, ' +
|
||||
`got error ${JSON.stringify(err)}`);
|
||||
expect(err).toEqual(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return BadRequest if putting more that 10 tags',
|
||||
done => {
|
||||
test('should return BadRequest if putting more that 10 tags', done => {
|
||||
const taggingConfig = generateMultipleTagQuery(11);
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: taggingConfig }, err => {
|
||||
|
@ -203,8 +193,7 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if using the same key twice',
|
||||
done => {
|
||||
test('should return InvalidArgument if using the same key twice', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: 'key1=value1&key1=value2' }, err => {
|
||||
_checkError(err, 'InvalidArgument', 400);
|
||||
|
@ -212,7 +201,7 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if using the same key twice ' +
|
||||
test('should return InvalidArgument if using the same key twice ' +
|
||||
'and empty tags', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: '&&&&&&&&&&&&&&&&&key1=value1&key1=value2' },
|
||||
|
@ -222,7 +211,7 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if tag with no key', done => {
|
||||
test('should return InvalidArgument if tag with no key', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object,
|
||||
Tagging: '=value1',
|
||||
}, err => {
|
||||
|
@ -231,7 +220,7 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument putting object with ' +
|
||||
test('should return InvalidArgument putting object with ' +
|
||||
'bad encoded tags', done => {
|
||||
s3.putObject({ Bucket: bucket, Key: object, Tagging:
|
||||
'key1==value1' }, err => {
|
||||
|
@ -239,7 +228,7 @@ describe('PUT object', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should return InvalidArgument putting object tag with ' +
|
||||
test('should return InvalidArgument putting object tag with ' +
|
||||
'invalid characters: %', done => {
|
||||
const value = 'value1%';
|
||||
s3.putObject({ Bucket: bucket, Key: object, Tagging:
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('PUT Object ACL', () => {
|
|||
const s3 = bucketUtil.s3;
|
||||
const Key = 'aclTest';
|
||||
|
||||
before(done => {
|
||||
beforeAll(done => {
|
||||
bucketUtil.createRandom(1)
|
||||
.then(created => {
|
||||
bucketName = created;
|
||||
|
@ -60,12 +60,12 @@ describe('PUT Object ACL', () => {
|
|||
return bucketUtil.empty(bucketName);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
afterAll(() => {
|
||||
process.stdout.write('deleting bucket');
|
||||
return bucketUtil.deleteOne(bucketName);
|
||||
});
|
||||
|
||||
it('should put object ACLs', done => {
|
||||
test('should put object ACLs', done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
const objects = [
|
||||
|
@ -77,13 +77,13 @@ describe('PUT Object ACL', () => {
|
|||
.then(() => s3.putObjectAclAsync({ Bucket, Key,
|
||||
ACL: 'public-read' }))
|
||||
.then(data => {
|
||||
assert(data);
|
||||
expect(data).toBeTruthy();
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should return NoSuchKey if try to put object ACLs ' +
|
||||
test('should return NoSuchKey if try to put object ACLs ' +
|
||||
'for nonexistent object', done => {
|
||||
const s3 = bucketUtil.s3;
|
||||
const Bucket = bucketName;
|
||||
|
@ -92,16 +92,16 @@ describe('PUT Object ACL', () => {
|
|||
Bucket,
|
||||
Key,
|
||||
ACL: 'public-read' }, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.statusCode, 404);
|
||||
assert.strictEqual(err.code, 'NoSuchKey');
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.statusCode).toBe(404);
|
||||
expect(err.code).toBe('NoSuchKey');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('on an object', () => {
|
||||
before(done => s3.putObject({ Bucket: bucketName, Key }, done));
|
||||
after(() => {
|
||||
beforeAll(done => s3.putObject({ Bucket: bucketName, Key }, done));
|
||||
afterAll(() => {
|
||||
process.stdout.write('deleting bucket');
|
||||
return bucketUtil.empty(bucketName);
|
||||
});
|
||||
|
@ -118,9 +118,9 @@ describe('PUT Object ACL', () => {
|
|||
AccessControlPolicy: acp,
|
||||
};
|
||||
s3.putObjectAcl(putAclParams, err => {
|
||||
assert(err);
|
||||
assert.strictEqual(err.statusCode, 403);
|
||||
assert.strictEqual(err.code, 'AccessDenied');
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.statusCode).toBe(403);
|
||||
expect(err.code).toBe('AccessDenied');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,9 +36,9 @@ function generateTaggingConfig(key, value) {
|
|||
}
|
||||
|
||||
function _checkError(err, code, statusCode) {
|
||||
assert(err, 'Expected error but found none');
|
||||
assert.strictEqual(err.code, code);
|
||||
assert.strictEqual(err.statusCode, statusCode);
|
||||
expect(err).toBeTruthy();
|
||||
expect(err.code).toBe(code);
|
||||
expect(err.statusCode).toBe(statusCode);
|
||||
}
|
||||
|
||||
describe('PUT object taggings', () => {
|
||||
|
@ -69,7 +69,7 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
|
||||
taggingTests.forEach(taggingTest => {
|
||||
it(taggingTest.it, done => {
|
||||
test(taggingTest.it, done => {
|
||||
const taggingConfig = generateTaggingConfig(taggingTest.tag.key,
|
||||
taggingTest.tag.value);
|
||||
s3.putObjectTagging({ Bucket: bucketName, Key: objectName,
|
||||
|
@ -78,14 +78,14 @@ describe('PUT object taggings', () => {
|
|||
_checkError(err, taggingTest.error, 400);
|
||||
} else {
|
||||
assert.ifError(err, `Found unexpected err ${err}`);
|
||||
assert.strictEqual(Object.keys(data).length, 0);
|
||||
expect(Object.keys(data).length).toBe(0);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return BadRequest if putting more that 10 tags', done => {
|
||||
test('should return BadRequest if putting more that 10 tags', done => {
|
||||
const taggingConfig = generateMultipleTagConfig(11);
|
||||
s3.putObjectTagging({ Bucket: bucketName, Key: objectName,
|
||||
Tagging: taggingConfig }, err => {
|
||||
|
@ -94,7 +94,7 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidTag if using the same key twice', done => {
|
||||
test('should return InvalidTag if using the same key twice', done => {
|
||||
s3.putObjectTagging({ Bucket: bucketName, Key: objectName,
|
||||
Tagging: { TagSet: [
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return InvalidTag if key is an empty string', done => {
|
||||
test('should return InvalidTag if key is an empty string', done => {
|
||||
s3.putObjectTagging({ Bucket: bucketName, Key: objectName,
|
||||
Tagging: { TagSet: [
|
||||
{
|
||||
|
@ -126,17 +126,17 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should be able to put an empty Tag set', done => {
|
||||
test('should be able to put an empty Tag set', done => {
|
||||
s3.putObjectTagging({ Bucket: bucketName, Key: objectName,
|
||||
Tagging: { TagSet: [] },
|
||||
}, (err, data) => {
|
||||
assert.ifError(err, `Found unexpected err ${err}`);
|
||||
assert.strictEqual(Object.keys(data).length, 0);
|
||||
expect(Object.keys(data).length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return NoSuchKey put tag to a non-existing object', done => {
|
||||
test('should return NoSuchKey put tag to a non-existing object', done => {
|
||||
s3.putObjectTagging({
|
||||
Bucket: bucketName,
|
||||
Key: 'nonexisting',
|
||||
|
@ -147,19 +147,20 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied putting tag with another account',
|
||||
done => {
|
||||
otherAccountS3.putObjectTagging({ Bucket: bucketName, Key:
|
||||
objectName, Tagging: taggingConfig,
|
||||
}, err => {
|
||||
_checkError(err, 'AccessDenied', 403);
|
||||
done();
|
||||
});
|
||||
});
|
||||
test(
|
||||
'should return 403 AccessDenied putting tag with another account',
|
||||
done => {
|
||||
otherAccountS3.putObjectTagging({ Bucket: bucketName, Key:
|
||||
objectName, Tagging: taggingConfig,
|
||||
}, err => {
|
||||
_checkError(err, 'AccessDenied', 403);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it('should return 403 AccessDenied putting tag with a different ' +
|
||||
'account to an object with ACL "public-read-write"',
|
||||
done => {
|
||||
test('should return 403 AccessDenied putting tag with a different ' +
|
||||
'account to an object with ACL "public-read-write"', done => {
|
||||
s3.putObjectAcl({ Bucket: bucketName, Key: objectName,
|
||||
ACL: 'public-read-write' }, err => {
|
||||
if (err) {
|
||||
|
@ -174,9 +175,8 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 403 AccessDenied putting tag to an object ' +
|
||||
'in a bucket created with a different account',
|
||||
done => {
|
||||
test('should return 403 AccessDenied putting tag to an object ' +
|
||||
'in a bucket created with a different account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
'public-read-write' }, err => next(err)),
|
||||
|
@ -191,7 +191,7 @@ describe('PUT object taggings', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should put tag to an object in a bucket created with same ' +
|
||||
test('should put tag to an object in a bucket created with same ' +
|
||||
'account', done => {
|
||||
async.waterfall([
|
||||
next => s3.putBucketAcl({ Bucket: bucketName, ACL:
|
||||
|
|
|
@ -44,21 +44,21 @@ describe('PUT object', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return Not Implemented error for obj. encryption using ' +
|
||||
test('should return Not Implemented error for obj. encryption using ' +
|
||||
'customer-provided encryption keys', done => {
|
||||
const params = { Bucket: bucket, Key: 'key', PartNumber: 0,
|
||||
UploadId: uploadId, SSECustomerAlgorithm: 'AES256' };
|
||||
s3.uploadPart(params, err => {
|
||||
assert.strictEqual(err.code, 'NotImplemented');
|
||||
expect(err.code).toBe('NotImplemented');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return InvalidArgument if negative PartNumber', done => {
|
||||
test('should return InvalidArgument if negative PartNumber', done => {
|
||||
const params = { Bucket: bucket, Key: 'key', PartNumber: -1,
|
||||
UploadId: uploadId };
|
||||
s3.uploadPart(params, err => {
|
||||
assert.strictEqual(err.code, 'InvalidArgument');
|
||||
expect(err.code).toBe('InvalidArgument');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -87,9 +87,9 @@ function createHashedFile(bytes) {
|
|||
}
|
||||
|
||||
describeSkipIfCeph('aws-node-sdk range tests', () => {
|
||||
before(() => execFileAsync('gcc', ['-o', 'getRangeExec',
|
||||
beforeAll(() => execFileAsync('gcc', ['-o', 'getRangeExec',
|
||||
'lib/utility/getRange.c']));
|
||||
after(() => execAsync('rm getRangeExec'));
|
||||
afterAll(() => execAsync('rm getRangeExec'));
|
||||
|
||||
describe('aws-node-sdk range test for object put by MPU', () =>
|
||||
withV4(sigCfg => {
|
||||
|
@ -125,8 +125,7 @@ describeSkipIfCeph('aws-node-sdk range tests', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
}))
|
||||
);
|
||||
})));
|
||||
|
||||
afterEach(() => bucketUtil.empty(bucket)
|
||||
.then(() => s3.abortMultipartUploadAsync({
|
||||
|
@ -141,19 +140,18 @@ describeSkipIfCeph('aws-node-sdk range tests', () => {
|
|||
resolve();
|
||||
}))
|
||||
.then(() => bucketUtil.deleteOne(bucket))
|
||||
.then(() => execAsync(`rm hashedFile.${fileSize}*`))
|
||||
);
|
||||
.then(() => execAsync(`rm hashedFile.${fileSize}*`)));
|
||||
|
||||
it('should get a range from the first part of an object', () =>
|
||||
test('should get a range from the first part of an object', () =>
|
||||
checkRanges('0-9', fileSize));
|
||||
|
||||
it('should get a range from the second part of an object', () =>
|
||||
test('should get a range from the second part of an object', () =>
|
||||
checkRanges('5242880-5242889', fileSize));
|
||||
|
||||
it('should get a range that spans both parts of an object', () =>
|
||||
test('should get a range that spans both parts of an object', () =>
|
||||
checkRanges('5242875-5242884', fileSize));
|
||||
|
||||
it('should get a range from the second part of an object and ' +
|
||||
test('should get a range from the second part of an object and ' +
|
||||
'include the end if the range requested goes beyond the ' +
|
||||
'actual object end', () =>
|
||||
checkRanges('10485750-10485790', fileSize));
|
||||
|
@ -210,7 +208,7 @@ describeSkipIfCeph('aws-node-sdk range tests', () => {
|
|||
];
|
||||
|
||||
putRangeTests.forEach(range => {
|
||||
it(`should get a range of ${range} bytes using a ${fileSize} ` +
|
||||
test(`should get a range of ${range} bytes using a ${fileSize} ` +
|
||||
'byte sized object', () =>
|
||||
checkRanges(range, fileSize));
|
||||
});
|
||||
|
@ -236,11 +234,11 @@ describeSkipIfCeph('aws-node-sdk range tests', () => {
|
|||
.then(() => bucketUtil.deleteOne(bucket))
|
||||
.then(() => execAsync(`rm hashedFile.${fileSize}*`)));
|
||||
|
||||
it('should get the final 90 bytes of a 2890 byte object for a ' +
|
||||
test('should get the final 90 bytes of a 2890 byte object for a ' +
|
||||
'byte range of 2800-', () =>
|
||||
checkRanges('2800-', fileSize));
|
||||
|
||||
it('should get the final 90 bytes of a 2890 byte object for a ' +
|
||||
test('should get the final 90 bytes of a 2890 byte object for a ' +
|
||||
'byte range of 2800-Number.MAX_SAFE_INTEGER', () =>
|
||||
checkRanges(`2800-${Number.MAX_SAFE_INTEGER}`, fileSize));
|
||||
});
|
||||
|
|
|
@ -44,7 +44,7 @@ function putBucketWebsiteAndPutObjectRedirect(redirect, condition, key, done) {
|
|||
}
|
||||
|
||||
describe('User visits bucket website endpoint', () => {
|
||||
it('should return 404 when no such bucket', done => {
|
||||
test('should return 404 when no such bucket', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -57,7 +57,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return 404 when no website configuration', done => {
|
||||
test('should return 404 when no website configuration', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -70,15 +70,14 @@ describe('User visits bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket, Key: 'index.html',
|
||||
ACL: 'public-read',
|
||||
Body: fs.readFileSync(path.join(__dirname,
|
||||
'/websiteFiles/index.html')),
|
||||
ContentType: 'text/html' },
|
||||
err => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -89,30 +88,29 @@ describe('User visits bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should return 405 when user requests method other than get ' +
|
||||
test('should return 405 when user requests method other than get ' +
|
||||
'or head', done => {
|
||||
makeRequest({
|
||||
hostname,
|
||||
port,
|
||||
method: 'POST',
|
||||
}, (err, res) => {
|
||||
assert.strictEqual(err, null,
|
||||
`Err with request ${err}`);
|
||||
assert.strictEqual(res.statusCode, 405);
|
||||
assert(res.body.indexOf('<head><title>405 ' +
|
||||
'Method Not Allowed</title></head>') > -1);
|
||||
expect(err).toBe(null);
|
||||
expect(res.statusCode).toBe(405);
|
||||
expect(res.body.indexOf('<head><title>405 ' +
|
||||
'Method Not Allowed</title></head>') > -1).toBeTruthy();
|
||||
return done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should serve indexDocument if no key requested', done => {
|
||||
test('should serve indexDocument if no key requested', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
responseType: 'index-user',
|
||||
}, done);
|
||||
});
|
||||
it('should serve indexDocument if key requested', done => {
|
||||
test('should serve indexDocument if key requested', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/index.html`,
|
||||
|
@ -125,8 +123,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'pathprefix/index.html',
|
||||
ACL: 'public-read',
|
||||
|
@ -142,8 +139,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
done);
|
||||
});
|
||||
|
||||
it('should serve indexDocument if path request without key',
|
||||
done => {
|
||||
test('should serve indexDocument if path request without key', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/pathprefix/`,
|
||||
|
@ -151,8 +147,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it('should serve indexDocument if path request with key',
|
||||
done => {
|
||||
test('should serve indexDocument if path request with key', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/pathprefix/index.html`,
|
||||
|
@ -166,8 +161,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'index.html',
|
||||
ACL: 'private',
|
||||
|
@ -181,7 +175,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
s3.deleteObject({ Bucket: bucket, Key: 'index.html' }, done);
|
||||
});
|
||||
|
||||
it('should return 403 if key is private', done => {
|
||||
test('should return 403 if key is private', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -197,7 +191,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should return 403 if nonexisting index document key', done => {
|
||||
test('should return 403 if nonexisting index document key', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -217,7 +211,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}`, done => {
|
||||
test(`should redirect to ${redirectEndpoint}`, done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -226,7 +220,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}/about`, done => {
|
||||
test(`should redirect to ${redirectEndpoint}/about`, done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/about`,
|
||||
|
@ -252,7 +246,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://google.com/', done => {
|
||||
test('should redirect to https://google.com/', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -261,7 +255,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://google.com/about', done => {
|
||||
test('should redirect to https://google.com/about', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/about`,
|
||||
|
@ -277,8 +271,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
'error.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'error.html',
|
||||
ACL: 'public-read',
|
||||
|
@ -292,8 +285,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
s3.deleteObject({ Bucket: bucket, Key: 'error.html' }, done);
|
||||
});
|
||||
|
||||
it('should serve custom error document if an error occurred',
|
||||
done => {
|
||||
test('should serve custom error document if an error occurred', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -310,7 +302,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should serve s3 error file if unfound custom error document ' +
|
||||
test('should serve s3 error file if unfound custom error document ' +
|
||||
'and an error occurred', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -334,7 +326,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint} if error 403` +
|
||||
test(`should redirect to ${redirectEndpoint} if error 403` +
|
||||
' occured', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -359,7 +351,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}/about/ if ` +
|
||||
test(`should redirect to ${redirectEndpoint}/about/ if ` +
|
||||
'key prefix is equal to "about"', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -386,7 +378,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint} if ` +
|
||||
test(`should redirect to ${redirectEndpoint} if ` +
|
||||
'key prefix is equal to "about" AND error code 403', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -415,7 +407,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect to the first one', done => {
|
||||
test('should redirect to the first one', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/about/`,
|
||||
|
@ -441,7 +433,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://www.google.com/about if ' +
|
||||
test('should redirect to https://www.google.com/about if ' +
|
||||
'https protocols', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -469,8 +461,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should serve redirect file if error 403 error occured',
|
||||
done => {
|
||||
test('should serve redirect file if error 403 error occured', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -495,7 +486,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}/about/ if ` +
|
||||
test(`should redirect to ${redirectEndpoint}/about/ if ` +
|
||||
'ReplaceKeyPrefixWith equals "about/"', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
|
@ -524,8 +515,7 @@ describe('User visits bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should serve redirect file if key prefix is equal to "about"',
|
||||
done => {
|
||||
test('should serve redirect file if key prefix is equal to "about"', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/about/`,
|
||||
|
@ -554,9 +544,8 @@ describe('User visits bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should serve redirect file if key prefix is equal to ' +
|
||||
'"about" and error 403',
|
||||
done => {
|
||||
test('should serve redirect file if key prefix is equal to ' +
|
||||
'"about" and error 403', done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: `${endpoint}/about/`,
|
||||
|
|
|
@ -142,7 +142,7 @@ describe('User visits bucket website endpoint with ACL', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it(`${test.it} with no auth credentials sent`, done => {
|
||||
test(`${test.it} with no auth credentials sent`, done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
method: 'GET',
|
||||
url: endpoint,
|
||||
|
@ -150,7 +150,7 @@ describe('User visits bucket website endpoint with ACL', () => {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it(`${test.it} even with invalid auth credentials`, done => {
|
||||
test(`${test.it} even with invalid auth credentials`, done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
auth: 'invalid credentials',
|
||||
method: 'GET',
|
||||
|
@ -159,7 +159,7 @@ describe('User visits bucket website endpoint with ACL', () => {
|
|||
}, done);
|
||||
});
|
||||
|
||||
it(`${test.it} even with valid auth credentials`, done => {
|
||||
test(`${test.it} even with valid auth credentials`, done => {
|
||||
WebsiteConfigTester.checkHTML({
|
||||
auth: 'valid credentials',
|
||||
method: 'GET',
|
||||
|
|
|
@ -77,7 +77,7 @@ const indexExpectedHeaders = {
|
|||
|
||||
|
||||
describe('Head request on bucket website endpoint', () => {
|
||||
it('should return 404 when no such bucket', done => {
|
||||
test('should return 404 when no such bucket', done => {
|
||||
const expectedHeaders = {
|
||||
'x-amz-error-code': 'NoSuchBucket',
|
||||
// Need arsenal fixed to remove period at the end
|
||||
|
@ -93,7 +93,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
|
||||
afterEach(done => s3.deleteBucket({ Bucket: bucket }, done));
|
||||
|
||||
it('should return 404 when no website configuration', done => {
|
||||
test('should return 404 when no website configuration', done => {
|
||||
const expectedHeaders = {
|
||||
'x-amz-error-code': 'NoSuchWebsiteConfiguration',
|
||||
'x-amz-error-message': 'The specified bucket does not ' +
|
||||
|
@ -108,8 +108,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket, Key: 'index.html',
|
||||
ACL: 'public-read',
|
||||
Body: fs.readFileSync(path.join(__dirname,
|
||||
|
@ -120,7 +119,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
},
|
||||
},
|
||||
err => {
|
||||
assert.strictEqual(err, null);
|
||||
expect(err).toBe(null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -131,13 +130,13 @@ describe('Head request on bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should return indexDocument headers if no key ' +
|
||||
test('should return indexDocument headers if no key ' +
|
||||
'requested', done => {
|
||||
WebsiteConfigTester.makeHeadRequest(undefined, endpoint,
|
||||
200, indexExpectedHeaders, done);
|
||||
});
|
||||
|
||||
it('should return indexDocument headers if key requested', done => {
|
||||
test('should return indexDocument headers if key requested', done => {
|
||||
WebsiteConfigTester.makeHeadRequest(undefined,
|
||||
`${endpoint}/index.html`, 200, indexExpectedHeaders, done);
|
||||
});
|
||||
|
@ -148,8 +147,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'pathprefix/index.html',
|
||||
ACL: 'public-read',
|
||||
|
@ -169,14 +167,12 @@ describe('Head request on bucket website endpoint', () => {
|
|||
done);
|
||||
});
|
||||
|
||||
it('should serve indexDocument if path request without key',
|
||||
done => {
|
||||
test('should serve indexDocument if path request without key', done => {
|
||||
WebsiteConfigTester.makeHeadRequest(undefined,
|
||||
`${endpoint}/pathprefix/`, 200, indexExpectedHeaders, done);
|
||||
});
|
||||
|
||||
it('should serve indexDocument if path request with key',
|
||||
done => {
|
||||
test('should serve indexDocument if path request with key', done => {
|
||||
WebsiteConfigTester.makeHeadRequest(undefined,
|
||||
`${endpoint}/pathprefix/index.html`, 200,
|
||||
indexExpectedHeaders, done);
|
||||
|
@ -188,8 +184,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
const webConfig = new WebsiteConfigTester('index.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'index.html',
|
||||
ACL: 'private',
|
||||
|
@ -203,7 +198,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
s3.deleteObject({ Bucket: bucket, Key: 'index.html' }, done);
|
||||
});
|
||||
|
||||
it('should return 403 if key is private', done => {
|
||||
test('should return 403 if key is private', done => {
|
||||
const expectedHeaders = {
|
||||
'x-amz-error-code': 'AccessDenied',
|
||||
'x-amz-error-message': 'Access Denied',
|
||||
|
@ -220,7 +215,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should return 403 if nonexisting index document key', done => {
|
||||
test('should return 403 if nonexisting index document key', done => {
|
||||
const expectedHeaders = {
|
||||
'x-amz-error-code': 'AccessDenied',
|
||||
'x-amz-error-message': 'Access Denied',
|
||||
|
@ -241,7 +236,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}`, done => {
|
||||
test(`should redirect to ${redirectEndpoint}`, done => {
|
||||
const expectedHeaders = {
|
||||
location: redirectEndpoint,
|
||||
};
|
||||
|
@ -249,7 +244,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
endpoint, 301, expectedHeaders, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}about`, done => {
|
||||
test(`should redirect to ${redirectEndpoint}about`, done => {
|
||||
const expectedHeaders = {
|
||||
location: `${redirectEndpoint}about/`,
|
||||
};
|
||||
|
@ -274,7 +269,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://google.com', done => {
|
||||
test('should redirect to https://google.com', done => {
|
||||
const expectedHeaders = {
|
||||
location: 'https://www.google.com/',
|
||||
};
|
||||
|
@ -282,7 +277,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
301, expectedHeaders, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://google.com/about', done => {
|
||||
test('should redirect to https://google.com/about', done => {
|
||||
const expectedHeaders = {
|
||||
location: 'https://www.google.com/about/',
|
||||
};
|
||||
|
@ -297,8 +292,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
'error.html');
|
||||
s3.putBucketWebsite({ Bucket: bucket,
|
||||
WebsiteConfiguration: webConfig }, err => {
|
||||
assert.strictEqual(err,
|
||||
null, `Found unexpected err ${err}`);
|
||||
expect(err).toBe(null);
|
||||
s3.putObject({ Bucket: bucket,
|
||||
Key: 'error.html',
|
||||
ACL: 'public-read',
|
||||
|
@ -312,7 +306,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
s3.deleteObject({ Bucket: bucket, Key: 'error.html' }, done);
|
||||
});
|
||||
|
||||
it('should return regular error headers regardless of whether ' +
|
||||
test('should return regular error headers regardless of whether ' +
|
||||
'custom error document', done => {
|
||||
const expectedHeaders = {
|
||||
'x-amz-error-code': 'AccessDenied',
|
||||
|
@ -337,7 +331,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint} if error 403` +
|
||||
test(`should redirect to ${redirectEndpoint} if error 403` +
|
||||
' occured', done => {
|
||||
const expectedHeaders = {
|
||||
location: redirectEndpoint,
|
||||
|
@ -361,7 +355,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}about if ` +
|
||||
test(`should redirect to ${redirectEndpoint}about if ` +
|
||||
'key prefix is equal to "about"', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${redirectEndpoint}about/`,
|
||||
|
@ -387,7 +381,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint} if ` +
|
||||
test(`should redirect to ${redirectEndpoint} if ` +
|
||||
'key prefix is equal to "about" AND error code 403', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${redirectEndpoint}about/`,
|
||||
|
@ -415,7 +409,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect based on first rule', done => {
|
||||
test('should redirect based on first rule', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${redirectEndpoint}about/`,
|
||||
};
|
||||
|
@ -440,7 +434,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it('should redirect to https://www.google.com/about if ' +
|
||||
test('should redirect to https://www.google.com/about if ' +
|
||||
'https protocol specified', done => {
|
||||
const expectedHeaders = {
|
||||
location: 'https://www.google.com/about/',
|
||||
|
@ -469,7 +463,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should redirect to specified file if 403 error ' +
|
||||
test('should redirect to specified file if 403 error ' +
|
||||
'error occured', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${endpoint}/redirect.html`,
|
||||
|
@ -494,7 +488,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
WebsiteConfiguration: webConfig }, done);
|
||||
});
|
||||
|
||||
it(`should redirect to ${redirectEndpoint}about if ` +
|
||||
test(`should redirect to ${redirectEndpoint}about if ` +
|
||||
'ReplaceKeyPrefixWith equals "about"', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${redirectEndpoint}about`,
|
||||
|
@ -524,7 +518,7 @@ describe('Head request on bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should redirect to "redirect/" object if key prefix is equal ' +
|
||||
test('should redirect to "redirect/" object if key prefix is equal ' +
|
||||
'to "about/"', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${endpoint}/redirect/`,
|
||||
|
@ -555,10 +549,9 @@ describe('Head request on bucket website endpoint', () => {
|
|||
err => done(err));
|
||||
});
|
||||
|
||||
it('should redirect to "redirect" object if key prefix is equal ' +
|
||||
test('should redirect to "redirect" object if key prefix is equal ' +
|
||||
'to "about/" and there is a 403 error satisfying the ' +
|
||||
'condition in the redirect rule',
|
||||
done => {
|
||||
'condition in the redirect rule', done => {
|
||||
const expectedHeaders = {
|
||||
location: `${endpoint}/redirect/`,
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue