Skip to content

Commit

Permalink
Fix bucket predefined ACL helpers
Browse files Browse the repository at this point in the history
The file predefined ACL helpers fix applied to bucket and default ACL.

[refs googleapis#381]
  • Loading branch information
blowmage committed Oct 20, 2015
1 parent fd63239 commit 568a9d7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/gcloud/storage/bucket/acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ def clear!

def update_predefined_acl! acl_role
resp = @connection.patch_bucket @bucket,
acl: acl_role
predefined_acl: acl_role,
acl: []

return clear! if resp.success?
fail Gcloud::Storage::ApiError.from_response(resp)
Expand Down Expand Up @@ -974,7 +975,8 @@ def clear!

def update_predefined_default_acl! acl_role
resp = @connection.patch_bucket @bucket,
default_acl: acl_role
predefined_default_acl: acl_role,
default_acl: []

return clear! if resp.success?
fail Gcloud::Storage::ApiError.from_response(resp)
Expand Down
8 changes: 5 additions & 3 deletions lib/gcloud/storage/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def insert_bucket bucket_name, options = {}
# Updates a bucket, including its ACL metadata.
def patch_bucket bucket_name, options = {}
params = { bucket: bucket_name,
predefinedAcl: options[:acl],
predefinedDefaultObjectAcl: options[:default_acl]
predefinedAcl: options[:predefined_acl],
predefinedDefaultObjectAcl: options[:predefined_default_acl]
}.delete_if { |_, v| v.nil? }

@client.execute(
Expand Down Expand Up @@ -324,7 +324,9 @@ def patch_bucket_request options = {}
"cors" => options[:cors],
"logging" => logging_config(options),
"versioning" => versioning_config(options[:versioning]),
"website" => website_config(options)
"website" => website_config(options),
"acl" => options[:acl],
"defaultObjectAcl" => options[:default_acl]
}.delete_if { |_, v| v.nil? }
end

Expand Down
1 change: 1 addition & 0 deletions test/gcloud/storage/bucket_acl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
def predefined_acl_update acl_role
mock_connection.patch "/storage/v1/b/#{bucket.name}" do |env|
env.params["predefinedAcl"].must_equal acl_role
JSON.parse(env.body)["acl"].must_equal []
[200, {"Content-Type"=>"application/json"},
random_bucket_hash(bucket.name).to_json]
end
Expand Down
1 change: 1 addition & 0 deletions test/gcloud/storage/default_acl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@
def predefined_default_acl_update acl_role
mock_connection.patch "/storage/v1/b/#{bucket.name}" do |env|
env.params["predefinedDefaultObjectAcl"].must_equal acl_role
JSON.parse(env.body)["defaultObjectAcl"].must_equal []
[200, {"Content-Type"=>"application/json"},
random_bucket_hash(bucket.name).to_json]
end
Expand Down

0 comments on commit 568a9d7

Please sign in to comment.