fog-aws 3.6.4 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.4"
3
+ VERSION = "3.8.0"
4
4
  end
5
5
  end
@@ -30,6 +30,23 @@ Shindo.tests('AWS | credentials', ['aws']) do
30
30
  aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
31
31
  end
32
32
 
33
+ tests('#fetch_credentials when the v2 token 404s') do
34
+ Excon.stub({ method: :put, path: '/latest/api/token' }, { status: 404, body: 'not found' })
35
+ returns(aws_access_key_id: 'dummykey',
36
+ aws_secret_access_key: 'dummysecret',
37
+ aws_session_token: 'dummytoken',
38
+ region: 'us-west-1',
39
+ aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true) }
40
+ end
41
+
42
+ tests('#fetch_credentials when the v2 disabled') do
43
+ returns(aws_access_key_id: 'dummykey',
44
+ aws_secret_access_key: 'dummysecret',
45
+ aws_session_token: 'dummytoken',
46
+ region: 'us-west-1',
47
+ aws_credentials_expire_at: expires_at) { Fog::AWS::Compute.fetch_credentials(use_iam_profile: true, disable_imds_v2: true) }
48
+ end
49
+
33
50
  ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = '/v1/credentials?id=task_id'
34
51
  Excon.stub({ method: :get, path: '/v1/credentials?id=task_id' }, { status: 200, body: Fog::JSON.encode(credentials) })
35
52
 
@@ -43,6 +60,35 @@ Shindo.tests('AWS | credentials', ['aws']) do
43
60
 
44
61
  ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = nil
45
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_WEB_IDENTITY_TOKEN_FILE'] = nil
91
+
46
92
  compute = Fog::AWS::Compute.new(use_iam_profile: true)
47
93
 
48
94
  tests('#refresh_credentials_if_expired') do
@@ -83,6 +129,7 @@ Shindo.tests('AWS | credentials', ['aws']) do
83
129
  end
84
130
  ensure
85
131
  ENV['AWS_CONTAINER_CREDENTIALS_RELATIVE_URI'] = nil
132
+ ENV['AWS_WEB_IDENTITY_TOKEN_FILE'] = nil
86
133
  Excon.stubs.clear
87
134
  Excon.defaults[:mock] = old_mock_value
88
135
  Fog.mock! if fog_was_mocked
@@ -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.4
4
+ version: 3.8.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-14 00:00:00.000000000 Z
12
+ date: 2021-01-13 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: []