gitlab-fog-azure-rm 1.8.0 → 1.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.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +12 -0
- data/.rubocop_todo.yml +1 -1
- data/gitlab-fog-azure-rm.gemspec +3 -2
- data/lib/fog/azurerm/docs/storage.md +1 -1
- data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
- data/lib/fog/azurerm/models/storage/directories.rb +6 -6
- data/lib/fog/azurerm/models/storage/directory.rb +4 -4
- data/lib/fog/azurerm/models/storage/file.rb +6 -3
- data/lib/fog/azurerm/models/storage/files.rb +8 -8
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
- data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
- data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
- data/lib/fog/azurerm/storage.rb +62 -9
- data/lib/fog/azurerm/utilities/general.rb +0 -5
- data/lib/fog/azurerm/version.rb +1 -1
- data/lib/fog/azurerm.rb +4 -5
- data/rakefile +4 -5
- data/test/api_stub/models/storage/directory.rb +1 -1
- data/test/api_stub/models/storage/file.rb +1 -1
- data/test/api_stub/requests/storage/directory.rb +1 -1
- data/test/api_stub/requests/storage/file.rb +4 -4
- data/test/integration/README.md +5 -7
- data/test/integration/blob.rb +28 -36
- data/test/integration/container.rb +8 -39
- data/test/integration/credentials/azure.yml +4 -5
- data/test/models/storage/test_directories.rb +5 -5
- data/test/models/storage/test_directory.rb +2 -2
- data/test/models/storage/test_file.rb +16 -4
- data/test/models/storage/test_files.rb +8 -8
- data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
- data/test/requests/storage/test_acquire_container_lease.rb +2 -2
- data/test/requests/storage/test_check_container_exists.rb +1 -1
- data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
- data/test/requests/storage/test_compare_container_blobs.rb +2 -2
- data/test/requests/storage/test_copy_blob.rb +2 -2
- data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
- data/test/requests/storage/test_create_block_blob.rb +2 -2
- data/test/requests/storage/test_create_container.rb +2 -2
- data/test/requests/storage/test_create_page_blob.rb +2 -2
- data/test/requests/storage/test_delete_blob.rb +2 -2
- data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
- data/test/requests/storage/test_delete_container.rb +2 -2
- data/test/requests/storage/test_delete_object.rb +2 -2
- data/test/requests/storage/test_get_blob.rb +2 -2
- data/test/requests/storage/test_get_blob_encoding.rb +45 -0
- data/test/requests/storage/test_get_blob_http_url.rb +13 -9
- data/test/requests/storage/test_get_blob_https_url.rb +95 -13
- data/test/requests/storage/test_get_blob_properties.rb +2 -2
- data/test/requests/storage/test_get_blob_url.rb +15 -24
- data/test/requests/storage/test_get_container_acl.rb +2 -2
- data/test/requests/storage/test_get_container_properties.rb +2 -2
- data/test/requests/storage/test_get_container_url.rb +5 -8
- data/test/requests/storage/test_get_object.rb +2 -2
- data/test/requests/storage/test_list_blobs.rb +2 -2
- data/test/requests/storage/test_list_containers.rb +2 -2
- data/test/requests/storage/test_put_blob_block.rb +2 -2
- data/test/requests/storage/test_put_blob_http_url.rb +33 -0
- data/test/requests/storage/test_put_blob_https_url.rb +8 -11
- data/test/requests/storage/test_put_blob_metadata.rb +2 -2
- data/test/requests/storage/test_put_blob_pages.rb +2 -2
- data/test/requests/storage/test_put_blob_properties.rb +2 -2
- data/test/requests/storage/test_put_container_acl.rb +2 -2
- data/test/requests/storage/test_put_container_metadata.rb +2 -2
- data/test/requests/storage/test_release_blob_lease.rb +2 -2
- data/test/requests/storage/test_release_container_lease.rb +2 -2
- data/test/requests/storage/test_save_page_blob.rb +2 -2
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
- data/test/test_helper.rb +38 -690
- metadata +27 -20
- data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
- data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
- data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
- data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
- data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
- data/lib/fog/azurerm/models/resources/provider.rb +0 -27
- data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
- data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
- data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
- data/test/integration/storage_account.rb +0 -135
- data/test/smoke_tests/compute/test_resource_group_smoke.rb +0 -37
@@ -2,15 +2,19 @@ require File.expand_path '../../test_helper', __dir__
|
|
2
2
|
|
3
3
|
# Storage Blob Class
|
4
4
|
class TestGetBlobHttpsUrl < Minitest::Test
|
5
|
+
HOUR = 3600
|
6
|
+
DAY = 24 * HOUR
|
7
|
+
WEEK = 7 * DAY
|
8
|
+
|
5
9
|
# This class posesses the test cases for the requests of Blob service.
|
6
10
|
def setup
|
7
11
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
12
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
13
|
Fog.unmock!
|
10
14
|
|
11
|
-
@service = Fog::Storage
|
15
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
12
16
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
13
|
-
@signature_client = @service.
|
17
|
+
@signature_client = @service.send(:signature_client, Minitest::Mock.new)
|
14
18
|
|
15
19
|
@url = ApiStub::Requests::Storage::File.blob_https_url
|
16
20
|
@token = ApiStub::Requests::Storage::File.blob_url_token
|
@@ -20,7 +24,7 @@ class TestGetBlobHttpsUrl < Minitest::Test
|
|
20
24
|
mock_generate_uri = Minitest::Mock.new
|
21
25
|
|
22
26
|
2.times do
|
23
|
-
mock_generate_uri.expect(:call, @url, ['test_container/test_blob', {}, { encode: true }])
|
27
|
+
mock_generate_uri.expect(:call, URI.parse(@url), ['test_container/test_blob', {}, { encode: true }])
|
24
28
|
end
|
25
29
|
|
26
30
|
@blob_client.stub :generate_uri, mock_generate_uri do
|
@@ -37,11 +41,12 @@ class TestGetBlobHttpsUrl < Minitest::Test
|
|
37
41
|
url_params = { content_disposition: 'attachment' }
|
38
42
|
|
39
43
|
2.times do
|
40
|
-
mock_generate_uri.expect(:call, @url, ['test_container/test_blob', {}, { encode: true }])
|
44
|
+
mock_generate_uri.expect(:call, URI.parse(@url), ['test_container/test_blob', {}, { encode: true }])
|
41
45
|
mock_generate_service_token.expect(:call, @token) do |_relative_path, params|
|
42
46
|
params[:service] == 'b' &&
|
43
47
|
params[:resource] == 'b' &&
|
44
48
|
params[:permissions] == 'r' &&
|
49
|
+
params[:protocol] == 'https' &&
|
45
50
|
params[:content_disposition] == url_params[:content_disposition]
|
46
51
|
end
|
47
52
|
end
|
@@ -59,7 +64,7 @@ class TestGetBlobHttpsUrl < Minitest::Test
|
|
59
64
|
mock_generate_service_token = Minitest::Mock.new
|
60
65
|
|
61
66
|
2.times do
|
62
|
-
mock_generate_uri.expect(:call, @url, ['.test0/..test1/...test2', {}, { encode: true }])
|
67
|
+
mock_generate_uri.expect(:call, URI.parse(@url), ['.test0/..test1/...test2', {}, { encode: true }])
|
63
68
|
mock_generate_service_token.expect(:call, @token) do |relative_path, _|
|
64
69
|
relative_path == '.test0/..test1/...test2'
|
65
70
|
end
|
@@ -73,20 +78,97 @@ class TestGetBlobHttpsUrl < Minitest::Test
|
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
81
|
+
def test_get_blob_https_url_with_endpoint_success
|
82
|
+
service = Fog::AzureRM::Storage.new(storage_account_credentials_with_endpoint)
|
83
|
+
signature_client = service.send(:signature_client, Minitest::Mock.new)
|
84
|
+
|
85
|
+
url = 'http://localhost:10000/mockaccount/test_container/test_blob'
|
86
|
+
token = ApiStub::Requests::Storage::File.blob_url_token
|
87
|
+
|
88
|
+
signature_client.stub :generate_service_sas_token, token do
|
89
|
+
assert_equal "#{url}?#{token}", service.get_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600)
|
90
|
+
assert_equal "#{url}?#{token}", service.get_object_url('test_container', 'test_blob', Time.now.utc + 3600)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
76
94
|
def test_get_blob_https_url_with_domain_success
|
77
|
-
service = Fog::Storage
|
78
|
-
|
79
|
-
signature_client = service.instance_variable_get(:@signature_client)
|
95
|
+
service = Fog::AzureRM::Storage.new(storage_account_credentials_with_domain)
|
96
|
+
signature_client = service.send(:signature_client, Minitest::Mock.new)
|
80
97
|
|
81
98
|
url = 'https://mockaccount.test.example.com/test_container/test_blob'
|
82
99
|
token = ApiStub::Requests::Storage::File.blob_url_token
|
83
100
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
101
|
+
signature_client.stub :generate_service_sas_token, token do
|
102
|
+
assert_equal "#{url}?#{token}", service.get_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600)
|
103
|
+
assert_equal "#{url}?#{token}", service.get_object_url('test_container', 'test_blob', Time.now.utc + 3600)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_get_blob_https_url_with_token_signer_success
|
108
|
+
service = Fog::AzureRM::Storage.new(storage_account_credentials_with_token_signer)
|
109
|
+
blob_client = service.instance_variable_get(:@blob_client)
|
110
|
+
|
111
|
+
ref_time = Time.now
|
112
|
+
|
113
|
+
stubbed_times = []
|
114
|
+
requested_expiries = []
|
115
|
+
expected_user_delegation_key_starts = []
|
116
|
+
|
117
|
+
# initial request
|
118
|
+
stubbed_times << ref_time
|
119
|
+
requested_expiries << stubbed_times.last + 1 * HOUR
|
120
|
+
expected_user_delegation_key_starts << stubbed_times.last
|
121
|
+
|
122
|
+
# second request during expiry window
|
123
|
+
stubbed_times << ref_time + 5.5 * DAY
|
124
|
+
requested_expiries << stubbed_times.last + 1 * DAY
|
125
|
+
# no additonal expected_user_delegation_key_starts
|
126
|
+
|
127
|
+
# request extending past current expiry
|
128
|
+
stubbed_times << ref_time + 6.5 * DAY
|
129
|
+
requested_expiries << stubbed_times.last + 1 * DAY
|
130
|
+
expected_user_delegation_key_starts << stubbed_times.last
|
131
|
+
|
132
|
+
# second request within new expiry
|
133
|
+
stubbed_times << ref_time + 10.5 * DAY
|
134
|
+
requested_expiries << stubbed_times.last + 1 * DAY
|
135
|
+
# no additonal expected_user_delegation_key_starts
|
136
|
+
|
137
|
+
user_delegation_key_starts = []
|
138
|
+
mock_user_delegation_key = lambda do |start, expiry|
|
139
|
+
user_delegation_key_starts << start
|
140
|
+
assert_equal 1 * WEEK, expiry - start
|
141
|
+
|
142
|
+
key = Azure::Storage::Common::Service::UserDelegationKey.new
|
143
|
+
key.signed_start = "start-#{start.to_i}"
|
144
|
+
key.signed_expiry = 'test-expiry'
|
145
|
+
key.value = 'delegation-key'
|
146
|
+
key
|
147
|
+
end
|
148
|
+
|
149
|
+
mock_new_signer = lambda do |token|
|
150
|
+
assert_equal 'delegation-key', token
|
151
|
+
mock_token_signer
|
152
|
+
end
|
153
|
+
|
154
|
+
requested_expiries.each do
|
155
|
+
mock_token_signer.expect(:sign, 'test-signature', [/\Ar\n.+test_blob\n.+\nstart-\d+\ntest-expiry/m])
|
156
|
+
end
|
157
|
+
|
158
|
+
Time.stub :now, -> { stubbed_times.first } do
|
159
|
+
blob_client.stub :get_user_delegation_key, mock_user_delegation_key do
|
160
|
+
Azure::Core::Auth::Signer.stub :new, mock_new_signer do
|
161
|
+
while (requested_expiry = requested_expiries.shift)
|
162
|
+
url = service.get_blob_https_url('test_container', 'test_blob', requested_expiry)
|
163
|
+
assert_match(/^#{Regexp.escape @url}.+&skt=start-#{user_delegation_key_starts.last.to_i}&.+&sig=test-signature/, url)
|
164
|
+
|
165
|
+
stubbed_times.shift
|
166
|
+
end
|
167
|
+
end
|
88
168
|
end
|
89
169
|
end
|
170
|
+
|
171
|
+
assert_equal expected_user_delegation_key_starts, user_delegation_key_starts
|
90
172
|
end
|
91
173
|
|
92
174
|
def test_get_blob_https_url_mock
|
@@ -5,11 +5,11 @@ class TestGetBlobProperties < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of getting storage blob properties.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@blob = ApiStub::Requests::Storage::File.blob
|
@@ -5,18 +5,18 @@ class TestGetBlobUrl < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of Blob service.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_get_blob_url_success
|
13
|
-
service = Fog::Storage
|
13
|
+
service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
14
14
|
blob_client = service.instance_variable_get(:@blob_client)
|
15
15
|
|
16
16
|
mock_generate_uri = Minitest::Mock.new
|
17
17
|
url = ApiStub::Requests::Storage::File.blob_https_url
|
18
18
|
2.times do
|
19
|
-
mock_generate_uri.expect(:call, url, ['test_container/test_blob', {}, { encode: true }])
|
19
|
+
mock_generate_uri.expect(:call, URI.parse(url), ['test_container/test_blob', {}, { encode: true }])
|
20
20
|
end
|
21
21
|
|
22
22
|
blob_client.stub :generate_uri, mock_generate_uri do
|
@@ -29,44 +29,35 @@ class TestGetBlobUrl < Minitest::Test
|
|
29
29
|
|
30
30
|
def test_get_blob_url_for_china_success
|
31
31
|
china_storage_account_credentials = storage_account_credentials.merge(environment: Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD)
|
32
|
-
service = Fog::Storage
|
33
|
-
blob_client = service.instance_variable_get(:@blob_client)
|
32
|
+
service = Fog::AzureRM::Storage.new(china_storage_account_credentials)
|
34
33
|
url = ApiStub::Requests::Storage::File.blob_https_url(Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD)
|
35
34
|
|
36
|
-
|
37
|
-
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
35
|
+
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
end
|
37
|
+
options = { scheme: 'http' }
|
38
|
+
assert_equal url.gsub('https:', 'http:'), service.get_blob_url('test_container', 'test_blob', options)
|
42
39
|
end
|
43
40
|
|
44
41
|
def test_get_blob_url_for_us_success
|
45
42
|
us_storage_account_credentials = storage_account_credentials.merge(environment: Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT)
|
46
|
-
service = Fog::Storage
|
47
|
-
blob_client = service.instance_variable_get(:@blob_client)
|
43
|
+
service = Fog::AzureRM::Storage.new(us_storage_account_credentials)
|
48
44
|
url = ApiStub::Requests::Storage::File.blob_https_url(Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT)
|
49
45
|
|
50
|
-
|
51
|
-
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
46
|
+
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
end
|
48
|
+
options = { scheme: 'http' }
|
49
|
+
assert_equal url.gsub('https:', 'http:'), service.get_blob_url('test_container', 'test_blob', options)
|
56
50
|
end
|
57
51
|
|
58
52
|
def test_get_blob_url_for_german_success
|
59
53
|
german_storage_account_credentials = storage_account_credentials.merge(environment: Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD)
|
60
|
-
service = Fog::Storage
|
61
|
-
blob_client = service.instance_variable_get(:@blob_client)
|
54
|
+
service = Fog::AzureRM::Storage.new(german_storage_account_credentials)
|
62
55
|
url = ApiStub::Requests::Storage::File.blob_https_url(Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD)
|
63
56
|
|
64
|
-
|
65
|
-
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
57
|
+
assert_equal url, service.get_blob_url('test_container', 'test_blob')
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
59
|
+
options = { scheme: 'http' }
|
60
|
+
assert_equal url.gsub('https:', 'http:'), service.get_blob_url('test_container', 'test_blob', options)
|
70
61
|
end
|
71
62
|
|
72
63
|
def test_get_blob_url_mock
|
@@ -5,11 +5,11 @@ class TestGetContainerAcl < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of getting storage container acl.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@raw_container_acl = ApiStub::Requests::Storage::Directory.raw_container_acl
|
@@ -5,11 +5,11 @@ class TestGetContainerProperties < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of getting storage container properties.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@container = ApiStub::Requests::Storage::Directory.container
|
@@ -5,22 +5,19 @@ class TestGetContainerUrl < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of getting storage container url.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
|
11
|
-
@service = Fog::Storage
|
12
|
-
@blob_client = @service.instance_variable_get(:@blob_client)
|
11
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
12
|
|
14
13
|
@url = ApiStub::Requests::Storage::Directory.container_https_url
|
15
14
|
end
|
16
15
|
|
17
16
|
def test_get_container_url_success
|
18
|
-
@
|
19
|
-
assert_equal @url, @service.get_container_url('test_container')
|
17
|
+
assert_equal @url, @service.get_container_url('test_container')
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
19
|
+
options = { scheme: 'http' }
|
20
|
+
assert_equal @url.gsub('https:', 'http:'), @service.get_container_url('test_container', options)
|
24
21
|
end
|
25
22
|
|
26
23
|
def test_get_container_url_mock
|
@@ -5,11 +5,11 @@ class TestGetObject < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of getting storage blob.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@raw_cloud_blob = storage_blob
|
@@ -5,11 +5,11 @@ class TestListBlobs < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of listing blobs in storage containers.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@blob_list = ApiStub::Requests::Storage::File.blob_list
|
@@ -5,11 +5,11 @@ class TestListContainers < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of listing storage containers.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@containers = ApiStub::Requests::Storage::Directory.container_list
|
@@ -5,11 +5,11 @@ class TestPutBlobBlock < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of putting blob block.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
end
|
15
15
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestPutBlobHttpUrl < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of Blob service.
|
6
|
+
def setup
|
7
|
+
Fog.mock!
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
|
+
Fog.unmock!
|
10
|
+
|
11
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
12
|
+
@signature_client = @service.send(:signature_client, Minitest::Mock.new)
|
13
|
+
|
14
|
+
@url = ApiStub::Requests::Storage::File.blob_https_url.gsub('https:', 'http:')
|
15
|
+
@token = ApiStub::Requests::Storage::File.blob_url_token
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_put_blob_http_urls_success
|
19
|
+
@signature_client.stub :generate_service_sas_token, @token do
|
20
|
+
assert_equal "#{@url}?#{@token}", @service.put_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_put_url_https_in_container_and_blob_names
|
25
|
+
uri = URI.parse(@service.put_blob_http_url('https://container', 'https://blob', Time.now.utc + 3600))
|
26
|
+
assert_equal 'http', uri.scheme
|
27
|
+
assert_equal '/https://container/https://blob', CGI.unescape(uri.path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_put_blob_http_url_mock
|
31
|
+
assert_equal "#{@url}?#{@token}", @mock_service.put_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600)
|
32
|
+
end
|
33
|
+
end
|
@@ -1,27 +1,24 @@
|
|
1
1
|
require File.expand_path '../../test_helper', __dir__
|
2
2
|
|
3
3
|
# Storage Blob Class
|
4
|
-
class
|
4
|
+
class TestPutBlobHttpsUrl < Minitest::Test
|
5
5
|
# This class posesses the test cases for the requests of Blob service.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
|
11
|
-
@service = Fog::Storage
|
12
|
-
@
|
13
|
-
@signature_client = @service.instance_variable_get(:@signature_client)
|
11
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
12
|
+
@signature_client = @service.send(:signature_client, Minitest::Mock.new)
|
14
13
|
|
15
14
|
@url = ApiStub::Requests::Storage::File.blob_https_url
|
16
15
|
@token = ApiStub::Requests::Storage::File.blob_url_token
|
17
16
|
end
|
18
17
|
|
19
|
-
def
|
20
|
-
@
|
21
|
-
@
|
22
|
-
|
23
|
-
assert_equal "#{@url}?#{@token}", @service.put_object_url('test_container', 'test_blob', Time.now.utc + 3600, {})
|
24
|
-
end
|
18
|
+
def test_put_blob_https_urls_success
|
19
|
+
@signature_client.stub :generate_service_sas_token, @token do
|
20
|
+
assert_equal "#{@url}?#{@token}", @service.put_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600)
|
21
|
+
assert_equal "#{@url}?#{@token}", @service.put_object_url('test_container', 'test_blob', Time.now.utc + 3600, {})
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
@@ -5,11 +5,11 @@ class TestPutBlobMetadata < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of setting blob metadata.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@metadata = ApiStub::Requests::Storage::File.blob_metadata
|
@@ -5,11 +5,11 @@ class TestPutBlobPages < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of putting blob page.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
end
|
15
15
|
|
@@ -5,11 +5,11 @@ class TestPutBlobProperties < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of setting blob properties.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@properties = {
|
@@ -5,11 +5,11 @@ class TestPutContainerACL < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of setting storage container acl.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
end
|
15
15
|
|
@@ -5,11 +5,11 @@ class TestPutContainerMetadata < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of container service.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
|
15
15
|
@metadata = ApiStub::Requests::Storage::Directory.container_metadata
|
@@ -5,11 +5,11 @@ class TestReleaseBlobLease < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of releasing blob lease.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
end
|
15
15
|
|
@@ -5,11 +5,11 @@ class TestReleaseContainerLease < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of releasing container lease.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
14
|
end
|
15
15
|
|
@@ -5,11 +5,11 @@ class TestSavePageBlob < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of saving storage page blob.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
|
12
|
-
@service = Fog::Storage
|
12
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_save_page_blob_success
|
@@ -5,12 +5,12 @@ class TestWaitBlobCopyOperationToFinish < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of waiting storage blob copy operation to finish.
|
6
6
|
def setup
|
7
7
|
Fog.mock!
|
8
|
-
@mock_service = Fog::Storage
|
8
|
+
@mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
9
9
|
Fog.unmock!
|
10
10
|
@mocked_response = mocked_storage_http_error
|
11
11
|
@blob = storage_blob
|
12
12
|
|
13
|
-
@service = Fog::Storage
|
13
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
14
14
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
15
15
|
end
|
16
16
|
|
@@ -49,7 +49,9 @@ class TestWaitBlobCopyOperationToFinish < Minitest::Test
|
|
49
49
|
end
|
50
50
|
|
51
51
|
@service.stub :get_blob_properties, multiple_values do
|
52
|
-
|
52
|
+
@service.stub :sleep, ->(delay) {} do
|
53
|
+
assert @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
@@ -104,10 +106,17 @@ class TestWaitBlobCopyOperationToFinish < Minitest::Test
|
|
104
106
|
@blob
|
105
107
|
end
|
106
108
|
|
109
|
+
stubbed_times = [
|
110
|
+
Time.now,
|
111
|
+
Time.now + 5
|
112
|
+
]
|
113
|
+
|
107
114
|
@service.stub :get_blob_properties, multiple_values do
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
Time.stub :new, -> { stubbed_times.shift } do
|
116
|
+
@service.stub :delete_blob, true do
|
117
|
+
assert_raises(Timeout::Error) do
|
118
|
+
@service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status, 2)
|
119
|
+
end
|
111
120
|
end
|
112
121
|
end
|
113
122
|
end
|