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.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +12 -0
  3. data/.rubocop_todo.yml +1 -1
  4. data/gitlab-fog-azure-rm.gemspec +3 -2
  5. data/lib/fog/azurerm/docs/storage.md +1 -1
  6. data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
  7. data/lib/fog/azurerm/models/storage/directories.rb +6 -6
  8. data/lib/fog/azurerm/models/storage/directory.rb +4 -4
  9. data/lib/fog/azurerm/models/storage/file.rb +6 -3
  10. data/lib/fog/azurerm/models/storage/files.rb +8 -8
  11. data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
  12. data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
  13. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
  14. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
  15. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
  16. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
  17. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
  18. data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
  19. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
  20. data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
  21. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
  22. data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
  23. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
  24. data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
  25. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
  26. data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
  27. data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
  28. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
  29. data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
  30. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
  31. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
  32. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
  33. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
  34. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
  35. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
  36. data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
  37. data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
  38. data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
  39. data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
  40. data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
  41. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
  42. data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
  43. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
  44. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
  45. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
  46. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
  47. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
  48. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
  49. data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
  50. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
  51. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
  52. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
  53. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
  54. data/lib/fog/azurerm/storage.rb +62 -9
  55. data/lib/fog/azurerm/utilities/general.rb +0 -5
  56. data/lib/fog/azurerm/version.rb +1 -1
  57. data/lib/fog/azurerm.rb +4 -5
  58. data/rakefile +4 -5
  59. data/test/api_stub/models/storage/directory.rb +1 -1
  60. data/test/api_stub/models/storage/file.rb +1 -1
  61. data/test/api_stub/requests/storage/directory.rb +1 -1
  62. data/test/api_stub/requests/storage/file.rb +4 -4
  63. data/test/integration/README.md +5 -7
  64. data/test/integration/blob.rb +28 -36
  65. data/test/integration/container.rb +8 -39
  66. data/test/integration/credentials/azure.yml +4 -5
  67. data/test/models/storage/test_directories.rb +5 -5
  68. data/test/models/storage/test_directory.rb +2 -2
  69. data/test/models/storage/test_file.rb +16 -4
  70. data/test/models/storage/test_files.rb +8 -8
  71. data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
  72. data/test/requests/storage/test_acquire_container_lease.rb +2 -2
  73. data/test/requests/storage/test_check_container_exists.rb +1 -1
  74. data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
  75. data/test/requests/storage/test_compare_container_blobs.rb +2 -2
  76. data/test/requests/storage/test_copy_blob.rb +2 -2
  77. data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
  78. data/test/requests/storage/test_create_block_blob.rb +2 -2
  79. data/test/requests/storage/test_create_container.rb +2 -2
  80. data/test/requests/storage/test_create_page_blob.rb +2 -2
  81. data/test/requests/storage/test_delete_blob.rb +2 -2
  82. data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
  83. data/test/requests/storage/test_delete_container.rb +2 -2
  84. data/test/requests/storage/test_delete_object.rb +2 -2
  85. data/test/requests/storage/test_get_blob.rb +2 -2
  86. data/test/requests/storage/test_get_blob_encoding.rb +45 -0
  87. data/test/requests/storage/test_get_blob_http_url.rb +13 -9
  88. data/test/requests/storage/test_get_blob_https_url.rb +95 -13
  89. data/test/requests/storage/test_get_blob_properties.rb +2 -2
  90. data/test/requests/storage/test_get_blob_url.rb +15 -24
  91. data/test/requests/storage/test_get_container_acl.rb +2 -2
  92. data/test/requests/storage/test_get_container_properties.rb +2 -2
  93. data/test/requests/storage/test_get_container_url.rb +5 -8
  94. data/test/requests/storage/test_get_object.rb +2 -2
  95. data/test/requests/storage/test_list_blobs.rb +2 -2
  96. data/test/requests/storage/test_list_containers.rb +2 -2
  97. data/test/requests/storage/test_put_blob_block.rb +2 -2
  98. data/test/requests/storage/test_put_blob_http_url.rb +33 -0
  99. data/test/requests/storage/test_put_blob_https_url.rb +8 -11
  100. data/test/requests/storage/test_put_blob_metadata.rb +2 -2
  101. data/test/requests/storage/test_put_blob_pages.rb +2 -2
  102. data/test/requests/storage/test_put_blob_properties.rb +2 -2
  103. data/test/requests/storage/test_put_container_acl.rb +2 -2
  104. data/test/requests/storage/test_put_container_metadata.rb +2 -2
  105. data/test/requests/storage/test_release_blob_lease.rb +2 -2
  106. data/test/requests/storage/test_release_container_lease.rb +2 -2
  107. data/test/requests/storage/test_save_page_blob.rb +2 -2
  108. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
  109. data/test/test_helper.rb +38 -690
  110. metadata +27 -20
  111. data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
  112. data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
  113. data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
  114. data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
  115. data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
  116. data/lib/fog/azurerm/models/resources/provider.rb +0 -27
  117. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
  118. data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
  119. data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
  120. data/test/integration/storage_account.rb +0 -135
  121. 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::AzureRM.new(storage_account_credentials)
7
- @directories = Fog::Storage::AzureRM::Directories.new(service: @service)
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::AzureRM::Directories, dirs
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::AzureRM::Directory, directory
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::AzureRM::Directory, directory
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::AzureRM.new(storage_account_credentials)
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::AzureRM::Files, @directory.files
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::AzureRM.new(storage_account_credentials)
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::AzureRM::File, target_file
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
- @file.collection.stub :get_url, @blob_https_url, { content_disposition: 'attachment' } do
294
- assert @file.url(Time.now + 3600, { query: { 'response-content-disposition' => 'attachment' } }), @blob_https_url
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::AzureRM.new(storage_account_credentials)
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::AzureRM::Files, files
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::AzureRM::File, file
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::AzureRM::Files, @files.each
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::AzureRM::File, file
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::AzureRM::File, file
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::AzureRM::File, file
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::AzureRM::File, @files.new
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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 TestPutBlobHttpUrl < Minitest::Test
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::AzureRM.new(storage_account_credentials)
8
+ @mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
9
9
  Fog.unmock!
10
10
 
11
- @service = Fog::Storage::AzureRM.new(storage_account_credentials)
12
- @blob_client = @service.instance_variable_get(:@blob_client)
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
- @blob_client.stub :generate_uri, @url do
21
- @signature_client.stub :generate_service_sas_token, @token do
22
- assert_equal "#{@url}?#{@token}", @service.delete_blob_https_url('test_container', 'test_blob', Time.now.utc + 3600)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
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::AzureRM.new(storage_account_credentials)
8
+ @mock_service = Fog::AzureRM::Storage.new(storage_account_credentials)
9
9
  Fog.unmock!
10
10
 
11
- @service = Fog::Storage::AzureRM.new(storage_account_credentials)
11
+ @service = Fog::AzureRM::Storage.new(storage_account_credentials)
12
12
  @blob_client = @service.instance_variable_get(:@blob_client)
13
- @signature_client = @service.instance_variable_get(:@signature_client)
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
- @blob_client.stub :generate_uri, @url do
21
- @signature_client.stub :generate_service_sas_token, @token do
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