gitlab-fog-azure-rm 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/.arclint +8 -0
  3. data/.codeclimate.yml +17 -0
  4. data/.gitignore +6 -0
  5. data/.gitlab-ci.yml +17 -0
  6. data/.hound.yml +2 -0
  7. data/.rubocop.yml +5 -0
  8. data/.rubocop_todo.yml +274 -0
  9. data/.travis.yml +49 -0
  10. data/CHANGELOG.md +414 -0
  11. data/CONTRIBUTING.md +40 -0
  12. data/CONTRIBUTORS.md +12 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE.md +20 -0
  15. data/README.md +100 -0
  16. data/gitlab-fog-azure-rm.gemspec +31 -0
  17. data/lib/fog/azurerm.rb +30 -0
  18. data/lib/fog/azurerm/async_response.rb +44 -0
  19. data/lib/fog/azurerm/config.rb +1 -0
  20. data/lib/fog/azurerm/constants.rb +72 -0
  21. data/lib/fog/azurerm/credentials.rb +40 -0
  22. data/lib/fog/azurerm/custom_fog_errors.rb +52 -0
  23. data/lib/fog/azurerm/docs/storage.md +398 -0
  24. data/lib/fog/azurerm/docs/structure.md +53 -0
  25. data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
  26. data/lib/fog/azurerm/models/resources/azure_resources.rb +40 -0
  27. data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
  28. data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
  29. data/lib/fog/azurerm/models/resources/deployments.rb +30 -0
  30. data/lib/fog/azurerm/models/resources/provider.rb +27 -0
  31. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
  32. data/lib/fog/azurerm/models/resources/resource_group.rb +34 -0
  33. data/lib/fog/azurerm/models/resources/resource_groups.rb +29 -0
  34. data/lib/fog/azurerm/models/storage/directories.rb +75 -0
  35. data/lib/fog/azurerm/models/storage/directory.rb +151 -0
  36. data/lib/fog/azurerm/models/storage/file.rb +265 -0
  37. data/lib/fog/azurerm/models/storage/files.rb +183 -0
  38. data/lib/fog/azurerm/models/storage/kind.rb +12 -0
  39. data/lib/fog/azurerm/models/storage/sku_name.rb +15 -0
  40. data/lib/fog/azurerm/models/storage/sku_tier.rb +12 -0
  41. data/lib/fog/azurerm/models/storage/storage_account.rb +92 -0
  42. data/lib/fog/azurerm/models/storage/storage_accounts.rb +47 -0
  43. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +32 -0
  44. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +32 -0
  45. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +30 -0
  46. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
  47. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
  48. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  49. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  50. data/lib/fog/azurerm/requests/storage/copy_object.rb +20 -0
  51. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
  52. data/lib/fog/azurerm/requests/storage/create_container.rb +40 -0
  53. data/lib/fog/azurerm/requests/storage/create_disk.rb +62 -0
  54. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
  55. data/lib/fog/azurerm/requests/storage/delete_blob.rb +32 -0
  56. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +39 -0
  57. data/lib/fog/azurerm/requests/storage/delete_container.rb +31 -0
  58. data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
  59. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +30 -0
  60. data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
  61. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
  62. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
  63. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +55 -0
  64. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
  65. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
  66. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +41 -0
  67. data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
  68. data/lib/fog/azurerm/requests/storage/get_object_url.rb +21 -0
  69. data/lib/fog/azurerm/requests/storage/list_blobs.rb +168 -0
  70. data/lib/fog/azurerm/requests/storage/list_containers.rb +73 -0
  71. data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
  72. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
  73. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +39 -0
  74. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +31 -0
  75. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
  76. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
  77. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
  78. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +31 -0
  79. data/lib/fog/azurerm/requests/storage/put_object_url.rb +30 -0
  80. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +30 -0
  81. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +30 -0
  82. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
  83. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
  84. data/lib/fog/azurerm/storage.rb +126 -0
  85. data/lib/fog/azurerm/utilities/general.rb +186 -0
  86. data/lib/fog/azurerm/utilities/logger_messages.yml +19 -0
  87. data/lib/fog/azurerm/version.rb +5 -0
  88. data/rake-script.sh +10 -0
  89. data/rakefile +29 -0
  90. data/test/api_stub.rb +147 -0
  91. data/test/api_stub/models/storage/directory.rb +178 -0
  92. data/test/api_stub/models/storage/file.rb +181 -0
  93. data/test/api_stub/requests/storage/directory.rb +89 -0
  94. data/test/api_stub/requests/storage/file.rb +252 -0
  95. data/test/integration/README.md +14 -0
  96. data/test/integration/blob.rb +297 -0
  97. data/test/integration/container.rb +160 -0
  98. data/test/integration/credentials/azure.yml +5 -0
  99. data/test/integration/storage_account.rb +135 -0
  100. data/test/models/storage/test_directories.rb +74 -0
  101. data/test/models/storage/test_directory.rb +178 -0
  102. data/test/models/storage/test_file.rb +294 -0
  103. data/test/models/storage/test_files.rb +234 -0
  104. data/test/requests/storage/test_acquire_blob_lease.rb +36 -0
  105. data/test/requests/storage/test_acquire_container_lease.rb +36 -0
  106. data/test/requests/storage/test_check_container_exists.rb +18 -0
  107. data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
  108. data/test/requests/storage/test_compare_container_blobs.rb +36 -0
  109. data/test/requests/storage/test_copy_blob.rb +39 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +36 -0
  111. data/test/requests/storage/test_create_block_blob.rb +80 -0
  112. data/test/requests/storage/test_create_container.rb +36 -0
  113. data/test/requests/storage/test_create_disk.rb +70 -0
  114. data/test/requests/storage/test_create_page_blob.rb +34 -0
  115. data/test/requests/storage/test_delete_blob.rb +42 -0
  116. data/test/requests/storage/test_delete_blob_https_url.rb +32 -0
  117. data/test/requests/storage/test_delete_container.rb +42 -0
  118. data/test/requests/storage/test_delete_disk.rb +30 -0
  119. data/test/requests/storage/test_get_blob.rb +141 -0
  120. data/test/requests/storage/test_get_blob_http_url.rb +30 -0
  121. data/test/requests/storage/test_get_blob_https_url.rb +32 -0
  122. data/test/requests/storage/test_get_blob_properties.rb +47 -0
  123. data/test/requests/storage/test_get_blob_url.rb +75 -0
  124. data/test/requests/storage/test_get_container_acl.rb +37 -0
  125. data/test/requests/storage/test_get_container_properties.rb +45 -0
  126. data/test/requests/storage/test_get_container_url.rb +33 -0
  127. data/test/requests/storage/test_list_blobs.rb +77 -0
  128. data/test/requests/storage/test_list_containers.rb +54 -0
  129. data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
  130. data/test/requests/storage/test_put_blob_block.rb +34 -0
  131. data/test/requests/storage/test_put_blob_https_url.rb +32 -0
  132. data/test/requests/storage/test_put_blob_metadata.rb +36 -0
  133. data/test/requests/storage/test_put_blob_pages.rb +34 -0
  134. data/test/requests/storage/test_put_blob_properties.rb +39 -0
  135. data/test/requests/storage/test_put_container_acl.rb +34 -0
  136. data/test/requests/storage/test_put_container_metadata.rb +36 -0
  137. data/test/requests/storage/test_release_blob_lease.rb +34 -0
  138. data/test/requests/storage/test_release_container_lease.rb +34 -0
  139. data/test/requests/storage/test_save_page_blob.rb +115 -0
  140. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
  141. data/test/smoke_tests/compute/test_resource_group_smoke.rb +37 -0
  142. data/test/test_credentials.rb +63 -0
  143. data/test/test_helper.rb +846 -0
  144. metadata +352 -0
@@ -0,0 +1,234 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Blob Collection
4
+ class TestFiles < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
7
+ @directory = directory(@service)
8
+ @files = @directory.files
9
+
10
+ @mocked_response = mocked_storage_http_error
11
+ @container = ApiStub::Models::Storage::File.container
12
+ @blob = ApiStub::Models::Storage::File.blob
13
+ @blob_list = ApiStub::Models::Storage::File.blob_list
14
+ @blob_https_url = ApiStub::Models::Storage::File.blob_https_url
15
+ end
16
+
17
+ def test_collection_methods
18
+ methods = [
19
+ :all,
20
+ :each,
21
+ :each_file_this_page,
22
+ :get,
23
+ :get_url,
24
+ :get_http_url,
25
+ :get_https_url,
26
+ :head,
27
+ :new
28
+ ]
29
+ methods.each do |method|
30
+ assert_respond_to @files, method
31
+ end
32
+ end
33
+
34
+ def test_collection_attributes
35
+ attributes = [
36
+ :directory,
37
+ :delimiter,
38
+ :marker,
39
+ :max_results,
40
+ :next_marker,
41
+ :prefix
42
+ ]
43
+ attributes.each do |attribute|
44
+ assert_respond_to @files, attribute
45
+ end
46
+ end
47
+
48
+ def test_all_method
49
+ @service.stub :get_container_properties, @container do
50
+ @service.stub :list_blobs, @blob_list do
51
+ files = @files.all
52
+ assert_instance_of Fog::Storage::AzureRM::Files, files
53
+ assert_equal @blob_list[:blobs].size, files.size
54
+ end
55
+ end
56
+ end
57
+
58
+ def test_all_method_without_directory_exception
59
+ assert_raises(ArgumentError) do
60
+ @files.attributes.delete(:directory)
61
+ @files.all
62
+ end
63
+ end
64
+
65
+ def test_all_method_container_not_found
66
+ @directory.collection.stub :get, nil do
67
+ assert @files.all.nil?
68
+ end
69
+ end
70
+
71
+ def test_each_method_with_all
72
+ @blob_list[:next_marker] = nil
73
+ @blob_list[:marker] = nil
74
+ @service.stub :get_container_properties, @container do
75
+ @service.stub :list_blobs, @blob_list do
76
+ @files.next_marker = nil
77
+ j = 0
78
+ @files.each do |file|
79
+ assert_instance_of Fog::Storage::AzureRM::File, file
80
+ j += 1
81
+ end
82
+ assert_equal @blob_list[:blobs].size, j
83
+ end
84
+ end
85
+ end
86
+
87
+ def test_each_method_with_parts
88
+ assert_instance_of Fog::Storage::AzureRM::Files, @files.each
89
+
90
+ multiple_values = lambda do |_container_name, options|
91
+ if options[:marker] == 'marker'
92
+ return {
93
+ next_marker: nil,
94
+ blobs: @blob_list[:blobs][2, 2]
95
+ }
96
+ end
97
+ return {
98
+ next_marker: 'marker',
99
+ blobs: @blob_list[:blobs][0, 2]
100
+ }
101
+ end
102
+
103
+ @service.stub :get_container_properties, @container do
104
+ @service.stub :list_blobs, multiple_values do
105
+ j = 0
106
+ @files.each do |file|
107
+ assert_instance_of Fog::Storage::AzureRM::File, file
108
+ j += 1
109
+ end
110
+ assert_equal @blob_list[:blobs].size, j
111
+ end
112
+ end
113
+ end
114
+
115
+ def test_get_method_success
116
+ content = 'data'
117
+ @service.stub :get_blob, [@blob, content] do
118
+ file = @files.get('test_blob')
119
+ assert_instance_of Fog::Storage::AzureRM::File, file
120
+ assert_equal content, file.body
121
+ end
122
+ end
123
+
124
+ def test_get_method_without_directory_exception
125
+ assert_raises(ArgumentError) do
126
+ @files.attributes.delete(:directory)
127
+ @files.get('test_blob')
128
+ end
129
+ end
130
+
131
+ def test_get_method_blob_not_found
132
+ exception = ->(*) { raise 'NotFound' }
133
+ @service.stub :get_blob, exception do
134
+ assert @files.get('test_blob').nil?
135
+ end
136
+ end
137
+
138
+ def test_get_method_http_exception
139
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
140
+ @service.stub :get_blob, http_exception do
141
+ assert_raises(Azure::Core::Http::HTTPError) do
142
+ @files.get('test_blob')
143
+ end
144
+ end
145
+ end
146
+
147
+ def test_get_url_method_success
148
+ @files.stub :get_https_url, @blob_https_url do
149
+ assert_equal @blob_https_url, @files.get_url('test_blob', Time.now + 3600)
150
+ end
151
+
152
+ options = { scheme: 'http' }
153
+ http_url = @blob_https_url.gsub('https:', 'http:')
154
+ @files.stub :get_http_url, http_url do
155
+ assert_equal http_url, @files.get_url('test_blob', Time.now + 3600, options)
156
+ end
157
+ end
158
+
159
+ def test_get_url_method_without_directory_exception
160
+ assert_raises(ArgumentError) do
161
+ @files.attributes.delete(:directory)
162
+ @files.get_url('test_blob', Time.now + 3600)
163
+ end
164
+ end
165
+
166
+ def test_get_http_url_method_success
167
+ http_url = @blob_https_url.gsub('https:', 'http:')
168
+ @service.stub :get_blob_http_url, http_url do
169
+ assert_equal http_url, @files.get_http_url('test_blob', Time.now + 3600)
170
+ end
171
+ end
172
+
173
+ def test_get_http_url_method_without_directory_exception
174
+ assert_raises(ArgumentError) do
175
+ @files.attributes.delete(:directory)
176
+ @files.get_http_url('test_blob', Time.now + 3600)
177
+ end
178
+ end
179
+
180
+ def test_get_https_url_method_success
181
+ @service.stub :get_blob_https_url, @blob_https_url do
182
+ assert_equal @blob_https_url, @files.get_https_url('test_blob', Time.now + 3600)
183
+ end
184
+ end
185
+
186
+ def test_get_https_url_method_without_directory_exception
187
+ assert_raises(ArgumentError) do
188
+ @files.attributes.delete(:directory)
189
+ @files.get_https_url('test_blob', Time.now + 3600)
190
+ end
191
+ end
192
+
193
+ def test_head_method_success
194
+ @service.stub :get_blob_properties, @blob do
195
+ file = @files.head('test_blob')
196
+ assert_instance_of Fog::Storage::AzureRM::File, file
197
+ assert file.attributes[:body].nil?
198
+ end
199
+ end
200
+
201
+ def test_head_method_without_directory_exception
202
+ assert_raises(ArgumentError) do
203
+ @files.attributes.delete(:directory)
204
+ @files.head('test_blob')
205
+ end
206
+ end
207
+
208
+ def test_head_method_blob_not_found
209
+ exception = ->(*) { raise 'NotFound' }
210
+ @service.stub :get_blob_properties, exception do
211
+ assert @files.head('test_blob').nil?
212
+ end
213
+ end
214
+
215
+ def test_head_method_http_exception
216
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
217
+ @service.stub :get_blob_properties, http_exception do
218
+ assert_raises(Azure::Core::Http::HTTPError) do
219
+ @files.head('test_blob')
220
+ end
221
+ end
222
+ end
223
+
224
+ def test_new_method_success
225
+ assert_instance_of Fog::Storage::AzureRM::File, @files.new
226
+ end
227
+
228
+ def test_new_method_without_directory_exception
229
+ assert_raises(ArgumentError) do
230
+ @files.attributes.delete(:directory)
231
+ @files.new
232
+ end
233
+ end
234
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestAcquireBlobLease < Minitest::Test
5
+ # This class posesses the test cases for the requests of acquire blob lease.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+
15
+ @blob_lease_id = ApiStub::Requests::Storage::File.blob_lease_id
16
+ end
17
+
18
+ def test_acquire_blob_lease_success
19
+ @blob_client.stub :acquire_blob_lease, @blob_lease_id do
20
+ assert_equal @blob_lease_id, @service.acquire_blob_lease('test_container', 'test_blob')
21
+ end
22
+ end
23
+
24
+ def test_acquire_blob_lease_http_exception
25
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
26
+ @blob_client.stub :acquire_blob_lease, http_exception do
27
+ assert_raises(Azure::Core::Http::HTTPError) do
28
+ @service.acquire_blob_lease('test_container', 'test_blob')
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_acquire_blob_lease_mock
34
+ assert_equal @blob_lease_id, @mock_service.acquire_blob_lease('test_container', 'test_blob')
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Container Class
4
+ class TestAcquireContainerLease < Minitest::Test
5
+ # This class posesses the test cases for the requests of acquire container lease.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+
15
+ @container_lease_id = ApiStub::Requests::Storage::Directory.container_lease_id
16
+ end
17
+
18
+ def test_acquire_container_lease_success
19
+ @blob_client.stub :acquire_container_lease, @container_lease_id do
20
+ assert_equal @container_lease_id, @service.acquire_container_lease('test_container')
21
+ end
22
+ end
23
+
24
+ def test_acquire_container_lease_http_exception
25
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
26
+ @blob_client.stub :acquire_container_lease, http_exception do
27
+ assert_raises(Azure::Core::Http::HTTPError) do
28
+ @service.acquire_container_lease('test_container')
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_acquire_container_lease_mock
34
+ assert_equal @container_lease_id, @mock_service.acquire_container_lease('test_container')
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Container Class
4
+ class TestCheckContainerExists < Minitest::Test
5
+ # This class posesses the test cases for the requests of checking container exists.
6
+ def setup
7
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
8
+ @blob_client = @service.instance_variable_get(:@blob_client)
9
+
10
+ @container = ApiStub::Requests::Storage::Directory.container
11
+ end
12
+
13
+ def test_check_container_exists_success
14
+ @blob_client.stub :get_container_properties, @container do
15
+ assert_equal @service.check_container_exists('test_container'), true
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestCommitBlobBlocks < Minitest::Test
5
+ # This class posesses the test cases for the requests of committing blob blocks.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+ end
15
+
16
+ def test_commit_blob_blocks_success
17
+ @blob_client.stub :commit_blob_blocks, true do
18
+ assert @service.commit_blob_blocks('test_container', 'test_blob', [])
19
+ end
20
+ end
21
+
22
+ def test_commit_blob_blocks_http_exception
23
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
24
+ @blob_client.stub :commit_blob_blocks, http_exception do
25
+ assert_raises(Azure::Core::Http::HTTPError) do
26
+ @service.commit_blob_blocks('test_container', 'test_blob', [])
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_commit_blob_blocks_mock
32
+ assert @mock_service.commit_blob_blocks('test_container', 'test_blob', [])
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestCompareContainerBlobs < Minitest::Test
5
+ # This class posesses the test cases for the requests of comparing blobs.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+
15
+ @blob_list = ApiStub::Requests::Storage::File.blob_list
16
+ end
17
+
18
+ def test_compare_container_blobs_success
19
+ @service.stub :get_identical_blobs_from_containers, @blob_list do
20
+ assert_equal @blob_list, @service.compare_container_blobs('test_container1', 'test_container2')
21
+ end
22
+ end
23
+
24
+ def test_compare_container_blobs_http_exception
25
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
26
+ @service.stub :get_identical_blobs_from_containers, http_exception do
27
+ assert_raises(Azure::Core::Http::HTTPError) do
28
+ @service.compare_container_blobs('test_container1', 'test_container2')
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_compare_container_blobs_mock
34
+ assert_equal @blob_list, @mock_service.compare_container_blobs('test_container1', 'test_container2')
35
+ end
36
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestCopyBlob < Minitest::Test
5
+ # This class posesses the test cases for the requests of copying blobs.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+
15
+ @blob_copy_result = ApiStub::Requests::Storage::File.blob_copy_result
16
+ end
17
+
18
+ def test_copy_blob_success
19
+ @blob_client.stub :copy_blob, @blob_copy_result do
20
+ assert_equal @blob_copy_result, @service.copy_blob('destination_container', 'destination_blob', 'source_container', 'source_blob')
21
+ assert_equal @blob_copy_result, @service.copy_object('destination_container', 'destination_blob', 'source_container', 'source_blob')
22
+ end
23
+ end
24
+
25
+ def test_copy_blob_http_exception
26
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
27
+ @blob_client.stub :copy_blob, http_exception do
28
+ assert_raises(Azure::Core::Http::HTTPError) do
29
+ @service.copy_blob('destination_container', 'destination_blob', 'source_container', 'source_blob')
30
+ @service.copy_object('destination_container', 'destination_blob', 'source_container', 'source_blob')
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_copy_blob_mock
36
+ assert_equal @blob_copy_result, @mock_service.copy_blob('destination_container', 'destination_blob', 'source_container', 'source_blob')
37
+ assert_equal @blob_copy_result, @mock_service.copy_object('destination_container', 'destination_blob', 'source_container', 'source_blob')
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestCopyBlobFromUri < Minitest::Test
5
+ # This class posesses the test cases for the requests of copying blobs from uri.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+
15
+ @blob_copy_result = ApiStub::Requests::Storage::File.blob_copy_result
16
+ end
17
+
18
+ def test_copy_blob_from_uri_success
19
+ @blob_client.stub :copy_blob_from_uri, @blob_copy_result do
20
+ assert_equal @blob_copy_result, @service.copy_blob_from_uri('destination_container', 'destination_blob', 'source_uri')
21
+ end
22
+ end
23
+
24
+ def test_copy_blob_from_uri_http_exception
25
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
26
+ @blob_client.stub :copy_blob_from_uri, http_exception do
27
+ assert_raises(Azure::Core::Http::HTTPError) do
28
+ @service.copy_blob_from_uri('destination_container', 'destination_blob', 'source_uri')
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_copy_blob_from_uri_mock
34
+ assert_equal @blob_copy_result, @mock_service.copy_blob_from_uri('destination_container', 'destination_blob', 'source_uri')
35
+ end
36
+ end