Skip to content

Commit be3e6ff

Browse files
committed
Set default bucket encryption during bucket creation
All S3 buckets have encryption configured by default, and objects are automatically encrypted by using server side encryption. When we do get-bucker-encryption on any bucket we get the the default encryption configuration. With this patch we set default encryption on bucket while creating the bucket and follow the behavior of S3 bucket. Signed-off-by: Vinayakswami Hariharmath <[email protected]>
1 parent 038ce84 commit be3e6ff

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/server/system_services/bucket_server.js

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ function new_bucket_defaults(name, system_id, tiering_policy_id, owner_account_i
7373
object_lock_configuration: config.WORM_ENABLED ? {
7474
object_lock_enabled: lock_enabled ? 'Enabled' : 'Disabled',
7575
} : undefined,
76+
encryption: {
77+
"algorithm": "AES256",
78+
},
7679
};
7780
}
7881

src/test/system_tests/ceph_s3_tests/s3-tests-lists/s3_tests_pending_list.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,6 @@ s3tests_boto3/functional/test_s3.py::test_lifecycle_expiration_size_lt
140140
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_retention
141141
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_legal_hold_on
142142
s3tests_boto3/functional/test_s3.py::test_get_undefined_public_block
143-
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
143+
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
144+
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_s3
145+
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_kms

src/test/unit_tests/test_s3_encryption.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,22 @@ mocha.describe('Bucket Encryption Operations', async () => {
7171
await local_s3.createBucket({ Bucket: BKT });
7272
});
7373

74-
mocha.it('should get bucket encryption error without encryption configured', async () => {
74+
mocha.it('getBucketEncryption should return the default server side encryption configuration', async () => {
7575
try {
7676
const res = await local_s3.getBucketEncryption({ Bucket: BKT });
77-
throw new Error(`Expected to get error with unconfigured bucket encryption ${res}`);
77+
const expected_response = {
78+
ServerSideEncryptionConfiguration: {
79+
Rules: [{
80+
ApplyServerSideEncryptionByDefault: {
81+
SSEAlgorithm: 'AES256'
82+
}
83+
}]
84+
}
85+
};
86+
const res_without_metadata = _.omit(res, '$metadata');
87+
assert.deepEqual(res_without_metadata, expected_response);
7888
} catch (error) {
79-
assert(error.message === 'The server side encryption configuration was not found.', `Error message does not match got: ${error.message}`);
80-
assert(error.Code === 'ServerSideEncryptionConfigurationNotFoundError', `Error code does not match got: ${error.Code}`);
81-
assert(error.$metadata.httpStatusCode === 404, `Error status code does not match got: ${error.$metadata.httpStatusCode}`);
89+
throw new Error(`The server side encryption configuration was not found ${error.message}`);
8290
}
8391
});
8492

0 commit comments

Comments
 (0)