gitlab-fog-azure-rm 1.7.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +12 -0
  3. data/.rubocop_todo.yml +1 -1
  4. data/CHANGELOG.md +4 -0
  5. data/gitlab-fog-azure-rm.gemspec +3 -3
  6. data/lib/fog/azurerm/constants.rb +0 -6
  7. data/lib/fog/azurerm/custom_fog_errors.rb +0 -41
  8. data/lib/fog/azurerm/docs/storage.md +1 -1
  9. data/lib/fog/azurerm/identity_encoding_filter.rb +12 -0
  10. data/lib/fog/azurerm/models/storage/directories.rb +6 -6
  11. data/lib/fog/azurerm/models/storage/directory.rb +4 -4
  12. data/lib/fog/azurerm/models/storage/file.rb +6 -3
  13. data/lib/fog/azurerm/models/storage/files.rb +8 -8
  14. data/lib/fog/azurerm/models/storage/storage_account.rb +4 -4
  15. data/lib/fog/azurerm/models/storage/storage_accounts.rb +6 -6
  16. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +2 -2
  17. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +2 -2
  18. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +2 -2
  19. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +2 -2
  20. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +2 -2
  21. data/lib/fog/azurerm/requests/storage/copy_blob.rb +2 -2
  22. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +2 -2
  23. data/lib/fog/azurerm/requests/storage/copy_object.rb +2 -2
  24. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +2 -2
  25. data/lib/fog/azurerm/requests/storage/create_container.rb +2 -2
  26. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +2 -2
  27. data/lib/fog/azurerm/requests/storage/delete_blob.rb +2 -2
  28. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +4 -4
  29. data/lib/fog/azurerm/requests/storage/delete_container.rb +2 -2
  30. data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -2
  31. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +2 -2
  32. data/lib/fog/azurerm/requests/storage/get_blob.rb +2 -2
  33. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +5 -5
  34. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +6 -5
  35. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +2 -2
  36. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +4 -4
  37. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +2 -2
  38. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +2 -2
  39. data/lib/fog/azurerm/requests/storage/get_container_url.rb +4 -4
  40. data/lib/fog/azurerm/requests/storage/get_object.rb +2 -2
  41. data/lib/fog/azurerm/requests/storage/get_object_url.rb +2 -2
  42. data/lib/fog/azurerm/requests/storage/list_blobs.rb +2 -2
  43. data/lib/fog/azurerm/requests/storage/list_containers.rb +2 -2
  44. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +2 -2
  45. data/lib/fog/azurerm/requests/storage/put_blob_http_url.rb +39 -0
  46. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +4 -4
  47. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +2 -2
  48. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +2 -2
  49. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +2 -2
  50. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +2 -2
  51. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +2 -2
  52. data/lib/fog/azurerm/requests/storage/put_object_url.rb +2 -2
  53. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +2 -2
  54. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +2 -2
  55. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +2 -2
  56. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +2 -2
  57. data/lib/fog/azurerm/storage.rb +62 -27
  58. data/lib/fog/azurerm/utilities/general.rb +2 -58
  59. data/lib/fog/azurerm/version.rb +1 -1
  60. data/lib/fog/azurerm.rb +4 -11
  61. data/rakefile +4 -5
  62. data/test/api_stub/models/storage/directory.rb +1 -1
  63. data/test/api_stub/models/storage/file.rb +1 -1
  64. data/test/api_stub/requests/storage/directory.rb +1 -1
  65. data/test/api_stub/requests/storage/file.rb +4 -4
  66. data/test/integration/README.md +5 -7
  67. data/test/integration/blob.rb +28 -36
  68. data/test/integration/container.rb +8 -39
  69. data/test/integration/credentials/azure.yml +4 -5
  70. data/test/models/storage/test_directories.rb +5 -5
  71. data/test/models/storage/test_directory.rb +2 -2
  72. data/test/models/storage/test_file.rb +16 -4
  73. data/test/models/storage/test_files.rb +8 -8
  74. data/test/requests/storage/test_acquire_blob_lease.rb +2 -2
  75. data/test/requests/storage/test_acquire_container_lease.rb +2 -2
  76. data/test/requests/storage/test_check_container_exists.rb +1 -1
  77. data/test/requests/storage/test_commit_blob_blocks.rb +2 -2
  78. data/test/requests/storage/test_compare_container_blobs.rb +2 -2
  79. data/test/requests/storage/test_copy_blob.rb +2 -2
  80. data/test/requests/storage/test_copy_blob_from_uri.rb +2 -2
  81. data/test/requests/storage/test_create_block_blob.rb +2 -2
  82. data/test/requests/storage/test_create_container.rb +2 -2
  83. data/test/requests/storage/test_create_page_blob.rb +2 -2
  84. data/test/requests/storage/test_delete_blob.rb +2 -2
  85. data/test/requests/storage/test_delete_blob_https_url.rb +7 -10
  86. data/test/requests/storage/test_delete_container.rb +2 -2
  87. data/test/requests/storage/test_delete_object.rb +2 -2
  88. data/test/requests/storage/test_get_blob.rb +2 -2
  89. data/test/requests/storage/test_get_blob_encoding.rb +45 -0
  90. data/test/requests/storage/test_get_blob_http_url.rb +13 -9
  91. data/test/requests/storage/test_get_blob_https_url.rb +95 -13
  92. data/test/requests/storage/test_get_blob_properties.rb +2 -2
  93. data/test/requests/storage/test_get_blob_url.rb +15 -24
  94. data/test/requests/storage/test_get_container_acl.rb +2 -2
  95. data/test/requests/storage/test_get_container_properties.rb +2 -2
  96. data/test/requests/storage/test_get_container_url.rb +5 -8
  97. data/test/requests/storage/test_get_object.rb +2 -2
  98. data/test/requests/storage/test_list_blobs.rb +2 -2
  99. data/test/requests/storage/test_list_containers.rb +2 -2
  100. data/test/requests/storage/test_put_blob_block.rb +2 -2
  101. data/test/requests/storage/test_put_blob_http_url.rb +33 -0
  102. data/test/requests/storage/test_put_blob_https_url.rb +8 -11
  103. data/test/requests/storage/test_put_blob_metadata.rb +2 -2
  104. data/test/requests/storage/test_put_blob_pages.rb +2 -2
  105. data/test/requests/storage/test_put_blob_properties.rb +2 -2
  106. data/test/requests/storage/test_put_container_acl.rb +2 -2
  107. data/test/requests/storage/test_put_container_metadata.rb +2 -2
  108. data/test/requests/storage/test_release_blob_lease.rb +2 -2
  109. data/test/requests/storage/test_release_container_lease.rb +2 -2
  110. data/test/requests/storage/test_save_page_blob.rb +2 -2
  111. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +15 -6
  112. data/test/test_helper.rb +38 -698
  113. metadata +27 -36
  114. data/lib/fog/azurerm/credentials.rb +0 -44
  115. data/lib/fog/azurerm/models/resources/azure_resource.rb +0 -25
  116. data/lib/fog/azurerm/models/resources/azure_resources.rb +0 -40
  117. data/lib/fog/azurerm/models/resources/dependency.rb +0 -27
  118. data/lib/fog/azurerm/models/resources/deployment.rb +0 -65
  119. data/lib/fog/azurerm/models/resources/deployments.rb +0 -30
  120. data/lib/fog/azurerm/models/resources/provider.rb +0 -27
  121. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +0 -22
  122. data/lib/fog/azurerm/models/resources/resource_group.rb +0 -34
  123. data/lib/fog/azurerm/models/resources/resource_groups.rb +0 -29
  124. data/test/integration/storage_account.rb +0 -135
  125. data/test/smoke_tests/compute/test_resource_group_smoke.rb +0 -37
  126. data/test/test_credentials.rb +0 -63
@@ -8,28 +8,11 @@ require 'yaml'
8
8
 
9
9
  azure_credentials = YAML.load_file(File.expand_path('credentials/azure.yml', __dir__))
10
10
 
11
- rs = Fog::Resources::AzureRM.new(
12
- tenant_id: azure_credentials['tenant_id'],
13
- client_id: azure_credentials['client_id'],
14
- client_secret: azure_credentials['client_secret'],
15
- subscription_id: azure_credentials['subscription_id']
16
- )
17
-
18
- storage = Fog::Storage::AzureRM.new(
19
- tenant_id: azure_credentials['tenant_id'],
20
- client_id: azure_credentials['client_id'],
21
- client_secret: azure_credentials['client_secret'],
22
- subscription_id: azure_credentials['subscription_id'],
23
- environment: azure_credentials['environment']
24
- )
25
-
26
11
  ########################################################################################################################
27
12
  ###################### Resource names #####################
28
13
  ########################################################################################################################
29
14
 
30
- time = current_time
31
- resource_group_name = "Blob-RG-#{time}"
32
- storage_account_name = "sa#{time}"
15
+ time = Time.now.to_i
33
16
  container_name = "con#{time}"
34
17
  test_container_name = "tcon#{time}"
35
18
 
@@ -38,36 +21,25 @@ test_container_name = "tcon#{time}"
38
21
  ########################################################################################################################
39
22
 
40
23
  begin
41
- resource_group = rs.resource_groups.create(
42
- name: resource_group_name,
43
- location: LOCATION
44
- )
45
-
46
- storage_account = storage.storage_accounts.create(
47
- name: storage_account_name,
48
- location: LOCATION,
49
- resource_group: resource_group_name
50
- )
51
-
52
- access_key = storage_account.get_access_keys[0].value
53
- Fog::Logger.debug access_key.inspect
54
24
  storage_data = Fog::Storage.new(
55
25
  provider: 'AzureRM',
56
- azure_storage_account_name: storage_account.name,
57
- azure_storage_access_key: access_key,
26
+ azure_storage_account_name: azure_credentials['azure_storage_account_name'],
27
+ azure_storage_access_key: azure_credentials['azure_storage_access_key'],
28
+ azure_storage_endpoint: azure_credentials['azure_storage_endpoint'],
58
29
  environment: azure_credentials['environment']
59
30
  )
31
+ scheme = URI.parse(azure_credentials.fetch('azure_storage_endpoint', 'https:')).scheme
60
32
 
61
33
  ########################################################################################################################
62
34
  ###################### Create Container ######################
63
35
  ########################################################################################################################
64
36
 
65
- storage_data.directories.create(
37
+ test_container1 = storage_data.directories.create(
66
38
  key: container_name,
67
39
  public: true
68
40
  )
69
41
 
70
- storage_data.directories.create(
42
+ test_container2 = storage_data.directories.create(
71
43
  key: test_container_name,
72
44
  public: false
73
45
  )
@@ -270,6 +242,24 @@ begin
270
242
 
271
243
  puts "Get a http URL with expires: #{test_blob.url(Time.now + 3600, scheme: 'http')}"
272
244
 
245
+ ########################################################################################################################
246
+ ###################### Test generated GET and PUT URLs ######################
247
+ ########################################################################################################################
248
+
249
+ url_blob_name = 'url-test.txt'
250
+ url_blob_content = 'Hello world.'
251
+ get_url = storage_data.public_send("get_blob_#{scheme}_url", container_name, url_blob_name, Time.now + 3600)
252
+ put_url = storage_data.public_send("put_blob_#{scheme}_url", container_name, url_blob_name, Time.now + 3600)
253
+
254
+ response = Faraday.put(put_url, url_blob_content, 'x-ms-blob-type' => 'BlockBlob')
255
+ raise unless response.success?
256
+ puts 'Uploaded blob using PUT blob URL'
257
+
258
+ response = Faraday.get(get_url)
259
+ raise unless response.success?
260
+ raise unless response.body == url_blob_content
261
+ puts 'Downloaded blob using GET blob URL'
262
+
273
263
  ########################################################################################################################
274
264
  ###################### Lease Blob ######################
275
265
  ########################################################################################################################
@@ -292,6 +282,8 @@ begin
292
282
  puts "Deleted blob: #{blob.destroy}"
293
283
  rescue => ex
294
284
  puts "Integration Test for blob is failing: #{ex.inspect}\n#{ex.backtrace.join("\n")}"
285
+ raise
295
286
  ensure
296
- resource_group.destroy unless resource_group.nil?
287
+ test_container1&.destroy
288
+ test_container2&.destroy
297
289
  end
@@ -8,28 +8,11 @@ require 'yaml'
8
8
 
9
9
  azure_credentials = YAML.load_file(File.expand_path('credentials/azure.yml', __dir__))
10
10
 
11
- rs = Fog::Resources::AzureRM.new(
12
- tenant_id: azure_credentials['tenant_id'],
13
- client_id: azure_credentials['client_id'],
14
- client_secret: azure_credentials['client_secret'],
15
- subscription_id: azure_credentials['subscription_id']
16
- )
17
-
18
- storage = Fog::Storage::AzureRM.new(
19
- tenant_id: azure_credentials['tenant_id'],
20
- client_id: azure_credentials['client_id'],
21
- client_secret: azure_credentials['client_secret'],
22
- subscription_id: azure_credentials['subscription_id'],
23
- environment: azure_credentials['environment']
24
- )
25
-
26
11
  ########################################################################################################################
27
12
  ###################### Resource names #####################
28
13
  ########################################################################################################################
29
14
 
30
- time = current_time
31
- resource_group_name = "Blob-RG-#{time}"
32
- storage_account_name = "sa#{time}"
15
+ time = Time.now.to_i
33
16
  container_name = "con#{time}"
34
17
  test_container_name = "tcon#{time}"
35
18
 
@@ -38,25 +21,10 @@ test_container_name = "tcon#{time}"
38
21
  ########################################################################################################################
39
22
 
40
23
  begin
41
- resource_group = rs.resource_groups.create(
42
- name: resource_group_name,
43
- location: LOCATION
44
- )
45
-
46
- storage_account_name = "sa#{current_time}"
47
-
48
- storage_account = storage.storage_accounts.create(
49
- name: storage_account_name,
50
- location: LOCATION,
51
- resource_group: resource_group_name
52
- )
53
-
54
- keys = storage_account.get_access_keys
55
- access_key = keys.first.value
56
-
57
- storage_data = Fog::Storage::AzureRM.new(
58
- azure_storage_account_name: storage_account.name,
59
- azure_storage_access_key: access_key,
24
+ storage_data = Fog::AzureRM::Storage.new(
25
+ azure_storage_account_name: azure_credentials['azure_storage_account_name'],
26
+ azure_storage_access_key: azure_credentials['azure_storage_access_key'],
27
+ azure_storage_endpoint: azure_credentials['azure_storage_endpoint'],
60
28
  environment: azure_credentials['environment']
61
29
  )
62
30
 
@@ -76,7 +44,7 @@ begin
76
44
  )
77
45
  puts "Created container: #{container.key}"
78
46
 
79
- storage_data.directories.create(
47
+ container2 = storage_data.directories.create(
80
48
  key: test_container_name,
81
49
  public: true
82
50
  )
@@ -155,6 +123,7 @@ begin
155
123
  puts "Deleted container: #{container.destroy}"
156
124
  rescue => ex
157
125
  puts "Integration Test for container is failing: #{ex.inspect}\n#{ex.backtrace.join("\n")}"
126
+ raise
158
127
  ensure
159
- resource_group.destroy unless resource_group.nil?
128
+ container2&.destroy
160
129
  end
@@ -1,5 +1,4 @@
1
- client_id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2
- client_secret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
3
- subscription_id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4
- tenant_id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
5
- environment: XXXXXXXX
1
+ azure_storage_account_name: devstoreaccount1
2
+ azure_storage_access_key: Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
3
+ azure_storage_endpoint: http://azurite:10000/devstoreaccount1
4
+ environment: AzureCloud
@@ -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