Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default bucket encryption during bucket creation #8478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/server/system_services/bucket_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function new_bucket_defaults(name, system_id, tiering_policy_id, owner_account_i
object_lock_configuration: config.WORM_ENABLED ? {
object_lock_enabled: lock_enabled ? 'Enabled' : 'Disabled',
} : undefined,
encryption: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with setting it like this here is that it also applies for namespace buckets - which we don't know for sure if they have encryption set or not. So I think you need to check here if it's data buckets only (no namespace). For namespace that can be a bigger discussion on what we should return, as it can be a mix of resources of different kinds. Would handling only data buckets be enough for now?

"algorithm": "AES256",
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,6 @@ s3tests_boto3/functional/test_s3.py::test_lifecycle_expiration_size_lt
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_retention
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_legal_hold_on
s3tests_boto3/functional/test_s3.py::test_get_undefined_public_block
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_s3
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_kms
18 changes: 13 additions & 5 deletions src/test/unit_tests/test_s3_encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ mocha.describe('Bucket Encryption Operations', async () => {
await local_s3.createBucket({ Bucket: BKT });
});

mocha.it('should get bucket encryption error without encryption configured', async () => {
mocha.it('getBucketEncryption should return the default server side encryption configuration', async () => {
try {
const res = await local_s3.getBucketEncryption({ Bucket: BKT });
throw new Error(`Expected to get error with unconfigured bucket encryption ${res}`);
const expected_response = {
ServerSideEncryptionConfiguration: {
Rules: [{
ApplyServerSideEncryptionByDefault: {
SSEAlgorithm: 'AES256'
}
}]
}
};
const res_without_metadata = _.omit(res, '$metadata');
assert.deepEqual(res_without_metadata, expected_response);
} catch (error) {
assert(error.message === 'The server side encryption configuration was not found.', `Error message does not match got: ${error.message}`);
assert(error.Code === 'ServerSideEncryptionConfigurationNotFoundError', `Error code does not match got: ${error.Code}`);
assert(error.$metadata.httpStatusCode === 404, `Error status code does not match got: ${error.$metadata.httpStatusCode}`);
throw new Error(`The server side encryption configuration was not found ${error.message}`);
}
});

Expand Down
Loading