gitlab-fog-azure-rm 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -3,8 +3,8 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Container Collection
|
4
4
|
class TestDirectories < Minitest::Test
|
5
5
|
def setup
|
6
|
-
@service = Fog::Storage
|
7
|
-
@directories = Fog::Storage::
|
6
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
7
|
+
@directories = Fog::AzureRM::Storage::Directories.new(service: @service)
|
8
8
|
|
9
9
|
@container_list = ApiStub::Models::Storage::Directory.container_list
|
10
10
|
@container = ApiStub::Models::Storage::Directory.container
|
@@ -25,10 +25,10 @@ class TestDirectories < Minitest::Test
|
|
25
25
|
def test_all_method_success
|
26
26
|
@service.stub :list_containers, @container_list do
|
27
27
|
dirs = @directories.all
|
28
|
-
assert_instance_of Fog::Storage::
|
28
|
+
assert_instance_of Fog::AzureRM::Storage::Directories, dirs
|
29
29
|
assert_equal @container_list.size, dirs.size
|
30
30
|
dirs.each do |directory|
|
31
|
-
assert_instance_of Fog::Storage::
|
31
|
+
assert_instance_of Fog::AzureRM::Storage::Directory, directory
|
32
32
|
assert_equal 'unknown', directory.attributes[:acl]
|
33
33
|
end
|
34
34
|
end
|
@@ -38,7 +38,7 @@ class TestDirectories < Minitest::Test
|
|
38
38
|
@service.stub :get_container_properties, @container do
|
39
39
|
@service.stub :list_blobs, @blob_list do
|
40
40
|
directory = @directories.get('test_container')
|
41
|
-
assert_instance_of Fog::Storage::
|
41
|
+
assert_instance_of Fog::AzureRM::Storage::Directory, directory
|
42
42
|
assert_equal 'unknown', directory.attributes[:acl]
|
43
43
|
end
|
44
44
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Storage Container Model
|
4
4
|
class TestDirectory < Minitest::Test
|
5
5
|
def setup
|
6
|
-
@service = Fog::Storage
|
6
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
7
7
|
@directory = directory(@service)
|
8
8
|
|
9
9
|
@container = ApiStub::Models::Storage::Directory.container
|
@@ -100,7 +100,7 @@ class TestDirectory < Minitest::Test
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def test_files_method_success
|
103
|
-
assert_instance_of Fog::Storage::
|
103
|
+
assert_instance_of Fog::AzureRM::Storage::Files, @directory.files
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_set_public_method_success
|
@@ -3,7 +3,7 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Storage Container Model
|
4
4
|
class TestFile < Minitest::Test # rubocop:disable Metrics/ClassLength
|
5
5
|
def setup
|
6
|
-
@service = Fog::Storage
|
6
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
7
7
|
@directory = directory(@service)
|
8
8
|
@file = file(@service)
|
9
9
|
@raw_cloud_blob = storage_blob
|
@@ -171,7 +171,7 @@ class TestFile < Minitest::Test # rubocop:disable Metrics/ClassLength
|
|
171
171
|
@service.stub :copy_blob, [copy_id, copy_status] do
|
172
172
|
@service.stub :wait_blob_copy_operation_to_finish, true do
|
173
173
|
target_file = @file.copy('target_container', 'target_blob')
|
174
|
-
assert_instance_of Fog::Storage::
|
174
|
+
assert_instance_of Fog::AzureRM::Storage::File, target_file
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
@@ -290,8 +290,20 @@ class TestFile < Minitest::Test # rubocop:disable Metrics/ClassLength
|
|
290
290
|
end
|
291
291
|
|
292
292
|
def test_url_method_with_response_content_disposition
|
293
|
-
|
294
|
-
|
293
|
+
fake = Minitest::Mock.new
|
294
|
+
expiry = Time.now + 3600
|
295
|
+
fake.expect :call, nil, [@file.key, expiry, { content_disposition: 'attachment', content_type: nil }]
|
296
|
+
@file.collection.stub(:get_url, fake) do
|
297
|
+
@file.url(expiry, { query: { 'response-content-disposition' => 'attachment' } })
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_url_method_with_response_content_type
|
302
|
+
fake = Minitest::Mock.new
|
303
|
+
expiry = Time.now + 3600
|
304
|
+
fake.expect :call, nil, [@file.key, expiry, { content_disposition: nil, content_type: 'image/png' }]
|
305
|
+
@file.collection.stub(:get_url, fake) do
|
306
|
+
@file.url(expiry, { query: { 'response-content-type' => 'image/png' } })
|
295
307
|
end
|
296
308
|
end
|
297
309
|
|
@@ -3,7 +3,7 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Blob Collection
|
4
4
|
class TestFiles < Minitest::Test
|
5
5
|
def setup
|
6
|
-
@service = Fog::Storage
|
6
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
7
7
|
@directory = directory(@service)
|
8
8
|
@files = @directory.files
|
9
9
|
|
@@ -49,7 +49,7 @@ class TestFiles < Minitest::Test
|
|
49
49
|
@service.stub :get_container_properties, @container do
|
50
50
|
@service.stub :list_blobs, @blob_list do
|
51
51
|
files = @files.all
|
52
|
-
assert_instance_of Fog::Storage::
|
52
|
+
assert_instance_of Fog::AzureRM::Storage::Files, files
|
53
53
|
assert_equal @blob_list[:blobs].size, files.size
|
54
54
|
end
|
55
55
|
end
|
@@ -76,7 +76,7 @@ class TestFiles < Minitest::Test
|
|
76
76
|
@files.next_marker = nil
|
77
77
|
j = 0
|
78
78
|
@files.each do |file|
|
79
|
-
assert_instance_of Fog::Storage::
|
79
|
+
assert_instance_of Fog::AzureRM::Storage::File, file
|
80
80
|
j += 1
|
81
81
|
end
|
82
82
|
assert_equal @blob_list[:blobs].size, j
|
@@ -85,7 +85,7 @@ class TestFiles < Minitest::Test
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_each_method_with_parts
|
88
|
-
assert_instance_of Fog::Storage::
|
88
|
+
assert_instance_of Fog::AzureRM::Storage::Files, @files.each
|
89
89
|
|
90
90
|
multiple_values = lambda do |_container_name, options|
|
91
91
|
if options[:marker] == 'marker'
|
@@ -104,7 +104,7 @@ class TestFiles < Minitest::Test
|
|
104
104
|
@service.stub :list_blobs, multiple_values do
|
105
105
|
j = 0
|
106
106
|
@files.each do |file|
|
107
|
-
assert_instance_of Fog::Storage::
|
107
|
+
assert_instance_of Fog::AzureRM::Storage::File, file
|
108
108
|
j += 1
|
109
109
|
end
|
110
110
|
assert_equal @blob_list[:blobs].size, j
|
@@ -116,7 +116,7 @@ class TestFiles < Minitest::Test
|
|
116
116
|
content = 'data'
|
117
117
|
@service.stub :get_blob, [@blob, content] do
|
118
118
|
file = @files.get('test_blob')
|
119
|
-
assert_instance_of Fog::Storage::
|
119
|
+
assert_instance_of Fog::AzureRM::Storage::File, file
|
120
120
|
assert_equal content, file.body
|
121
121
|
end
|
122
122
|
end
|
@@ -193,7 +193,7 @@ class TestFiles < Minitest::Test
|
|
193
193
|
def test_head_method_success
|
194
194
|
@service.stub :get_blob_properties, @blob do
|
195
195
|
file = @files.head('test_blob')
|
196
|
-
assert_instance_of Fog::Storage::
|
196
|
+
assert_instance_of Fog::AzureRM::Storage::File, file
|
197
197
|
assert file.attributes[:body].nil?
|
198
198
|
end
|
199
199
|
end
|
@@ -222,7 +222,7 @@ class TestFiles < Minitest::Test
|
|
222
222
|
end
|
223
223
|
|
224
224
|
def test_new_method_success
|
225
|
-
assert_instance_of Fog::Storage::
|
225
|
+
assert_instance_of Fog::AzureRM::Storage::File, @files.new
|
226
226
|
end
|
227
227
|
|
228
228
|
def test_new_method_without_directory_exception
|
@@ -5,11 +5,11 @@ class TestAcquireBlobLease < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of acquire 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
|
|
15
15
|
@blob_lease_id = ApiStub::Requests::Storage::File.blob_lease_id
|
@@ -5,11 +5,11 @@ class TestAcquireContainerLease < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of acquire 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
|
|
15
15
|
@container_lease_id = ApiStub::Requests::Storage::Directory.container_lease_id
|
@@ -4,7 +4,7 @@ require File.expand_path '../../test_helper', __dir__
|
|
4
4
|
class TestCheckContainerExists < Minitest::Test
|
5
5
|
# This class posesses the test cases for the requests of checking container exists.
|
6
6
|
def setup
|
7
|
-
@service = Fog::Storage
|
7
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
8
8
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
9
|
|
10
10
|
@container = ApiStub::Requests::Storage::Directory.container
|
@@ -5,11 +5,11 @@ class TestCommitBlobBlocks < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of committing blob blocks.
|
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 TestCompareContainerBlobs < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of comparing blobs.
|
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 TestCopyBlob < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of copying blobs.
|
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_copy_result = ApiStub::Requests::Storage::File.blob_copy_result
|
@@ -5,11 +5,11 @@ class TestCopyBlobFromUri < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of copying blobs from uri.
|
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_copy_result = ApiStub::Requests::Storage::File.blob_copy_result
|
@@ -5,11 +5,11 @@ class TestCreateBlockBlob < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of creating block 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
|
@block_blob = ApiStub::Requests::Storage::File.block_blob
|
@@ -5,11 +5,11 @@ class TestCreateContainer < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of creating 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
|
@container = ApiStub::Requests::Storage::Directory.container
|
@@ -5,11 +5,11 @@ class TestCreatePageBlob < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of creating storage page blobs.
|
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,12 +5,12 @@ class TestDeleteBlob < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of deleting storage blobs.
|
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
|
@mocked_not_found_response = mocked_storage_http_not_found_error
|
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
|
|
@@ -1,27 +1,24 @@
|
|
1
1
|
require File.expand_path '../../test_helper', __dir__
|
2
2
|
|
3
3
|
# Storage Blob Class
|
4
|
-
class
|
4
|
+
class TestDeleteBlobHttpsUrl < 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
18
|
def test_delete_blob_http_urls_success
|
20
|
-
@
|
21
|
-
@
|
22
|
-
|
23
|
-
assert_equal "#{@url}?#{@token}", @service.delete_object_url('test_container', 'test_blob', Time.now.utc + 3600)
|
24
|
-
end
|
19
|
+
@signature_client.stub :generate_service_sas_token, @token do
|
20
|
+
assert_equal "#{@url}?#{@token}", @service.delete_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600)
|
21
|
+
assert_equal "#{@url}?#{@token}", @service.delete_object_url('test_container', 'test_blob', Time.now.utc + 3600)
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
@@ -5,12 +5,12 @@ class TestDeleteContainer < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of deleting 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
|
@mocked_not_found_response = mocked_storage_http_not_found_error
|
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
|
|
@@ -5,12 +5,12 @@ class TestDeleteObject < Minitest::Test
|
|
5
5
|
# This class posesses the test cases for the requests of deleting storage blobs.
|
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
|
@mocked_not_found_response = mocked_storage_http_not_found_error
|
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
|
|
@@ -5,11 +5,11 @@ class TestGetBlob < 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
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
require 'webrick'
|
4
|
+
|
5
|
+
class TestGetBlobGzipped < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@server = WEBrick::HTTPServer.new(
|
8
|
+
BindAddress: '127.0.0.1',
|
9
|
+
Port: 0,
|
10
|
+
Logger: WEBrick::Log.new(nil, 0),
|
11
|
+
AccessLog: []
|
12
|
+
)
|
13
|
+
@server_uri = URI.parse("http://#{@server.config.values_at(:BindAddress, :Port).join(':')}/test")
|
14
|
+
@thread = Thread.new do
|
15
|
+
@server.start
|
16
|
+
end
|
17
|
+
|
18
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
19
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
@server&.shutdown
|
24
|
+
@thread&.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_blob_with_encoding
|
28
|
+
io = StringIO.new.binmode
|
29
|
+
gzip = Zlib::GzipWriter.new(io)
|
30
|
+
gzip.write "Hello world.\n"
|
31
|
+
gzip.close
|
32
|
+
|
33
|
+
@server.mount_proc '/' do |_request, response|
|
34
|
+
response.header['Content-Encoding'] = 'gzip'
|
35
|
+
response.body = io.string
|
36
|
+
end
|
37
|
+
|
38
|
+
blob, content = @blob_client.stub :generate_uri, @server_uri do
|
39
|
+
@service.get_blob('test_container', 'test_blob')
|
40
|
+
end
|
41
|
+
|
42
|
+
assert_equal 'gzip', blob.properties[:content_encoding]
|
43
|
+
assert_equal io.string, content
|
44
|
+
end
|
45
|
+
end
|
@@ -5,22 +5,20 @@ class TestGetBlobHttpUrl < 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
|
11
|
+
@service = Fog::AzureRM::Storage.new(storage_account_credentials)
|
12
12
|
@blob_client = @service.instance_variable_get(:@blob_client)
|
13
|
-
@signature_client = @service.
|
13
|
+
@signature_client = @service.send(:signature_client, Minitest::Mock.new)
|
14
14
|
|
15
15
|
@url = ApiStub::Requests::Storage::File.blob_https_url.gsub('https:', 'http:')
|
16
16
|
@token = ApiStub::Requests::Storage::File.blob_url_token
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_get_blob_http_url_success
|
20
|
-
@
|
21
|
-
@
|
22
|
-
assert_equal "#{@url}?#{@token}", @service.get_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600)
|
23
|
-
end
|
20
|
+
@signature_client.stub :generate_service_sas_token, @token do
|
21
|
+
assert_equal "#{@url}?#{@token}", @service.get_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -29,7 +27,7 @@ class TestGetBlobHttpUrl < Minitest::Test
|
|
29
27
|
mock_generate_service_token = Minitest::Mock.new
|
30
28
|
url_params = { content_disposition: 'attachment' }
|
31
29
|
|
32
|
-
mock_generate_uri.expect(:call, @url, ['test_container/test_blob', {}, { encode: true }])
|
30
|
+
mock_generate_uri.expect(:call, URI.parse(@url), ['test_container/test_blob', {}, { encode: true }])
|
33
31
|
mock_generate_service_token.expect(:call, @token) do |_relative_path, params|
|
34
32
|
params[:service] == 'b' &&
|
35
33
|
params[:resource] == 'b' &&
|
@@ -49,7 +47,7 @@ class TestGetBlobHttpUrl < Minitest::Test
|
|
49
47
|
mock_generate_uri = Minitest::Mock.new
|
50
48
|
mock_generate_service_token = Minitest::Mock.new
|
51
49
|
|
52
|
-
mock_generate_uri.expect(:call, @url, ['.test0/..test1/...test2', {}, { encode: true }])
|
50
|
+
mock_generate_uri.expect(:call, URI.parse(@url), ['.test0/..test1/...test2', {}, { encode: true }])
|
53
51
|
mock_generate_service_token.expect(:call, @token) do |relative_path, _|
|
54
52
|
relative_path == '.test0/..test1/...test2'
|
55
53
|
end
|
@@ -61,6 +59,12 @@ class TestGetBlobHttpUrl < Minitest::Test
|
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
62
|
+
def test_get_url_https_in_container_and_blob_names
|
63
|
+
uri = URI.parse(@service.get_blob_http_url('https://container', 'https://blob', Time.now.utc + 3600))
|
64
|
+
assert_equal 'http', uri.scheme
|
65
|
+
assert_equal '/https://container/https://blob', CGI.unescape(uri.path)
|
66
|
+
end
|
67
|
+
|
64
68
|
def test_get_blob_http_url_mock
|
65
69
|
assert_equal "#{@url}?#{@token}", @mock_service.get_blob_http_url('test_container', 'test_blob', Time.now.utc + 3600)
|
66
70
|
end
|