fog-aws 3.6.5 → 3.9.0

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.
@@ -112,6 +112,7 @@ module Fog
112
112
  request :put_request_payment
113
113
  request :sync_clock
114
114
  request :upload_part
115
+ request :upload_part_copy
115
116
 
116
117
  module Utils
117
118
  attr_accessor :region
@@ -227,7 +228,7 @@ module Fog
227
228
  when %r{\Acn-.*}
228
229
  "s3.#{region}.amazonaws.com.cn"
229
230
  else
230
- "s3-#{region}.amazonaws.com"
231
+ "s3.#{region}.amazonaws.com"
231
232
  end
232
233
  end
233
234
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AWS
3
- VERSION = "3.6.5"
3
+ VERSION = "3.9.0"
4
4
  end
5
5
  end
@@ -60,6 +60,47 @@ Shindo.tests('AWS | credentials', ['aws']) do
60
60
 
61
61
  ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = nil
62
62
 
63
+ ENV['AWS_WEB_IDENTITY_TOKEN_FILE'] = File.dirname(__FILE__) + '/lorem.txt'
64
+ ENV['AWS_ROLE_ARN'] = "dummyrole"
65
+ ENV['AWS_ROLE_SESSION_NAME'] = "dummyrolesessionname"
66
+ document =
67
+ '<AssumeRoleWithWebIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">'\
68
+ '<AssumeRoleWithWebIdentityResult>'\
69
+ '<Credentials>'\
70
+ '<SessionToken>dummytoken</SessionToken>'\
71
+ '<SecretAccessKey>dummysecret</SecretAccessKey>'\
72
+ "<Expiration>#{expires_at.xmlschema}</Expiration>"\
73
+ '<AccessKeyId>dummykey</AccessKeyId>'\
74
+ '</Credentials>'\
75
+ '</AssumeRoleWithWebIdentityResult>'\
76
+ '</AssumeRoleWithWebIdentityResponse>'
77
+
78
+ Excon.stub({method: :get, path: "/", idempotent: true}, { status: 200, body: document})
79
+
80
+ tests('#fetch_credentials token based') do
81
+ returns(
82
+ aws_access_key_id: 'dummykey',
83
+ aws_secret_access_key: 'dummysecret',
84
+ aws_session_token: 'dummytoken',
85
+ region: 'us-west-1',
86
+ aws_credentials_expire_at: expires_at
87
+ ) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
88
+ end
89
+
90
+ ENV['AWS_ROLE_SESSION_NAME'] = nil
91
+
92
+ tests('#fetch_credentials token based without session name') do
93
+ returns(
94
+ aws_access_key_id: 'dummykey',
95
+ aws_secret_access_key: 'dummysecret',
96
+ aws_session_token: 'dummytoken',
97
+ region: 'us-west-1',
98
+ aws_credentials_expire_at: expires_at
99
+ ) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
100
+ end
101
+
102
+ ENV['AWS_WEB_IDENTITY_TOKEN_FILE'] = nil
103
+
63
104
  compute = Fog::AWS::Compute.new(use_iam_profile: true)
64
105
 
65
106
  tests('#refresh_credentials_if_expired') do
@@ -100,6 +141,7 @@ Shindo.tests('AWS | credentials', ['aws']) do
100
141
  end
101
142
  ensure
102
143
  ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = nil
144
+ ENV['AWS_WEB_IDENTITY_TOKEN_FILE'] = nil
103
145
  Excon.stubs.clear
104
146
  Excon.defaults[:mock] = old_mock_value
105
147
  Fog.mock! if fog_was_mocked
@@ -1,8 +1,8 @@
1
1
  module Shindo
2
2
  class Tests
3
- def succeeds
3
+ def succeeds(&block)
4
4
  test('succeeds') do
5
- !instance_eval(&Proc.new).nil?
5
+ !instance_eval(&Proc.new(&block)).nil?
6
6
  end
7
7
  end
8
8
  end
@@ -50,6 +50,38 @@ Shindo.tests("Storage[:aws] | files", ["aws"]) do
50
50
  end
51
51
  end
52
52
 
53
+ tests('#normalize_headers') do
54
+ files = @directory.files
55
+ response = Excon::Response.new
56
+ current_time = Time.new(2021, 02, 21)
57
+
58
+ response.headers['last-modified'] = current_time.to_s
59
+ response.headers['etag'] = '12345'
60
+ response.headers['ETAG'] = '12345'
61
+ response.headers['Cache-Control'] = 'no-cache'
62
+ response.headers['Content-disposition'] = 'attachment'
63
+ response.headers['content-length'] = 100
64
+ response.headers['content-Encoding'] = 'gzip'
65
+ response.headers['content-md5'] = 'ABCDEAB'
66
+ response.headers['content-Md5'] = 'ABCDEAB'
67
+ response.headers['ConTent-Type'] = 'application/json'
68
+
69
+ expected = {
70
+ 'Last-Modified' => current_time,
71
+ 'ETag' => '12345',
72
+ 'Cache-Control' => 'no-cache',
73
+ 'Content-Disposition' => 'attachment',
74
+ 'Content-Length' => 100,
75
+ 'Content-Encoding' => 'gzip',
76
+ 'Content-MD5' => 'ABCDEAB',
77
+ 'Content-Type' => 'application/json'
78
+ }
79
+
80
+ tests('header keys are normalized').returns(expected) do
81
+ files.normalize_headers(response)
82
+ response.headers
83
+ end
84
+ end
53
85
  end
54
86
 
55
87
  @directory.versions.each(&:destroy)
@@ -0,0 +1,93 @@
1
+ require 'securerandom'
2
+
3
+ Shindo.tests('Fog::Storage[:aws] | copy requests', ["aws"]) do
4
+
5
+ @directory = Fog::Storage[:aws].directories.create(:key => uniq_id('fogmultipartcopytests'))
6
+ @large_data = SecureRandom.hex * 600000
7
+ @large_blob = Fog::Storage[:aws].put_object(@directory.identity, 'large_object', @large_data)
8
+
9
+ tests('copies an empty object') do
10
+ Fog::Storage[:aws].put_object(@directory.identity, 'empty_object', '')
11
+
12
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('empty_object')
13
+ file.multipart_chunk_size = Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
14
+
15
+ tests("#copy_object('#{@directory.identity}', 'empty_copied_object'").succeeds do
16
+ file.copy(@directory.identity, 'empty_copied_object')
17
+ end
18
+
19
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('empty_copied_object')
20
+ test("copied is the same") { copied.body == file.body }
21
+ end
22
+
23
+ tests('copies a small object') do
24
+ Fog::Storage[:aws].put_object(@directory.identity, 'fog_object', lorem_file)
25
+
26
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('fog_object')
27
+
28
+ tests("#copy_object('#{@directory.identity}', 'copied_object'").succeeds do
29
+ file.copy(@directory.identity, 'copied_object')
30
+ end
31
+
32
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('copied_object')
33
+ test("copied is the same") { copied.body == file.body }
34
+ end
35
+
36
+ tests('copies a file needing a single part') do
37
+ data = '*' * Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
38
+ Fog::Storage[:aws].put_object(@directory.identity, '1_part_object', data)
39
+
40
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('1_part_object')
41
+ file.multipart_chunk_size = Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
42
+
43
+ tests("#copy_object('#{@directory.identity}', '1_part_copied_object'").succeeds do
44
+ file.copy(@directory.identity, '1_part_copied_object')
45
+ end
46
+
47
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('1_part_copied_object')
48
+ test("copied is the same") { copied.body == file.body }
49
+ end
50
+
51
+ tests('copies a file with many parts') do
52
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('large_object')
53
+ file.multipart_chunk_size = Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
54
+
55
+ tests("#copy_object('#{@directory.identity}', 'large_copied_object'").succeeds do
56
+ file.copy(@directory.identity, 'large_copied_object')
57
+ end
58
+
59
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('large_copied_object')
60
+
61
+ test("concurrency defaults to 1") { file.concurrency == 1 }
62
+ test("copied is the same") { copied.body == file.body }
63
+ end
64
+
65
+ tests('copies a file with many parts with 10 threads') do
66
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('large_object')
67
+ file.multipart_chunk_size = Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
68
+ file.concurrency = 10
69
+
70
+ test("concurrency is set to 10") { file.concurrency == 10 }
71
+
72
+ tests("#copy_object('#{@directory.identity}', 'copied_object_with_10_threads'").succeeds do
73
+ file.copy(@directory.identity, 'copied_object_with_10_threads')
74
+ end
75
+
76
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('copied_object_with_10_threads')
77
+
78
+ test("copied is the same") { copied.body == file.body }
79
+ end
80
+
81
+ tests('copies an object with unknown headers') do
82
+ file = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('large_object')
83
+ file.multipart_chunk_size = Fog::AWS::Storage::File::MIN_MULTIPART_CHUNK_SIZE
84
+ file.concurrency = 10
85
+
86
+ tests("#copy_object('#{@directory.identity}', 'copied_object'").succeeds do
87
+ file.copy(@directory.identity, 'copied_object', { unknown: 1 } )
88
+ end
89
+
90
+ copied = Fog::Storage[:aws].directories.new(key: @directory.identity).files.get('copied_object')
91
+ test("copied is the same") { copied.body == file.body }
92
+ end
93
+ end
@@ -18,6 +18,13 @@ Shindo.tests('AWS::Storage | object requests', ['aws']) do
18
18
  Fog::Storage[:aws].put_object(@directory.identity, 'fog_object', lorem_file)
19
19
  end
20
20
 
21
+ tests("#put_object('#{@directory.identity}', 'fog_object', lorem_file at EOF)").returns(lorem_file.read) do
22
+ file = lorem_file
23
+ file.read
24
+ Fog::Storage[:aws].put_object(@directory.identity, 'fog_object', file)
25
+ Fog::Storage[:aws].get_object(@directory.identity, 'fog_object').body
26
+ end
27
+
21
28
  tests("#copy_object('#{@directory.identity}', 'fog_object', '#{@directory.identity}', 'fog_other_object')").succeeds do
22
29
  Fog::Storage[:aws].copy_object(@directory.identity, 'fog_object', @directory.identity, 'fog_other_object')
23
30
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.5
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  - Wesley Beary
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-22 00:00:00.000000000 Z
12
+ date: 2021-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -754,6 +754,7 @@ files:
754
754
  - lib/fog/aws/parsers/storage/initiate_multipart_upload.rb
755
755
  - lib/fog/aws/parsers/storage/list_multipart_uploads.rb
756
756
  - lib/fog/aws/parsers/storage/list_parts.rb
757
+ - lib/fog/aws/parsers/storage/upload_part_copy_object.rb
757
758
  - lib/fog/aws/parsers/sts/assume_role.rb
758
759
  - lib/fog/aws/parsers/sts/assume_role_with_saml.rb
759
760
  - lib/fog/aws/parsers/sts/assume_role_with_web_identity.rb
@@ -1442,6 +1443,7 @@ files:
1442
1443
  - lib/fog/aws/requests/storage/shared_mock_methods.rb
1443
1444
  - lib/fog/aws/requests/storage/sync_clock.rb
1444
1445
  - lib/fog/aws/requests/storage/upload_part.rb
1446
+ - lib/fog/aws/requests/storage/upload_part_copy.rb
1445
1447
  - lib/fog/aws/requests/sts/assume_role.rb
1446
1448
  - lib/fog/aws/requests/sts/assume_role_with_saml.rb
1447
1449
  - lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
@@ -1709,6 +1711,7 @@ files:
1709
1711
  - tests/requests/storage/bucket_tests.rb
1710
1712
  - tests/requests/storage/cors_utils_tests.rb
1711
1713
  - tests/requests/storage/delete_multiple_objects_tests.rb
1714
+ - tests/requests/storage/multipart_copy_tests.rb
1712
1715
  - tests/requests/storage/multipart_upload_tests.rb
1713
1716
  - tests/requests/storage/object_tests.rb
1714
1717
  - tests/requests/storage/versioning_tests.rb
@@ -1726,7 +1729,7 @@ homepage: https://github.com/fog/fog-aws
1726
1729
  licenses:
1727
1730
  - MIT
1728
1731
  metadata: {}
1729
- post_install_message:
1732
+ post_install_message:
1730
1733
  rdoc_options: []
1731
1734
  require_paths:
1732
1735
  - lib
@@ -1741,8 +1744,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1741
1744
  - !ruby/object:Gem::Version
1742
1745
  version: '0'
1743
1746
  requirements: []
1744
- rubygems_version: 3.0.3
1745
- signing_key:
1747
+ rubygems_version: 3.1.2
1748
+ signing_key:
1746
1749
  specification_version: 4
1747
1750
  summary: Module for the 'fog' gem to support Amazon Web Services.
1748
1751
  test_files: []