gitlab-fog-azure-rm 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/fog/azurerm/credentials.rb +6 -2
- data/lib/fog/azurerm/requests/storage/delete_object.rb +15 -0
- data/lib/fog/azurerm/requests/storage/get_object.rb +15 -0
- data/lib/fog/azurerm/storage.rb +3 -1
- data/lib/fog/azurerm/version.rb +1 -1
- data/rakefile +3 -0
- data/test/requests/storage/test_delete_object.rb +42 -0
- data/test/requests/storage/test_get_blob.rb +15 -0
- data/test/test_credentials.rb +3 -3
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e22573f58ecdd3a318e5b75145645b6828d557320e00d3833ac6bb552c12a27
|
4
|
+
data.tar.gz: 02e55258c8128b9e00cdcf1d4659e270b58f9382b362555c49a73f260586e129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65983b2a6caa2de4444fdde0b27053519588df069809894445c52123242afedfc3f5357434c754b361e5234eae5230ac86c1b3d208b10ea2615fbdb74bb8e347
|
7
|
+
data.tar.gz: bad2b6523176bc008228137172e50f1059333f59428de88e7cc237892650056e92987aff983436ef1086b12cdf8c5e72f4cf0c7727059b88b6af5fcd71a3f224
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@ module Fog
|
|
2
2
|
module Credentials
|
3
3
|
# This class is managing credentials token
|
4
4
|
class AzureRM
|
5
|
-
|
5
|
+
class << self
|
6
|
+
include Fog::AzureRM::Utilities::General
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.get_credentials(tenant_id, client_id, client_secret, environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
|
6
10
|
if @credentials.nil? || new_management_credential?(tenant_id, client_id, client_secret, environment)
|
7
11
|
get_new_credentials(tenant_id, client_id, client_secret, environment)
|
8
12
|
else
|
@@ -10,7 +14,7 @@ module Fog
|
|
10
14
|
end
|
11
15
|
end
|
12
16
|
|
13
|
-
def self.get_token(tenant_id, client_id, client_secret, environment = ENVIRONMENT_AZURE_CLOUD)
|
17
|
+
def self.get_token(tenant_id, client_id, client_secret, environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
|
14
18
|
get_credentials(tenant_id, client_id, client_secret, environment) if @credentials.nil?
|
15
19
|
@token_provider.get_authentication_header
|
16
20
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implementation for service calls.
|
5
|
+
class Real
|
6
|
+
alias delete_object delete_blob
|
7
|
+
end
|
8
|
+
|
9
|
+
# This class provides the mock implementation for unit tests.
|
10
|
+
class Mock
|
11
|
+
alias delete_object delete_blob
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Fog
|
2
|
+
module Storage
|
3
|
+
class AzureRM
|
4
|
+
# This class provides the actual implemention for service calls.
|
5
|
+
class Real
|
6
|
+
alias get_object get_blob
|
7
|
+
end
|
8
|
+
|
9
|
+
# This class provides the mock implementation for unit tests.
|
10
|
+
class Mock
|
11
|
+
alias get_object get_blob
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/fog/azurerm/storage.rb
CHANGED
@@ -40,9 +40,9 @@ module Fog
|
|
40
40
|
request :compare_container_blobs
|
41
41
|
request :acquire_blob_lease
|
42
42
|
request :release_blob_lease
|
43
|
-
request :delete_blob
|
44
43
|
request :get_blob
|
45
44
|
request :get_blob_url
|
45
|
+
request :get_object
|
46
46
|
request :get_object_url
|
47
47
|
request :get_blob_http_url
|
48
48
|
request :get_blob_https_url
|
@@ -50,8 +50,10 @@ module Fog
|
|
50
50
|
request :put_blob_block
|
51
51
|
request :put_blob_https_url
|
52
52
|
request :put_object_url
|
53
|
+
request :delete_blob
|
53
54
|
request :delete_blob_https_url
|
54
55
|
request :delete_object_url
|
56
|
+
request :delete_object
|
55
57
|
request :commit_blob_blocks
|
56
58
|
request :create_page_blob
|
57
59
|
request :put_blob_pages
|
data/lib/fog/azurerm/version.rb
CHANGED
data/rakefile
CHANGED
@@ -5,6 +5,7 @@ task default: :cc_coverage
|
|
5
5
|
task :test do
|
6
6
|
ENV['COVERAGE'] = nil
|
7
7
|
ENV['CODECLIMATE_REPO_TOKEN'] = nil
|
8
|
+
Dir.glob('test/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
8
9
|
Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
9
10
|
Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
10
11
|
end
|
@@ -13,6 +14,7 @@ desc 'Generates a coverage report for minitest-cases using simple-cov'
|
|
13
14
|
task :coverage do
|
14
15
|
ENV['CODECLIMATE_REPO_TOKEN'] = nil
|
15
16
|
ENV['COVERAGE'] = 'true'
|
17
|
+
Dir.glob('test/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
16
18
|
Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
17
19
|
Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
18
20
|
end
|
@@ -21,6 +23,7 @@ desc 'Generates a coverage report for minitest-cases using code-climate'
|
|
21
23
|
task :cc_coverage do
|
22
24
|
ENV['COVERAGE'] = nil
|
23
25
|
ENV['CODECLIMATE_REPO_TOKEN'] = 'b1401494baa004d90402414cb33a7fc6420fd3693e60c677a120ddefd7d84cfd'
|
26
|
+
Dir.glob('test/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
24
27
|
Dir.glob('test/models/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
25
28
|
Dir.glob('test/requests/**/test_*.rb').each { |file| require File.expand_path file, __dir__ }
|
26
29
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestDeleteObject < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of deleting storage 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
|
+
@mocked_not_found_response = mocked_storage_http_not_found_error
|
12
|
+
|
13
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
14
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_delete_object_success
|
18
|
+
@blob_client.stub :delete_blob, true do
|
19
|
+
assert @service.delete_object('test_container', 'test_blob')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_delete_object_with_not_found_success
|
24
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_not_found_response) }
|
25
|
+
@blob_client.stub :delete_blob, http_exception do
|
26
|
+
assert @service.delete_object('test_container', 'test_blob')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_delete_object_http_exception
|
31
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
32
|
+
@blob_client.stub :delete_blob, http_exception do
|
33
|
+
assert_raises(Azure::Core::Http::HTTPError) do
|
34
|
+
@service.delete_object('test_container', 'test_blob')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_delete_object_mock
|
40
|
+
assert @mock_service.delete_blob('test_container', 'test_blob')
|
41
|
+
end
|
42
|
+
end
|
@@ -26,6 +26,12 @@ class TestGetBlob < Minitest::Test
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def test_get_object_success
|
30
|
+
@blob_client.stub :get_blob, @blob_with_content do
|
31
|
+
assert_equal @blob_with_content, @service.get_object('test_container', 'test_blob')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
29
35
|
def test_get_blob_not_found
|
30
36
|
exception = ->(*) { raise StandardError.new('Not found(404). Not exist') }
|
31
37
|
@blob_client.stub :get_blob, exception do
|
@@ -35,6 +41,15 @@ class TestGetBlob < Minitest::Test
|
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
44
|
+
def test_get_object_not_found
|
45
|
+
exception = ->(*) { raise StandardError.new('Not found(404). Not exist') }
|
46
|
+
@blob_client.stub :get_blob, exception do
|
47
|
+
assert_raises('NotFound') do
|
48
|
+
@service.get_object('test_container', 'test_blob')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
def test_get_blob_http_exception
|
39
54
|
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
40
55
|
@blob_client.stub :get_blob, http_exception do
|
data/test/test_credentials.rb
CHANGED
@@ -38,7 +38,7 @@ class TestCredentials < Minitest::Test
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_get_token_method_with_china_environment
|
41
|
-
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], ENVIRONMENT_AZURE_CHINA_CLOUD)
|
41
|
+
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD)
|
42
42
|
token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
43
43
|
token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
44
44
|
assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
|
@@ -46,7 +46,7 @@ class TestCredentials < Minitest::Test
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_get_token_method_with_us_government_environment
|
49
|
-
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], ENVIRONMENT_AZURE_US_GOVERNMENT)
|
49
|
+
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT)
|
50
50
|
token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
51
51
|
token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
52
52
|
assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
|
@@ -54,7 +54,7 @@ class TestCredentials < Minitest::Test
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_get_token_method_with_german_environment
|
57
|
-
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], ENVIRONMENT_AZURE_GERMAN_CLOUD)
|
57
|
+
Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD)
|
58
58
|
token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
59
59
|
token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
60
60
|
assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-fog-azure-rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaffan Chaudhry
|
@@ -18,7 +18,7 @@ authors:
|
|
18
18
|
autorequire:
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
|
-
date:
|
21
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: codeclimate-test-reporter
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- lib/fog/azurerm/requests/storage/delete_blob.rb
|
238
238
|
- lib/fog/azurerm/requests/storage/delete_blob_https_url.rb
|
239
239
|
- lib/fog/azurerm/requests/storage/delete_container.rb
|
240
|
+
- lib/fog/azurerm/requests/storage/delete_object.rb
|
240
241
|
- lib/fog/azurerm/requests/storage/delete_object_url.rb
|
241
242
|
- lib/fog/azurerm/requests/storage/get_blob.rb
|
242
243
|
- lib/fog/azurerm/requests/storage/get_blob_http_url.rb
|
@@ -246,6 +247,7 @@ files:
|
|
246
247
|
- lib/fog/azurerm/requests/storage/get_container_acl.rb
|
247
248
|
- lib/fog/azurerm/requests/storage/get_container_properties.rb
|
248
249
|
- lib/fog/azurerm/requests/storage/get_container_url.rb
|
250
|
+
- lib/fog/azurerm/requests/storage/get_object.rb
|
249
251
|
- lib/fog/azurerm/requests/storage/get_object_url.rb
|
250
252
|
- lib/fog/azurerm/requests/storage/list_blobs.rb
|
251
253
|
- lib/fog/azurerm/requests/storage/list_containers.rb
|
@@ -294,6 +296,7 @@ files:
|
|
294
296
|
- test/requests/storage/test_delete_blob.rb
|
295
297
|
- test/requests/storage/test_delete_blob_https_url.rb
|
296
298
|
- test/requests/storage/test_delete_container.rb
|
299
|
+
- test/requests/storage/test_delete_object.rb
|
297
300
|
- test/requests/storage/test_get_blob.rb
|
298
301
|
- test/requests/storage/test_get_blob_http_url.rb
|
299
302
|
- test/requests/storage/test_get_blob_https_url.rb
|
@@ -338,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
341
|
- !ruby/object:Gem::Version
|
339
342
|
version: '0'
|
340
343
|
requirements: []
|
341
|
-
rubygems_version: 3.
|
344
|
+
rubygems_version: 3.4.7
|
342
345
|
signing_key:
|
343
346
|
specification_version: 4
|
344
347
|
summary: Module for the 'fog' gem to support Azure Blob Storage with CarrierWave and
|