gitlab-fog-azure-rm 1.5.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 +5 -0
- data/lib/fog/azurerm/credentials.rb +6 -2
- data/lib/fog/azurerm/requests/storage/delete_object.rb +2 -7
- data/lib/fog/azurerm/requests/storage/get_object.rb +15 -0
- data/lib/fog/azurerm/storage.rb +1 -0
- data/lib/fog/azurerm/version.rb +1 -1
- data/rakefile +3 -0
- data/test/requests/storage/test_get_blob.rb +15 -0
- data/test/test_credentials.rb +3 -3
- metadata +2 -1
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
|
@@ -3,17 +3,12 @@ module Fog
|
|
3
3
|
class AzureRM
|
4
4
|
# This class provides the actual implementation for service calls.
|
5
5
|
class Real
|
6
|
-
|
7
|
-
delete_blob(container_name, blob_name)
|
8
|
-
end
|
6
|
+
alias delete_object delete_blob
|
9
7
|
end
|
10
8
|
|
11
9
|
# This class provides the mock implementation for unit tests.
|
12
10
|
class Mock
|
13
|
-
|
14
|
-
Fog::Logger.debug 'Blob deleted successfully.'
|
15
|
-
true
|
16
|
-
end
|
11
|
+
alias delete_object delete_blob
|
17
12
|
end
|
18
13
|
end
|
19
14
|
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
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
|
@@ -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
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/fog/azurerm/requests/storage/get_container_acl.rb
|
248
248
|
- lib/fog/azurerm/requests/storage/get_container_properties.rb
|
249
249
|
- lib/fog/azurerm/requests/storage/get_container_url.rb
|
250
|
+
- lib/fog/azurerm/requests/storage/get_object.rb
|
250
251
|
- lib/fog/azurerm/requests/storage/get_object_url.rb
|
251
252
|
- lib/fog/azurerm/requests/storage/list_blobs.rb
|
252
253
|
- lib/fog/azurerm/requests/storage/list_containers.rb
|