fakes3test6 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,208 @@
1
+ require 'test/test_helper'
2
+ require 'fileutils'
3
+ #require 'fakes3/server'
4
+ require 'aws/s3'
5
+
6
+ class S3CommandsTest < Test::Unit::TestCase
7
+ include AWS::S3
8
+
9
+ def setup
10
+ AWS::S3::Base.establish_connection!(:access_key_id => "123",
11
+ :secret_access_key => "abc",
12
+ :server => "localhost",
13
+ :port => "10453" )
14
+ end
15
+
16
+ def teardown
17
+ AWS::S3::Base.disconnect!
18
+ end
19
+
20
+ def test_create_bucket
21
+ bucket = Bucket.create("ruby_aws_s3")
22
+ assert_not_nil bucket
23
+
24
+ bucket_names = []
25
+ Service.buckets.each do |bucket|
26
+ bucket_names << bucket.name
27
+ end
28
+ assert(bucket_names.index("ruby_aws_s3") >= 0)
29
+ end
30
+
31
+ def test_destroy_bucket
32
+ Bucket.create("deletebucket")
33
+ Bucket.delete("deletebucket")
34
+
35
+ begin
36
+ bucket = Bucket.find("deletebucket")
37
+ assert_fail("Shouldn't succeed here")
38
+ rescue
39
+ end
40
+ end
41
+
42
+ def test_store
43
+ bucket = Bucket.create("ruby_aws_s3")
44
+ S3Object.store("hello", "world", "ruby_aws_s3")
45
+
46
+ output = ""
47
+ obj = S3Object.stream("hello", "ruby_aws_s3") do |chunk|
48
+ output << chunk
49
+ end
50
+ assert_equal "world", output
51
+ end
52
+
53
+ def test_large_store
54
+ bucket = Bucket.create("ruby_aws_s3")
55
+ buffer = ""
56
+ 500000.times do
57
+ buffer << "#{(rand * 100).to_i}"
58
+ end
59
+
60
+ buf_len = buffer.length
61
+ S3Object.store("big",buffer,"ruby_aws_s3")
62
+
63
+ output = ""
64
+ S3Object.stream("big","ruby_aws_s3") do |chunk|
65
+ output << chunk
66
+ end
67
+ assert_equal buf_len,output.size
68
+ end
69
+
70
+ def test_metadata_store
71
+ assert_equal true, Bucket.create("ruby_aws_s3")
72
+ bucket = Bucket.find("ruby_aws_s3")
73
+
74
+ # Note well: we can't seem to access obj.metadata until we've stored
75
+ # the object and found it again. Thus the store, find, store
76
+ # runaround below.
77
+ obj = bucket.new_object(:value => "foo")
78
+ obj.key = "key_with_metadata"
79
+ obj.store
80
+ obj = S3Object.find("key_with_metadata", "ruby_aws_s3")
81
+ obj.metadata[:param1] = "one"
82
+ obj.metadata[:param2] = "two, three"
83
+ obj.store
84
+ obj = S3Object.find("key_with_metadata", "ruby_aws_s3")
85
+
86
+ assert_equal "one", obj.metadata[:param1]
87
+ assert_equal "two, three", obj.metadata[:param2]
88
+ end
89
+
90
+ def test_metadata_copy
91
+ assert_equal true, Bucket.create("ruby_aws_s3")
92
+ bucket = Bucket.find("ruby_aws_s3")
93
+
94
+ # Note well: we can't seem to access obj.metadata until we've stored
95
+ # the object and found it again. Thus the store, find, store
96
+ # runaround below.
97
+ obj = bucket.new_object(:value => "foo")
98
+ obj.key = "key_with_metadata"
99
+ obj.store
100
+ obj = S3Object.find("key_with_metadata", "ruby_aws_s3")
101
+ obj.metadata[:param1] = "one"
102
+ obj.metadata[:param2] = "two, three"
103
+ obj.store
104
+
105
+ S3Object.copy("key_with_metadata", "key_with_metadata2", "ruby_aws_s3")
106
+ obj = S3Object.find("key_with_metadata2", "ruby_aws_s3")
107
+
108
+ assert_equal "one", obj.metadata[:param1]
109
+ assert_equal "two, three", obj.metadata[:param2]
110
+ end
111
+
112
+ def test_multi_directory
113
+ bucket = Bucket.create("ruby_aws_s3")
114
+ S3Object.store("dir/myfile/123.txt","recursive","ruby_aws_s3")
115
+
116
+ output = ""
117
+ obj = S3Object.stream("dir/myfile/123.txt","ruby_aws_s3") do |chunk|
118
+ output << chunk
119
+ end
120
+ assert_equal "recursive", output
121
+ end
122
+
123
+ def test_find_nil_bucket
124
+ begin
125
+ bucket = Bucket.find("unknown")
126
+ assert_fail "Bucket.find didn't throw an exception"
127
+ rescue
128
+ assert_equal AWS::S3::NoSuchBucket,$!.class
129
+ end
130
+ end
131
+
132
+ def test_find_object
133
+ bucket = Bucket.create('find_bucket')
134
+ obj_name = 'short'
135
+ S3Object.store(obj_name,'short_text','find_bucket')
136
+ short = S3Object.find(obj_name,"find_bucket")
137
+ assert_not_nil(short)
138
+ assert_equal(short.value,'short_text')
139
+ end
140
+
141
+ def test_find_non_existent_object
142
+ bucket = Bucket.create('find_bucket')
143
+ obj_name = 'doesnotexist'
144
+ assert_raise AWS::S3::NoSuchKey do
145
+ should_throw = S3Object.find(obj_name,"find_bucket")
146
+ end
147
+
148
+ # Try something higher in the alphabet
149
+ assert_raise AWS::S3::NoSuchKey do
150
+ should_throw = S3Object.find("zzz","find_bucket")
151
+ end
152
+ end
153
+
154
+ def test_exists?
155
+ bucket = Bucket.create('ruby_aws_s3')
156
+ obj_name = 'dir/myfile/exists.txt'
157
+ S3Object.store(obj_name,'exists','ruby_aws_s3')
158
+ assert S3Object.exists?(obj_name, 'ruby_aws_s3')
159
+ assert !S3Object.exists?('dir/myfile/doesnotexist.txt','ruby_aws_s3')
160
+ end
161
+
162
+ def test_delete
163
+ bucket = Bucket.create("ruby_aws_s3")
164
+ S3Object.store("something_to_delete","asdf","ruby_aws_s3")
165
+ something = S3Object.find("something_to_delete","ruby_aws_s3")
166
+ S3Object.delete("something_to_delete","ruby_aws_s3")
167
+
168
+ assert_raise AWS::S3::NoSuchKey do
169
+ should_throw = S3Object.find("something_to_delete","ruby_aws_s3")
170
+ end
171
+ end
172
+
173
+ def test_rename
174
+ bucket = Bucket.create("ruby_aws_s3")
175
+ S3Object.store("something_to_rename","asdf","ruby_aws_s3")
176
+ S3Object.rename("something_to_rename","renamed","ruby_aws_s3")
177
+
178
+ renamed = S3Object.find("renamed","ruby_aws_s3")
179
+ assert_not_nil(renamed)
180
+ assert_equal(renamed.value,'asdf')
181
+
182
+ assert_raise AWS::S3::NoSuchKey do
183
+ should_throw = S3Object.find("something_to_rename","ruby_aws_s3")
184
+ end
185
+ end
186
+
187
+ def test_larger_lists
188
+ Bucket.create("ruby_aws_s3_many")
189
+ (0..50).each do |i|
190
+ ('a'..'z').each do |letter|
191
+ name = "#{letter}#{i}"
192
+ S3Object.store(name,"asdf","ruby_aws_s3_many")
193
+ end
194
+ end
195
+
196
+ bucket = Bucket.find("ruby_aws_s3_many")
197
+ assert_equal(bucket.size,1000)
198
+ assert_equal(bucket.objects.first.key,"a0")
199
+ end
200
+
201
+
202
+ # Copying an object
203
+ #S3Object.copy 'headshot.jpg', 'headshot2.jpg', 'photos'
204
+
205
+ # Renaming an object
206
+ #S3Object.rename 'headshot.jpg', 'portrait.jpg', 'photos'
207
+
208
+ end
@@ -0,0 +1,52 @@
1
+ require 'test/test_helper'
2
+ require 'fileutils'
3
+
4
+ class S3CmdTest < Test::Unit::TestCase
5
+ def setup
6
+ config = File.expand_path(File.join(File.dirname(__FILE__),'local_s3_cfg'))
7
+ raise "Please install s3cmd" if `which s3cmd`.empty?
8
+ @s3cmd = "s3cmd --config #{config}"
9
+ end
10
+
11
+ def teardown
12
+ end
13
+
14
+ def test_create_bucket
15
+ `#{@s3cmd} mb s3://s3cmd_bucket`
16
+ output = `#{@s3cmd} ls`
17
+ assert_match(/s3cmd_bucket/,output)
18
+ end
19
+
20
+ def test_store
21
+ File.open(__FILE__,'rb') do |input|
22
+ File.open("/tmp/fakes3_upload",'wb') do |output|
23
+ output << input.read
24
+ end
25
+ end
26
+ output = `#{@s3cmd} put /tmp/fakes3_upload s3://s3cmd_bucket/upload`
27
+ assert_match(/upload/,output)
28
+
29
+ FileUtils.rm("/tmp/fakes3_upload")
30
+ end
31
+
32
+ def test_acl
33
+ File.open(__FILE__,'rb') do |input|
34
+ File.open("/tmp/fakes3_acl_upload",'wb') do |output|
35
+ output << input.read
36
+ end
37
+ end
38
+ output = `#{@s3cmd} put /tmp/fakes3_acl_upload s3://s3cmd_bucket/acl_upload`
39
+ assert_match(/upload/,output)
40
+
41
+ output = `#{@s3cmd} --force setacl -P s3://s3cmd_bucket/acl_upload`
42
+ end
43
+
44
+ def test_large_store
45
+ end
46
+
47
+ def test_multi_directory
48
+ end
49
+
50
+ def test_intra_bucket_copy
51
+ end
52
+ end
@@ -0,0 +1,6 @@
1
+ require 'test/unit'
2
+ require 'test/unit/assertions'
3
+ require 'mocha/test_unit'
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ require 'fakes3'
metadata ADDED
@@ -0,0 +1,270 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fakes3test6
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Curtis Spencer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-s3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: right_aws
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aws-sdk
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: aws-sdk-v1
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: mocha
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: thor
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: builder
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: xml-simple
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: Use Fake S3 to test basic Amazon S3 functionality without actually connecting
182
+ to AWS
183
+ email:
184
+ - fakes3@supso.org
185
+ executables:
186
+ - fakes3
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - .gitignore
191
+ - CONTRIBUTING.md
192
+ - DEPLOY_README.md
193
+ - Dockerfile
194
+ - Gemfile
195
+ - Gemfile.lock
196
+ - ISSUE_TEMPLATE.md
197
+ - Makefile
198
+ - PULL_REQUEST_TEMPLATE.md
199
+ - README.md
200
+ - Rakefile
201
+ - bin/fakes3
202
+ - fakes3.gemspec
203
+ - lib/fakes3.rb
204
+ - lib/fakes3/bucket.rb
205
+ - lib/fakes3/bucket_query.rb
206
+ - lib/fakes3/cli.rb
207
+ - lib/fakes3/errors.rb
208
+ - lib/fakes3/file_store.rb
209
+ - lib/fakes3/rate_limitable_file.rb
210
+ - lib/fakes3/s3_object.rb
211
+ - lib/fakes3/server.rb
212
+ - lib/fakes3/sorted_object_list.rb
213
+ - lib/fakes3/unsupported_operation.rb
214
+ - lib/fakes3/util.rb
215
+ - lib/fakes3/version.rb
216
+ - lib/fakes3/xml_adapter.rb
217
+ - lib/fakes3/xml_parser.rb
218
+ - static/button.svg
219
+ - static/logo.png
220
+ - test/aws_sdk_commands_test.rb
221
+ - test/aws_sdk_v2_commands_test.rb
222
+ - test/boto_test.rb
223
+ - test/botocmd.py
224
+ - test/cli_test.rb
225
+ - test/local_s3_cfg
226
+ - test/minitest_helper.rb
227
+ - test/post_test.rb
228
+ - test/right_aws_commands_test.rb
229
+ - test/s3_commands_test.rb
230
+ - test/s3cmd_test.rb
231
+ - test/test_helper.rb
232
+ homepage: https://github.com/jubos/fake-s3
233
+ licenses:
234
+ - Supported-Source
235
+ metadata: {}
236
+ post_install_message: 'Fake S3: if you don''t already have a license for Fake S3,
237
+ you can get one at https://supso.org/projects/fake-s3'
238
+ rdoc_options: []
239
+ require_paths:
240
+ - lib
241
+ required_ruby_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ required_rubygems_version: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - '>='
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ requirements: []
252
+ rubyforge_project:
253
+ rubygems_version: 2.0.14.1
254
+ signing_key:
255
+ specification_version: 4
256
+ summary: Fake S3 is a server that simulates Amazon S3 commands so you can test your
257
+ S3 functionality in your projects
258
+ test_files:
259
+ - test/aws_sdk_commands_test.rb
260
+ - test/aws_sdk_v2_commands_test.rb
261
+ - test/boto_test.rb
262
+ - test/botocmd.py
263
+ - test/cli_test.rb
264
+ - test/local_s3_cfg
265
+ - test/minitest_helper.rb
266
+ - test/post_test.rb
267
+ - test/right_aws_commands_test.rb
268
+ - test/s3_commands_test.rb
269
+ - test/s3cmd_test.rb
270
+ - test/test_helper.rb