gcloud 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/AUTHENTICATION.md +71 -0
- data/CHANGELOG.md +5 -0
- data/README.md +10 -15
- data/lib/gcloud.rb +30 -0
- data/lib/gcloud/backoff.rb +3 -0
- data/lib/gcloud/credentials.rb +47 -30
- data/lib/gcloud/datastore.rb +246 -15
- data/lib/gcloud/datastore/connection.rb +4 -2
- data/lib/gcloud/datastore/credentials.rb +3 -1
- data/lib/gcloud/datastore/dataset.rb +130 -25
- data/lib/gcloud/datastore/dataset/lookup_results.rb +1 -0
- data/lib/gcloud/datastore/dataset/query_results.rb +7 -5
- data/lib/gcloud/datastore/entity.rb +99 -17
- data/lib/gcloud/datastore/errors.rb +13 -2
- data/lib/gcloud/datastore/key.rb +133 -2
- data/lib/gcloud/datastore/properties.rb +6 -1
- data/lib/gcloud/datastore/proto.rb +2 -1
- data/lib/gcloud/datastore/query.rb +4 -4
- data/lib/gcloud/datastore/transaction.rb +3 -0
- data/lib/gcloud/storage.rb +280 -13
- data/lib/gcloud/storage/bucket.rb +248 -11
- data/lib/gcloud/storage/bucket/acl.rb +631 -4
- data/lib/gcloud/storage/bucket/list.rb +1 -0
- data/lib/gcloud/storage/connection.rb +1 -0
- data/lib/gcloud/storage/credentials.rb +3 -1
- data/lib/gcloud/storage/errors.rb +9 -1
- data/lib/gcloud/storage/file.rb +231 -6
- data/lib/gcloud/storage/file/acl.rb +365 -2
- data/lib/gcloud/storage/file/list.rb +1 -0
- data/lib/gcloud/storage/file/verifier.rb +1 -0
- data/lib/gcloud/storage/project.rb +119 -10
- data/lib/gcloud/version.rb +18 -3
- metadata +33 -80
- data/.gemtest +0 -0
- data/.rubocop.yml +0 -17
- data/Manifest.txt +0 -66
- data/Rakefile +0 -35
- data/gcloud.gemspec +0 -63
- data/rakelib/console.rake +0 -28
- data/rakelib/manifest.rake +0 -24
- data/rakelib/proto.rake +0 -17
- data/rakelib/rubocop.rake +0 -17
- data/rakelib/test.rake +0 -144
- data/test/gcloud/datastore/proto/test_cursor.rb +0 -36
- data/test/gcloud/datastore/proto/test_direction.rb +0 -60
- data/test/gcloud/datastore/proto/test_operator.rb +0 -76
- data/test/gcloud/datastore/proto/test_value.rb +0 -231
- data/test/gcloud/datastore/test_connection.rb +0 -93
- data/test/gcloud/datastore/test_credentials.rb +0 -38
- data/test/gcloud/datastore/test_dataset.rb +0 -413
- data/test/gcloud/datastore/test_entity.rb +0 -161
- data/test/gcloud/datastore/test_entity_exclude.rb +0 -225
- data/test/gcloud/datastore/test_key.rb +0 -189
- data/test/gcloud/datastore/test_query.rb +0 -271
- data/test/gcloud/datastore/test_transaction.rb +0 -121
- data/test/gcloud/storage/test_backoff.rb +0 -127
- data/test/gcloud/storage/test_bucket.rb +0 -270
- data/test/gcloud/storage/test_bucket_acl.rb +0 -253
- data/test/gcloud/storage/test_default_acl.rb +0 -256
- data/test/gcloud/storage/test_file.rb +0 -221
- data/test/gcloud/storage/test_file_acl.rb +0 -367
- data/test/gcloud/storage/test_project.rb +0 -180
- data/test/gcloud/storage/test_storage.rb +0 -29
- data/test/gcloud/storage/test_verifier.rb +0 -62
- data/test/gcloud/test_version.rb +0 -8
- data/test/helper.rb +0 -91
@@ -1,270 +0,0 @@
|
|
1
|
-
# Copyright 2014 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require "helper"
|
16
|
-
require "json"
|
17
|
-
require "uri"
|
18
|
-
|
19
|
-
describe Gcloud::Storage::Bucket, :mock_storage do
|
20
|
-
# Create a bucket object with the project's mocked connection object
|
21
|
-
let(:bucket) { Gcloud::Storage::Bucket.from_gapi random_bucket_hash,
|
22
|
-
storage.connection }
|
23
|
-
|
24
|
-
it "can delete itself" do
|
25
|
-
mock_connection.delete "/storage/v1/b/#{bucket.name}" do |env|
|
26
|
-
[200, {"Content-Type"=>"application/json"}, ""]
|
27
|
-
end
|
28
|
-
|
29
|
-
bucket.delete
|
30
|
-
end
|
31
|
-
|
32
|
-
it "creates a file" do
|
33
|
-
new_file_name = random_file_path
|
34
|
-
|
35
|
-
mock_connection.post "/upload/storage/v1/b/#{bucket.name}/o" do |env|
|
36
|
-
env.params.wont_include "predefinedAcl"
|
37
|
-
[200, {"Content-Type"=>"application/json"},
|
38
|
-
create_file_json(bucket.name, new_file_name)]
|
39
|
-
end
|
40
|
-
|
41
|
-
Tempfile.open "gcloud-ruby" do |tmpfile|
|
42
|
-
bucket.create_file tmpfile, new_file_name
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "creates a file with predefined acl" do
|
47
|
-
new_file_name = random_file_path
|
48
|
-
|
49
|
-
mock_connection.post "/upload/storage/v1/b/#{bucket.name}/o" do |env|
|
50
|
-
env.params.must_include "predefinedAcl"
|
51
|
-
env.params["predefinedAcl"].must_equal "private"
|
52
|
-
[200, {"Content-Type"=>"application/json"},
|
53
|
-
create_file_json(bucket.name, new_file_name)]
|
54
|
-
end
|
55
|
-
|
56
|
-
Tempfile.open "gcloud-ruby" do |tmpfile|
|
57
|
-
bucket.create_file tmpfile, new_file_name, acl: "private"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it "creates a file with predefined acl alias" do
|
62
|
-
new_file_name = random_file_path
|
63
|
-
|
64
|
-
mock_connection.post "/upload/storage/v1/b/#{bucket.name}/o" do |env|
|
65
|
-
env.params.must_include "predefinedAcl"
|
66
|
-
env.params["predefinedAcl"].must_equal "publicRead"
|
67
|
-
[200, {"Content-Type"=>"application/json"},
|
68
|
-
create_file_json(bucket.name, new_file_name)]
|
69
|
-
end
|
70
|
-
|
71
|
-
Tempfile.open "gcloud-ruby" do |tmpfile|
|
72
|
-
bucket.create_file tmpfile, new_file_name, acl: :public
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it "creates with resumable" do
|
77
|
-
# Mock the upload
|
78
|
-
mock_connection.post "/upload/storage/v1/b/#{bucket.name}/o" do |env|
|
79
|
-
[200, {"Content-Type"=>"application/json", Location: "/upload/resumable-uri"},
|
80
|
-
create_file_json(bucket.name, "resumable.ext")]
|
81
|
-
end
|
82
|
-
|
83
|
-
Tempfile.open "gcloud-ruby" do |tmpfile|
|
84
|
-
tmpfile.write "The quick brown fox jumps over the lazy dog."
|
85
|
-
Gcloud::Storage.stub :resumable_threshold, tmpfile.size/2 do
|
86
|
-
bucket.create_file tmpfile, "resumable.ext"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it "does not error on an invalid chunk_size" do
|
92
|
-
# Mock the upload
|
93
|
-
valid_chunk_size = 256 * 1024 # 256KB
|
94
|
-
invalid_chunk_size = valid_chunk_size + 1
|
95
|
-
upload_request = false
|
96
|
-
mock_connection.post "/upload/storage/v1/b/#{bucket.name}/o" do |env|
|
97
|
-
if upload_request
|
98
|
-
# The content length is sent on the second request
|
99
|
-
env.request_headers["Content-length"].to_i.must_equal valid_chunk_size
|
100
|
-
end
|
101
|
-
upload_request = true
|
102
|
-
[200, {"Content-Type"=>"application/json", Location: "/upload/resumable-uri"},
|
103
|
-
create_file_json(bucket.name, "resumable.ext")]
|
104
|
-
end
|
105
|
-
Tempfile.open "gcloud-ruby" do |tmpfile|
|
106
|
-
10000.times do # write enough to be larger than the chunk_size
|
107
|
-
tmpfile.write "The quick brown fox jumps over the lazy dog."
|
108
|
-
end
|
109
|
-
Gcloud::Storage.stub :resumable_threshold, tmpfile.size/2 do
|
110
|
-
bucket.create_file tmpfile, "resumable.ext", chunk_size: invalid_chunk_size
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
it "lists files" do
|
116
|
-
num_files = 3
|
117
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
118
|
-
[200, {"Content-Type"=>"application/json"},
|
119
|
-
list_files_json(num_files)]
|
120
|
-
end
|
121
|
-
|
122
|
-
files = bucket.files
|
123
|
-
files.size.must_equal num_files
|
124
|
-
end
|
125
|
-
|
126
|
-
it "paginates files" do
|
127
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
128
|
-
env.params.wont_include "pageToken"
|
129
|
-
[200, {"Content-Type"=>"application/json"},
|
130
|
-
list_files_json(3, "next_page_token")]
|
131
|
-
end
|
132
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
133
|
-
env.params.must_include "pageToken"
|
134
|
-
env.params["pageToken"].must_equal "next_page_token"
|
135
|
-
[200, {"Content-Type"=>"application/json"},
|
136
|
-
list_files_json(2)]
|
137
|
-
end
|
138
|
-
|
139
|
-
first_files = bucket.files
|
140
|
-
first_files.count.must_equal 3
|
141
|
-
first_files.token.wont_be :nil?
|
142
|
-
first_files.token.must_equal "next_page_token"
|
143
|
-
|
144
|
-
second_files = bucket.files token: first_files.token
|
145
|
-
second_files.count.must_equal 2
|
146
|
-
second_files.token.must_be :nil?
|
147
|
-
end
|
148
|
-
|
149
|
-
it "paginates files with prefix set" do
|
150
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
151
|
-
env.params.must_include "prefix"
|
152
|
-
env.params["prefix"].must_equal "/prefix/"
|
153
|
-
[200, {"Content-Type"=>"application/json"},
|
154
|
-
list_files_json(3, nil, ["/prefix/path1/", "/prefix/path2/"])]
|
155
|
-
end
|
156
|
-
|
157
|
-
files = bucket.files prefix: "/prefix/"
|
158
|
-
files.count.must_equal 3
|
159
|
-
files.prefixes.wont_be :empty?
|
160
|
-
files.prefixes.must_include "/prefix/path1/"
|
161
|
-
files.prefixes.must_include "/prefix/path2/"
|
162
|
-
end
|
163
|
-
|
164
|
-
it "paginates files without prefix set" do
|
165
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
166
|
-
env.params.wont_include "prefix"
|
167
|
-
[200, {"Content-Type"=>"application/json"},
|
168
|
-
list_files_json(3, nil, ["/prefix/path1/", "/prefix/path2/"])]
|
169
|
-
end
|
170
|
-
|
171
|
-
files = bucket.files
|
172
|
-
files.count.must_equal 3
|
173
|
-
files.prefixes.wont_be :empty?
|
174
|
-
files.prefixes.must_include "/prefix/path1/"
|
175
|
-
files.prefixes.must_include "/prefix/path2/"
|
176
|
-
end
|
177
|
-
|
178
|
-
it "paginates files with max set" do
|
179
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
180
|
-
env.params.must_include "maxResults"
|
181
|
-
env.params["maxResults"].must_equal "3"
|
182
|
-
[200, {"Content-Type"=>"application/json"},
|
183
|
-
list_files_json(3, "next_page_token")]
|
184
|
-
end
|
185
|
-
|
186
|
-
files = bucket.files max: 3
|
187
|
-
files.count.must_equal 3
|
188
|
-
files.token.wont_be :nil?
|
189
|
-
files.token.must_equal "next_page_token"
|
190
|
-
end
|
191
|
-
|
192
|
-
it "paginates files without max set" do
|
193
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
194
|
-
env.params.wont_include "maxResults"
|
195
|
-
[200, {"Content-Type"=>"application/json"},
|
196
|
-
list_files_json(3, "next_page_token")]
|
197
|
-
end
|
198
|
-
|
199
|
-
files = bucket.files
|
200
|
-
files.count.must_equal 3
|
201
|
-
files.token.wont_be :nil?
|
202
|
-
files.token.must_equal "next_page_token"
|
203
|
-
end
|
204
|
-
|
205
|
-
it "paginates files with versions set" do
|
206
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
207
|
-
env.params.must_include "versions"
|
208
|
-
env.params["versions"].must_equal "true"
|
209
|
-
[200, {"Content-Type"=>"application/json"},
|
210
|
-
list_files_json(8)]
|
211
|
-
end
|
212
|
-
|
213
|
-
files = bucket.files versions: true
|
214
|
-
files.count.must_equal 8
|
215
|
-
end
|
216
|
-
|
217
|
-
it "paginates files without versions set" do
|
218
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o" do |env|
|
219
|
-
env.params.wont_include "versions"
|
220
|
-
[200, {"Content-Type"=>"application/json"},
|
221
|
-
list_files_json(3)]
|
222
|
-
end
|
223
|
-
|
224
|
-
files = bucket.files
|
225
|
-
files.count.must_equal 3
|
226
|
-
end
|
227
|
-
|
228
|
-
it "finds a file without generation" do
|
229
|
-
file_name = "file.ext"
|
230
|
-
|
231
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o/#{file_name}" do |env|
|
232
|
-
URI(env.url).query.must_be :nil?
|
233
|
-
[200, {"Content-Type"=>"application/json"},
|
234
|
-
create_file_json(bucket.name, file_name)]
|
235
|
-
end
|
236
|
-
|
237
|
-
file = bucket.find_file file_name
|
238
|
-
file.name.must_equal file_name
|
239
|
-
end
|
240
|
-
|
241
|
-
it "finds a file with generation" do
|
242
|
-
file_name = "file.ext"
|
243
|
-
generation = 123
|
244
|
-
|
245
|
-
mock_connection.get "/storage/v1/b/#{bucket.name}/o/#{file_name}" do |env|
|
246
|
-
URI(env.url).query.must_equal "generation=#{generation}"
|
247
|
-
[200, {"Content-Type"=>"application/json"},
|
248
|
-
create_file_json(bucket.name, file_name)]
|
249
|
-
end
|
250
|
-
|
251
|
-
file = bucket.find_file file_name, generation: generation
|
252
|
-
file.name.must_equal file_name
|
253
|
-
end
|
254
|
-
|
255
|
-
def create_file_json bucket=nil, name = nil
|
256
|
-
random_file_hash(bucket, name).to_json
|
257
|
-
end
|
258
|
-
|
259
|
-
def find_file_json bucket=nil, name = nil
|
260
|
-
random_file_hash(bucket, name).to_json
|
261
|
-
end
|
262
|
-
|
263
|
-
def list_files_json count = 2, token = nil, prefixes = nil
|
264
|
-
files = count.times.map { random_file_hash }
|
265
|
-
hash = {"kind"=>"storage#objects", "items"=>files}
|
266
|
-
hash["nextPageToken"] = token unless token.nil?
|
267
|
-
hash["prefixes"] = prefixes unless prefixes.nil?
|
268
|
-
hash.to_json
|
269
|
-
end
|
270
|
-
end
|
@@ -1,253 +0,0 @@
|
|
1
|
-
# Copyright 2015 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require "helper"
|
16
|
-
require "json"
|
17
|
-
require "uri"
|
18
|
-
|
19
|
-
describe Gcloud::Storage::Bucket, :acl, :mock_storage do
|
20
|
-
# Create a bucket object with the project's mocked connection object
|
21
|
-
let(:bucket) { Gcloud::Storage::Bucket.from_gapi random_bucket_hash,
|
22
|
-
storage.connection }
|
23
|
-
|
24
|
-
it "retrieves the ACL" do
|
25
|
-
bucket_name = "found-bucket"
|
26
|
-
|
27
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}" do |env|
|
28
|
-
[200, {"Content-Type"=>"application/json"},
|
29
|
-
random_bucket_hash(bucket_name).to_json]
|
30
|
-
end
|
31
|
-
|
32
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}/acl" do |env|
|
33
|
-
[200, {"Content-Type"=>"application/json"},
|
34
|
-
random_bucket_acl_hash(bucket_name).to_json]
|
35
|
-
end
|
36
|
-
|
37
|
-
bucket = storage.find_bucket bucket_name
|
38
|
-
bucket.name.must_equal bucket_name
|
39
|
-
bucket.acl.owners.wont_be :empty?
|
40
|
-
bucket.acl.writers.must_be :empty?
|
41
|
-
bucket.acl.readers.wont_be :empty?
|
42
|
-
end
|
43
|
-
|
44
|
-
it "adds to the ACL" do
|
45
|
-
bucket_name = "found-bucket"
|
46
|
-
|
47
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}" do |env|
|
48
|
-
[200, {"Content-Type"=>"application/json"},
|
49
|
-
random_bucket_hash(bucket_name).to_json]
|
50
|
-
end
|
51
|
-
|
52
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}/acl" do |env|
|
53
|
-
[200, {"Content-Type"=>"application/json"},
|
54
|
-
random_bucket_acl_hash(bucket_name).to_json]
|
55
|
-
end
|
56
|
-
|
57
|
-
bucket = storage.find_bucket bucket_name
|
58
|
-
bucket.name.must_equal bucket_name
|
59
|
-
bucket.acl.owners.wont_be :empty?
|
60
|
-
bucket.acl.writers.must_be :empty?
|
61
|
-
bucket.acl.readers.wont_be :empty?
|
62
|
-
|
63
|
-
writer_entity = "user-user@example.net"
|
64
|
-
writer_acl = {
|
65
|
-
"kind" => "storage#bucketAccessControl",
|
66
|
-
"id" => "#{bucket_name}-UUID/#{writer_entity}",
|
67
|
-
"selfLink" => "https://www.googleapis.com/storage/v1/b/#{bucket_name}-UUID/acl/#{writer_entity}",
|
68
|
-
"bucket" => "#{bucket_name}-UUID",
|
69
|
-
"entity" => writer_entity,
|
70
|
-
"email" => "user@example.net",
|
71
|
-
"role" => "WRITER",
|
72
|
-
"etag" => "CAE="
|
73
|
-
}
|
74
|
-
|
75
|
-
mock_connection.post "/storage/v1/b/#{bucket_name}/acl" do |env|
|
76
|
-
[200, {"Content-Type"=>"application/json"},
|
77
|
-
writer_acl.to_json]
|
78
|
-
end
|
79
|
-
|
80
|
-
bucket.acl.add_writer writer_entity
|
81
|
-
bucket.acl.owners.wont_be :empty?
|
82
|
-
bucket.acl.writers.wont_be :empty?
|
83
|
-
bucket.acl.readers.wont_be :empty?
|
84
|
-
bucket.acl.writers.must_include writer_entity
|
85
|
-
end
|
86
|
-
|
87
|
-
it "removes from the ACL" do
|
88
|
-
bucket_name = "found-bucket"
|
89
|
-
|
90
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}" do |env|
|
91
|
-
[200, {"Content-Type"=>"application/json"},
|
92
|
-
random_bucket_hash(bucket_name).to_json]
|
93
|
-
end
|
94
|
-
|
95
|
-
mock_connection.get "/storage/v1/b/#{bucket_name}/acl" do |env|
|
96
|
-
[200, {"Content-Type"=>"application/json"},
|
97
|
-
random_bucket_acl_hash(bucket_name).to_json]
|
98
|
-
end
|
99
|
-
|
100
|
-
bucket = storage.find_bucket bucket_name
|
101
|
-
bucket.name.must_equal bucket_name
|
102
|
-
bucket.acl.owners.wont_be :empty?
|
103
|
-
bucket.acl.writers.must_be :empty?
|
104
|
-
bucket.acl.readers.wont_be :empty?
|
105
|
-
|
106
|
-
reader_entity = bucket.acl.readers.first
|
107
|
-
|
108
|
-
mock_connection.delete "/storage/v1/b/#{bucket_name}/acl/#{reader_entity}" do |env|
|
109
|
-
[200, {"Content-Type"=>"application/json"}, ""]
|
110
|
-
end
|
111
|
-
|
112
|
-
bucket.acl.delete reader_entity
|
113
|
-
|
114
|
-
bucket.acl.owners.wont_be :empty?
|
115
|
-
bucket.acl.writers.must_be :empty?
|
116
|
-
bucket.acl.readers.must_be :empty?
|
117
|
-
end
|
118
|
-
|
119
|
-
it "sets the predefined ACL rule authenticatedRead" do
|
120
|
-
predefined_acl_update "authenticatedRead" do |acl|
|
121
|
-
acl.authenticatedRead!
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "sets the predefined ACL rule auth" do
|
126
|
-
predefined_acl_update "authenticatedRead" do |acl|
|
127
|
-
acl.auth!
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it "sets the predefined ACL rule auth_read" do
|
132
|
-
predefined_acl_update "authenticatedRead" do |acl|
|
133
|
-
acl.auth_read!
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
it "sets the predefined ACL rule authenticated" do
|
138
|
-
predefined_acl_update "authenticatedRead" do |acl|
|
139
|
-
acl.authenticated!
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
it "sets the predefined ACL rule authenticated_read" do
|
144
|
-
predefined_acl_update "authenticatedRead" do |acl|
|
145
|
-
acl.authenticated_read!
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
it "sets the predefined ACL rule private" do
|
150
|
-
predefined_acl_update "private" do |acl|
|
151
|
-
acl.private!
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
it "sets the predefined ACL rule projectPrivate" do
|
156
|
-
predefined_acl_update "projectPrivate" do |acl|
|
157
|
-
acl.projectPrivate!
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
it "sets the predefined ACL rule project_private" do
|
162
|
-
predefined_acl_update "projectPrivate" do |acl|
|
163
|
-
acl.project_private!
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
it "sets the predefined ACL rule publicRead" do
|
168
|
-
predefined_acl_update "publicRead" do |acl|
|
169
|
-
acl.publicRead!
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
it "sets the predefined ACL rule public" do
|
174
|
-
predefined_acl_update "publicRead" do |acl|
|
175
|
-
acl.public!
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
it "sets the predefined ACL rule public_read" do
|
180
|
-
predefined_acl_update "publicRead" do |acl|
|
181
|
-
acl.public_read!
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
it "sets the predefined ACL rule publicReadWrite" do
|
186
|
-
predefined_acl_update "publicReadWrite" do |acl|
|
187
|
-
acl.publicReadWrite!
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
it "sets the predefined ACL rule public_write" do
|
192
|
-
predefined_acl_update "publicReadWrite" do |acl|
|
193
|
-
acl.public_write!
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def predefined_acl_update acl_role
|
198
|
-
mock_connection.patch "/storage/v1/b/#{bucket.name}" do |env|
|
199
|
-
env.params["predefinedAcl"].must_equal acl_role
|
200
|
-
[200, {"Content-Type"=>"application/json"},
|
201
|
-
random_bucket_hash(bucket.name).to_json]
|
202
|
-
end
|
203
|
-
|
204
|
-
yield bucket.acl
|
205
|
-
end
|
206
|
-
|
207
|
-
def random_bucket_acl_hash bucket_name
|
208
|
-
{
|
209
|
-
"kind" => "storage#bucketAccessControls",
|
210
|
-
"items" => [
|
211
|
-
{
|
212
|
-
"kind" => "storage#bucketAccessControl",
|
213
|
-
"id" => "#{bucket_name}-UUID/project-owners-1234567890",
|
214
|
-
"selfLink" => "https://www.googleapis.com/storage/v1/b/#{bucket_name}-UUID/acl/project-owners-1234567890",
|
215
|
-
"bucket" => "#{bucket_name}-UUID",
|
216
|
-
"entity" => "project-owners-1234567890",
|
217
|
-
"role" => "OWNER",
|
218
|
-
"projectTeam" => {
|
219
|
-
"projectNumber" => "1234567890",
|
220
|
-
"team" => "owners"
|
221
|
-
},
|
222
|
-
"etag" => "CAE="
|
223
|
-
},
|
224
|
-
{
|
225
|
-
"kind" => "storage#bucketAccessControl",
|
226
|
-
"id" => "#{bucket_name}-UUID/project-editors-1234567890",
|
227
|
-
"selfLink" => "https://www.googleapis.com/storage/v1/b/#{bucket_name}-UUID/acl/project-editors-1234567890",
|
228
|
-
"bucket" => "#{bucket_name}-UUID",
|
229
|
-
"entity" => "project-editors-1234567890",
|
230
|
-
"role" => "OWNER",
|
231
|
-
"projectTeam" => {
|
232
|
-
"projectNumber" => "1234567890",
|
233
|
-
"team" => "editors"
|
234
|
-
},
|
235
|
-
"etag" => "CAE="
|
236
|
-
},
|
237
|
-
{
|
238
|
-
"kind" => "storage#bucketAccessControl",
|
239
|
-
"id" => "#{bucket_name}-UUID/project-viewers-1234567890",
|
240
|
-
"selfLink" => "https://www.googleapis.com/storage/v1/b/#{bucket_name}-UUID/acl/project-viewers-1234567890",
|
241
|
-
"bucket" => "#{bucket_name}-UUID",
|
242
|
-
"entity" => "project-viewers-1234567890",
|
243
|
-
"role" => "READER",
|
244
|
-
"projectTeam" => {
|
245
|
-
"projectNumber" => "1234567890",
|
246
|
-
"team" => "viewers"
|
247
|
-
},
|
248
|
-
"etag" => "CAE="
|
249
|
-
}
|
250
|
-
]
|
251
|
-
}
|
252
|
-
end
|
253
|
-
end
|