Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/endpoint/s3/ops/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports.get_bucket_object_lock = require('./s3_get_bucket_object_lock');
exports.get_bucket_policy = require('./s3_get_bucket_policy');
exports.get_bucket_policy_status = require('./s3_get_bucket_policy_status');
exports.get_bucket_replication = require('./s3_get_bucket_replication');
exports.get_bucket_requestPayment = require('./s3_get_bucket_requestPayment');
exports.get_bucket_request_payment = require('./s3_get_bucket_request_payment');
exports.get_bucket_tagging = require('./s3_get_bucket_tagging');
exports.get_bucket_uploads = require('./s3_get_bucket_uploads');
exports.get_bucket_versioning = require('./s3_get_bucket_versioning');
Expand Down Expand Up @@ -69,7 +69,7 @@ exports.put_bucket_notification = require('./s3_put_bucket_notification');
exports.put_bucket_object_lock = require('./s3_put_bucket_object_lock');
exports.put_bucket_policy = require('./s3_put_bucket_policy');
exports.put_bucket_replication = require('./s3_put_bucket_replication');
exports.put_bucket_requestPayment = require('./s3_put_bucket_requestPayment');
exports.put_bucket_request_payment = require('./s3_put_bucket_request_payment');
exports.put_bucket_tagging = require('./s3_put_bucket_tagging');
exports.put_bucket_versioning = require('./s3_put_bucket_versioning');
exports.put_bucket_website = require('./s3_put_bucket_website');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/* Copyright (C) 2016 NooBaa */
'use strict';

const dbg = require('../../../util/debug_module')(__filename);

/**
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentGET.html
*/
async function get_bucket_requestPayment(req) {
async function get_bucket_request_payment(req) {
await req.object_sdk.read_bucket({ name: req.params.bucket });
const payer = 'BucketOwner';
dbg.log1(`s3_get_bucket_request_payment (returns ${payer} on every request)`);
return {
RequestPaymentConfiguration: {
Payer: 'BucketOwner'
Payer: payer
}
};
}

module.exports = {
handler: get_bucket_requestPayment,
handler: get_bucket_request_payment,
body: {
type: 'empty',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const S3Error = require('../s3_errors').S3Error;
/**
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTrequestPaymentPUT.html
*/
async function put_bucket_requestPayment(req) {
async function put_bucket_request_payment(req) {
await req.object_sdk.read_bucket({ name: req.params.bucket });
// TODO S3 put_bucket_requestPayment not implemented
throw new S3Error(S3Error.NotImplemented);
}

module.exports = {
handler: put_bucket_requestPayment,
handler: put_bucket_request_payment,
body: {
type: 'xml',
},
Expand Down
4 changes: 2 additions & 2 deletions src/endpoint/s3/s3_bucket_policy_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const OP_NAME_TO_ACTION = Object.freeze({
get_bucket_policy: { regular: "s3:GetBucketPolicy" },
get_bucket_policy_status: { regular: "s3:GetBucketPolicyStatus" },
get_bucket_replication: { regular: "s3:GetReplicationConfiguration" },
get_bucket_requestpayment: { regular: "s3:GetBucketRequestPayment" },
get_bucket_request_payment: { regular: "s3:GetBucketRequestPayment" },
get_bucket_tagging: { regular: "s3:GetBucketTagging" },
get_bucket_uploads: { regular: "s3:ListBucketMultipartUploads" },
get_bucket_versioning: { regular: "s3:GetBucketVersioning" },
Expand Down Expand Up @@ -77,7 +77,7 @@ const OP_NAME_TO_ACTION = Object.freeze({
put_bucket_notification: { regular: "s3:PutBucketNotification" },
put_bucket_policy: { regular: "s3:PutBucketPolicy" },
put_bucket_replication: { regular: "s3:PutReplicationConfiguration" },
put_bucket_requestpayment: { regular: "s3:PutBucketRequestPayment" },
put_bucket_request_payment: { regular: "s3:PutBucketRequestPayment" },
put_bucket_tagging: { regular: "s3:PutBucketTagging" },
put_bucket_versioning: { regular: "s3:PutBucketVersioning" },
put_bucket_website: { regular: "s3:PutBucketWebsite" },
Expand Down
2 changes: 1 addition & 1 deletion src/endpoint/s3/s3_rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const BUCKET_SUB_RESOURCES = Object.freeze({
'policy': 'policy',
'policyStatus': 'policy_status',
'replication': 'replication',
'requestPayment': 'requestPayment',
'requestPayment': 'request_payment',
'tagging': 'tagging',
'uploads': 'uploads',
'versioning': 'versioning',
Expand Down
6 changes: 6 additions & 0 deletions src/test/unit_tests/test_nsfs_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,12 @@ mocha.describe('bucket operations - namespace_fs', function() {
const res_without_metadata = _.omit(res, '$metadata');
assert.deepEqual(res_without_metadata, {});
});
mocha.it('get bucket request payment (currently returns a mock) without failing', async function() {
const res = await s3_correct_uid_default_nsr.getBucketRequestPayment({ Bucket: bucket_name});
assert.equal(res.$metadata.httpStatusCode, 200);
const expected_payer = 'BucketOwner'; // this is the mock that we use
assert.equal(res.Payer, expected_payer);
});

mocha.it('delete multiple non existing objects without failing', async function() {
const keys_to_delete = [
Expand Down
6 changes: 6 additions & 0 deletions src/test/unit_tests/test_s3_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ mocha.describe('s3_ops', function() {
const res = await s3.listBuckets({});
assert(res.Buckets.find(bucket => bucket.Name === BKT1));
});
mocha.it('should not fail request of get bucket request payment (currently returns a mock)', async function() {
const res = await s3.getBucketRequestPayment({ Bucket: BKT1 });
assert.equal(res.$metadata.httpStatusCode, 200);
const expected_payer = 'BucketOwner'; // this is the mock that we use
assert.equal(res.Payer, expected_payer);
});
mocha.it('should enable bucket logging', async function() {
await s3.createBucket({ Bucket: BKT2 });
await s3.putBucketLogging({
Expand Down