mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:33:24 +08:00
FIX: Destination prefix in S3 inventory configuration is incorrect
This commit is contained in:
parent
381793243e
commit
ba9cc83d4c
|
@ -125,18 +125,13 @@ class S3Inventory
|
||||||
|
|
||||||
def inventory_configuration
|
def inventory_configuration
|
||||||
filter_prefix = inventory_id
|
filter_prefix = inventory_id
|
||||||
destination_prefix = File.join(INVENTORY_PREFIX, inventory_id)
|
filter_prefix = File.join(bucket_folder_path, filter_prefix) if bucket_folder_path.present?
|
||||||
|
|
||||||
if bucket_folder_path.present?
|
|
||||||
filter_prefix = File.join(bucket_folder_path, filter_prefix)
|
|
||||||
destination_prefix = File.join(bucket_folder_path, destination_prefix)
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
{
|
||||||
destination: {
|
destination: {
|
||||||
s3_bucket_destination: {
|
s3_bucket_destination: {
|
||||||
bucket: bucket_arn,
|
bucket: bucket_arn,
|
||||||
prefix: destination_prefix,
|
prefix: inventory_path,
|
||||||
format: "CSV"
|
format: "CSV"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,9 +16,11 @@ describe Jobs::UpdateS3Inventory do
|
||||||
|
|
||||||
it "updates the bucket policy and inventory configuration in S3" do
|
it "updates the bucket policy and inventory configuration in S3" do
|
||||||
id = "original"
|
id = "original"
|
||||||
|
path = File.join(S3Inventory::INVENTORY_PREFIX, S3Inventory::INVENTORY_VERSION)
|
||||||
|
|
||||||
@client.expects(:put_bucket_policy).with(
|
@client.expects(:put_bucket_policy).with(
|
||||||
bucket: "bucket",
|
bucket: "bucket",
|
||||||
policy: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"InventoryAndAnalyticsPolicy\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"s3.amazonaws.com\"},\"Action\":[\"s3:PutObject\"],\"Resource\":[\"arn:aws:s3:::bucket/#{S3Inventory::INVENTORY_PREFIX}/#{S3Inventory::INVENTORY_VERSION}/*\"],\"Condition\":{\"ArnLike\":{\"aws:SourceArn\":\"arn:aws:s3:::bucket\"},\"StringEquals\":{\"s3:x-amz-acl\":\"bucket-owner-full-control\"}}}]}"
|
policy: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"InventoryAndAnalyticsPolicy\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"s3.amazonaws.com\"},\"Action\":[\"s3:PutObject\"],\"Resource\":[\"arn:aws:s3:::bucket/#{path}/*\"],\"Condition\":{\"ArnLike\":{\"aws:SourceArn\":\"arn:aws:s3:::bucket\"},\"StringEquals\":{\"s3:x-amz-acl\":\"bucket-owner-full-control\"}}}]}"
|
||||||
)
|
)
|
||||||
@client.expects(:put_bucket_inventory_configuration)
|
@client.expects(:put_bucket_inventory_configuration)
|
||||||
@client.expects(:put_bucket_inventory_configuration).with(
|
@client.expects(:put_bucket_inventory_configuration).with(
|
||||||
|
@ -28,7 +30,7 @@ describe Jobs::UpdateS3Inventory do
|
||||||
destination: {
|
destination: {
|
||||||
s3_bucket_destination: {
|
s3_bucket_destination: {
|
||||||
bucket: "arn:aws:s3:::bucket",
|
bucket: "arn:aws:s3:::bucket",
|
||||||
prefix: "inventory/#{id}",
|
prefix: path,
|
||||||
format: "CSV"
|
format: "CSV"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user