gitlab-fog-azure-rm 1.6.0 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e22573f58ecdd3a318e5b75145645b6828d557320e00d3833ac6bb552c12a27
4
- data.tar.gz: 02e55258c8128b9e00cdcf1d4659e270b58f9382b362555c49a73f260586e129
3
+ metadata.gz: e159dfc8b3cace029e335019a550572fd139b03621711088ef223f87989b0b97
4
+ data.tar.gz: aaebbcfd822283723b45ebb2db3a1588a67ca90b26cd1ddc319630f21131338d
5
5
  SHA512:
6
- metadata.gz: 65983b2a6caa2de4444fdde0b27053519588df069809894445c52123242afedfc3f5357434c754b361e5234eae5230ac86c1b3d208b10ea2615fbdb74bb8e347
7
- data.tar.gz: bad2b6523176bc008228137172e50f1059333f59428de88e7cc237892650056e92987aff983436ef1086b12cdf8c5e72f4cf0c7727059b88b6af5fcd71a3f224
6
+ metadata.gz: 28dd5cd1ed31cad829892047887b48790f78370fa2b2e56fd5f5aa57140347cb7f31db8fc03d37552ffdfe0bcda6a6a219541b713d9b286c7d0a833934785ebe
7
+ data.tar.gz: 7604dd353e7d0345943e4d90bdc77184ca293deb605d1d3682a293107ae55c38026cde9e88f5ddee3c60c709046dd742a5d08864b8b601fa7609a33d8c807e55
data/.gitlab-ci.yml CHANGED
@@ -14,7 +14,7 @@ test:
14
14
  - bundle exec rake test
15
15
  parallel:
16
16
  matrix:
17
- - RUBY_VERSION: [ "2.7", "3.0", "3.1" ]
17
+ - RUBY_VERSION: [ "2.7", "3.0", "3.1", "3.2" ]
18
18
 
19
19
  rubocop:
20
20
  script:
data/.rubocop.yml CHANGED
@@ -2,4 +2,4 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
4
  NewCops: enable
5
-
5
+ TargetRubyVersion: 2.7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.8.0
4
+
5
+ - Remove deprecated ms_rest_azure dependency (thanks to @jasoncodes) !38
6
+
7
+ ## 1.7.0
8
+
9
+ - Fix #get_object return type to be consistent with other Fog providers !36
10
+ - Require Ruby 2.7+ !36
11
+
3
12
  ## 1.6.0
4
13
 
5
14
  - Add get_object request method !34
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = 'https://gitlab.com/gitlab-org/gitlab-fog-azure-rm'
16
16
  spec.rdoc_options = %w[--charset=UTF-8]
17
17
  spec.extra_rdoc_files = %w[README.md]
18
- spec.required_ruby_version = '>= 2.0.0'
18
+ spec.required_ruby_version = '>= 2.7.0'
19
19
  spec.post_install_message = 'Thanks for installing!'
20
20
  spec.add_development_dependency 'codeclimate-test-reporter' , '~> 1.0.0'
21
21
  spec.add_development_dependency 'minitest', '~> 5.8.4'
@@ -27,5 +27,4 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'fog-core', '= 2.1.0'
28
28
  spec.add_dependency 'fog-json', '~> 1.2.0'
29
29
  spec.add_dependency 'mime-types'
30
- spec.add_dependency 'ms_rest_azure', '~> 0.12.0'
31
30
  end
@@ -34,12 +34,6 @@ module Fog
34
34
  ENVIRONMENT_AZURE_US_GOVERNMENT = 'AzureUSGovernment'.freeze
35
35
  ENVIRONMENT_AZURE_GERMAN_CLOUD = 'AzureGermanCloud'.freeze
36
36
 
37
- # MsRestAzure::AzureOperationError class Error Codes
38
- ERROR_CODE_RESOURCE_NOT_FOUND = 'ResourceNotFound'.freeze
39
- ERROR_CODE_NOT_FOUND = 'NotFound'.freeze
40
- ERROR_CODE_RESOURCE_GROUP_NOT_FOUND = 'ResourceGroupNotFound'.freeze
41
- ERROR_CODE_PARENT_RESOURCE_NOT_FOUND = 'ParentResourceNotFound'.freeze
42
-
43
37
  PLATFORM_LINUX = 'linux'.freeze
44
38
 
45
39
  # State of the copy operation
@@ -1,47 +1,6 @@
1
1
  # This file contains any or all custom Fog errors that we create
2
2
  module Fog
3
3
  module AzureRM
4
- # This is a custom Fog exception inherited from MsRestAzure::AzureOperationError
5
- class CustomAzureOperationError < MsRestAzure::AzureOperationError
6
- def initialize(message, azure_exception)
7
- super(azure_exception.request, azure_exception.response, azure_exception.body, "Exception in #{message}")
8
- end
9
-
10
- def print_subscription_limits_information
11
- request_method = @request.method
12
- subscription_id = @request.path_params['subscriptionId']
13
-
14
- limit_value = remaining_subscription_request_limits(@response)
15
-
16
- puts "Subscription: '#{subscription_id}'. Request Method: '#{request_method}'. \nLimit Value: #{limit_value['header']}: #{limit_value['value']}\n" unless limit_value.empty?
17
- end
18
-
19
- def remaining_subscription_request_limits(response)
20
- limit = {}
21
- # handles both read and write limits
22
- if response.headers.key? 'x-ms-ratelimit-remaining-subscription-resource-requests'
23
- limit['header'] = 'x-ms-ratelimit-remaining-subscription-resource-requests'
24
- limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-resource-requests']
25
-
26
- # limit for collection API calls
27
- elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-resource-entities-read'
28
- limit['header'] = 'x-ms-ratelimit-remaining-subscription-resource-entities-read'
29
- limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-resource-entities-read']
30
-
31
- # read requests limit
32
- elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-reads'
33
- limit['header'] = 'x-ms-ratelimit-remaining-subscription-reads'
34
- limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-reads']
35
-
36
- # write requests limit
37
- elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-writes'
38
- limit['header'] = 'x-ms-ratelimit-remaining-subscription-writes'
39
- limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-writes']
40
- end
41
- limit
42
- end
43
- end
44
-
45
4
  # This is a custom Fog exception inherited from Azure::Core::Http::HTTPError
46
5
  class CustomAzureCoreHttpError < Azure::Core::Http::HTTPError
47
6
  def initialize(azure_exception)
@@ -3,12 +3,22 @@ module Fog
3
3
  class AzureRM
4
4
  # This class provides the actual implemention for service calls.
5
5
  class Real
6
- alias get_object get_blob
6
+ def get_object(...)
7
+ blob, body = get_blob(...)
8
+
9
+ blob[:body] = body
10
+ blob
11
+ end
7
12
  end
8
13
 
9
14
  # This class provides the mock implementation for unit tests.
10
15
  class Mock
11
- alias get_object get_blob
16
+ def get_object(...)
17
+ blob, body = get_blob(...)
18
+
19
+ blob[:body] = body
20
+ blob
21
+ end
12
22
  end
13
23
  end
14
24
  end
@@ -2,13 +2,6 @@ module Fog
2
2
  module Storage
3
3
  # This class registers models, requests and collections
4
4
  class AzureRM < Fog::Service
5
- # Recognizes when creating management client
6
- recognizes :tenant_id
7
- recognizes :client_id
8
- recognizes :client_secret
9
- recognizes :subscription_id
10
- recognizes :environment
11
-
12
5
  # Recognizes when creating data client
13
6
  recognizes :azure_storage_account_name
14
7
  recognizes :azure_storage_access_key
@@ -95,17 +88,6 @@ module Fog
95
88
  raise e.message
96
89
  end
97
90
 
98
- options[:environment] = 'AzureCloud' if options[:environment].nil?
99
-
100
- @tenant_id = options[:tenant_id]
101
- @client_id = options[:client_id]
102
- @client_secret = options[:client_secret]
103
- @subscription_id = options[:subscription_id]
104
- @environment = options[:environment]
105
-
106
- credentials = Fog::Credentials::AzureRM.get_credentials(@tenant_id, @client_id, @client_secret, @environment)
107
- telemetry = "gitlab-fog-azure-rm/#{Fog::AzureRM::VERSION}"
108
-
109
91
  return unless @azure_storage_account_name != options[:azure_storage_account_name] ||
110
92
  @azure_storage_access_key != options[:azure_storage_access_key]
111
93
 
@@ -53,13 +53,9 @@ module Fog
53
53
  type.split('/').last
54
54
  end
55
55
 
56
- def raise_azure_exception(exception, msg)
56
+ def raise_azure_exception(exception, _msg)
57
57
  raise Fog::AzureRM::CustomAzureCoreHttpError.new(exception) if exception.is_a?(Azure::Core::Http::HTTPError)
58
- raise exception unless exception.is_a?(MsRestAzure::AzureOperationError)
59
-
60
- azure_operation_error = Fog::AzureRM::CustomAzureOperationError.new(msg, exception)
61
- azure_operation_error.print_subscription_limits_information if !azure_operation_error.request.nil? && !azure_operation_error.response.nil?
62
- raise azure_operation_error
58
+ raise exception
63
59
  end
64
60
 
65
61
  # Make sure if input_params(Hash) contains all keys present in required_params(Array)
@@ -80,47 +76,15 @@ module Fog
80
76
  (0...length).map { ('a'..'z').to_a[rand(26)] }.join
81
77
  end
82
78
 
83
- def active_directory_service_settings(environment = ENVIRONMENT_AZURE_CLOUD)
84
- case environment
85
- when ENVIRONMENT_AZURE_CHINA_CLOUD
86
- MsRestAzure::ActiveDirectoryServiceSettings.get_azure_china_settings
87
- when ENVIRONMENT_AZURE_US_GOVERNMENT
88
- MsRestAzure::ActiveDirectoryServiceSettings.get_azure_us_government_settings
89
- when ENVIRONMENT_AZURE_GERMAN_CLOUD
90
- MsRestAzure::ActiveDirectoryServiceSettings.get_azure_german_settings
91
- else
92
- MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings
93
- end
94
- end
95
-
96
- def resource_manager_endpoint_url(environment = ENVIRONMENT_AZURE_CLOUD)
97
- case environment
98
- when ENVIRONMENT_AZURE_CHINA_CLOUD
99
- MsRestAzure::AzureEnvironments::ChinaCloud.resource_manager_endpoint_url
100
- when ENVIRONMENT_AZURE_US_GOVERNMENT
101
- MsRestAzure::AzureEnvironments::USGovernment.resource_manager_endpoint_url
102
- when ENVIRONMENT_AZURE_GERMAN_CLOUD
103
- MsRestAzure::AzureEnvironments::GermanCloud.resource_manager_endpoint_url
104
- else
105
- MsRestAzure::AzureEnvironments::AzureCloud.resource_manager_endpoint_url
106
- end
107
- end
108
-
109
- # storage_endpoint_suffix is nil in ms_rest_azure 0.6.2
110
- # Reference the issue: https://github.com/Azure/azure-sdk-for-ruby/issues/603
111
79
  def storage_endpoint_suffix(environment = ENVIRONMENT_AZURE_CLOUD)
112
80
  case environment
113
81
  when ENVIRONMENT_AZURE_CHINA_CLOUD
114
- # MsRestAzure::AzureEnvironments::AzureChina.storage_endpoint_suffix
115
82
  '.core.chinacloudapi.cn'
116
83
  when ENVIRONMENT_AZURE_US_GOVERNMENT
117
- # MsRestAzure::AzureEnvironments::AzureUSGovernment.storage_endpoint_suffix
118
84
  '.core.usgovcloudapi.net'
119
85
  when ENVIRONMENT_AZURE_GERMAN_CLOUD
120
- # MsRestAzure::AzureEnvironments::AzureGermanCloud.storage_endpoint_suffix
121
86
  '.core.cloudapi.de'
122
87
  else
123
- # MsRestAzure::AzureEnvironments::Azure.storage_endpoint_suffix
124
88
  '.core.windows.net'
125
89
  end
126
90
  end
@@ -172,21 +136,6 @@ module Fog
172
136
  data
173
137
  end
174
138
 
175
- def resource_not_found?(azure_operation_error)
176
- is_found = false
177
- if azure_operation_error.response.status == HTTP_NOT_FOUND
178
- if azure_operation_error.body['code']
179
- is_found = azure_operation_error.body['code'] == ERROR_CODE_NOT_FOUND
180
- elsif azure_operation_error.body['error']
181
- is_found = azure_operation_error.body['error']['code'] == ERROR_CODE_NOT_FOUND ||
182
- azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_GROUP_NOT_FOUND ||
183
- azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND ||
184
- azure_operation_error.body['error']['code'] == ERROR_CODE_PARENT_RESOURCE_NOT_FOUND
185
- end
186
- end
187
- is_found
188
- end
189
-
190
139
  def get_image_name(id)
191
140
  id.split('/').last
192
141
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.8.0'.freeze
4
4
  end
5
5
  end
data/lib/fog/azurerm.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'ms_rest_azure'
2
1
  require 'azure/core/http/http_error'
3
2
  require 'erb'
4
3
  require 'fog/azurerm/config'
@@ -12,11 +11,6 @@ require 'fog/azurerm/models/storage/sku_tier'
12
11
  require 'fog/azurerm/models/storage/kind'
13
12
 
14
13
  module Fog
15
- # Autoload Module for Credentials
16
- module Credentials
17
- autoload :AzureRM, File.expand_path('azurerm/credentials', __dir__)
18
- end
19
-
20
14
  # Autoload Module for Storage
21
15
  module Storage
22
16
  autoload :AzureRM, File.expand_path('azurerm/storage', __dir__)
@@ -26,12 +26,6 @@ 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
-
35
29
  def test_get_blob_not_found
36
30
  exception = ->(*) { raise StandardError.new('Not found(404). Not exist') }
37
31
  @blob_client.stub :get_blob, exception do
@@ -41,15 +35,6 @@ class TestGetBlob < Minitest::Test
41
35
  end
42
36
  end
43
37
 
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
-
53
38
  def test_get_blob_http_exception
54
39
  http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
55
40
  @blob_client.stub :get_blob, http_exception do
@@ -0,0 +1,34 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestGetObject < Minitest::Test
5
+ # This class posesses the test cases for the requests of getting storage blob.
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
+ @raw_cloud_blob = storage_blob
16
+ @blob = ApiStub::Requests::Storage::File.blob_as_hash
17
+ @blob_with_content = @blob.merge(body: 'content')
18
+ end
19
+
20
+ def test_get_object_success
21
+ @blob_client.stub :get_blob, @blob_with_content do
22
+ assert_equal @blob_with_content, @service.get_object('test_container', 'test_blob')
23
+ end
24
+ end
25
+
26
+ def test_get_object_not_found
27
+ exception = ->(*) { raise StandardError.new('Not found(404). Not exist') }
28
+ @blob_client.stub :get_blob, exception do
29
+ assert_raises('NotFound') do
30
+ @service.get_object('test_container', 'test_blob')
31
+ end
32
+ end
33
+ end
34
+ end
data/test/test_helper.rb CHANGED
@@ -20,14 +20,6 @@ require 'azure/core/http/http_response'
20
20
  $LOAD_PATH.unshift(File.expand_path '../lib', __dir__)
21
21
  require File.expand_path '../lib/fog/azurerm', __dir__
22
22
  require File.expand_path './api_stub', __dir__
23
- def credentials
24
- {
25
- tenant_id: '<TENANT-ID>',
26
- client_id: '<CLIENT-ID>',
27
- client_secret: '<CLIENT-SECRET>',
28
- subscription_id: '<SUBSCRIPTION-ID>'
29
- }
30
- end
31
23
 
32
24
  def storage_account_credentials
33
25
  {
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.6.0
4
+ version: 1.8.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: 2023-02-27 00:00:00.000000000 Z
21
+ date: 2023-07-12 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: codeclimate-test-reporter
@@ -160,20 +160,6 @@ dependencies:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
- - !ruby/object:Gem::Dependency
164
- name: ms_rest_azure
165
- requirement: !ruby/object:Gem::Requirement
166
- requirements:
167
- - - "~>"
168
- - !ruby/object:Gem::Version
169
- version: 0.12.0
170
- type: :runtime
171
- prerelease: false
172
- version_requirements: !ruby/object:Gem::Requirement
173
- requirements:
174
- - - "~>"
175
- - !ruby/object:Gem::Version
176
- version: 0.12.0
177
163
  description: This is a stripped-down fork of fog-azure-rm that enables Azure Blob
178
164
  Storage to be used with CarrierWave and Fog.
179
165
  email:
@@ -201,7 +187,6 @@ files:
201
187
  - lib/fog/azurerm/async_response.rb
202
188
  - lib/fog/azurerm/config.rb
203
189
  - lib/fog/azurerm/constants.rb
204
- - lib/fog/azurerm/credentials.rb
205
190
  - lib/fog/azurerm/custom_fog_errors.rb
206
191
  - lib/fog/azurerm/docs/storage.md
207
192
  - lib/fog/azurerm/docs/structure.md
@@ -305,6 +290,7 @@ files:
305
290
  - test/requests/storage/test_get_container_acl.rb
306
291
  - test/requests/storage/test_get_container_properties.rb
307
292
  - test/requests/storage/test_get_container_url.rb
293
+ - test/requests/storage/test_get_object.rb
308
294
  - test/requests/storage/test_list_blobs.rb
309
295
  - test/requests/storage/test_list_containers.rb
310
296
  - test/requests/storage/test_put_blob_block.rb
@@ -319,7 +305,6 @@ files:
319
305
  - test/requests/storage/test_save_page_blob.rb
320
306
  - test/requests/storage/test_wait_blob_copy_operation_to_finish.rb
321
307
  - test/smoke_tests/compute/test_resource_group_smoke.rb
322
- - test/test_credentials.rb
323
308
  - test/test_helper.rb
324
309
  homepage: https://gitlab.com/gitlab-org/gitlab-fog-azure-rm
325
310
  licenses:
@@ -334,14 +319,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
334
319
  requirements:
335
320
  - - ">="
336
321
  - !ruby/object:Gem::Version
337
- version: 2.0.0
322
+ version: 2.7.0
338
323
  required_rubygems_version: !ruby/object:Gem::Requirement
339
324
  requirements:
340
325
  - - ">="
341
326
  - !ruby/object:Gem::Version
342
327
  version: '0'
343
328
  requirements: []
344
- rubygems_version: 3.4.7
329
+ rubygems_version: 3.4.15
345
330
  signing_key:
346
331
  specification_version: 4
347
332
  summary: Module for the 'fog' gem to support Azure Blob Storage with CarrierWave and
@@ -1,44 +0,0 @@
1
- module Fog
2
- module Credentials
3
- # This class is managing credentials token
4
- class AzureRM
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)
10
- if @credentials.nil? || new_management_credential?(tenant_id, client_id, client_secret, environment)
11
- get_new_credentials(tenant_id, client_id, client_secret, environment)
12
- else
13
- @credentials
14
- end
15
- end
16
-
17
- def self.get_token(tenant_id, client_id, client_secret, environment = Fog::AzureRM::ENVIRONMENT_AZURE_CLOUD)
18
- get_credentials(tenant_id, client_id, client_secret, environment) if @credentials.nil?
19
- @token_provider.get_authentication_header
20
- end
21
-
22
- def self.get_new_credentials(tenant_id, client_id, client_secret, environment)
23
- @tenant_id = tenant_id
24
- @client_id = client_id
25
- @client_secret = client_secret
26
- @environment = environment
27
- return if @tenant_id.nil? || @client_id.nil? || @client_secret.nil?
28
- @token_provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret, active_directory_service_settings(environment))
29
- @credentials = MsRest::TokenCredentials.new(@token_provider)
30
- @credentials
31
- end
32
-
33
- def self.new_management_credential?(tenant_id, client_id, client_secret, environment)
34
- @tenant_id != tenant_id ||
35
- @client_id != client_id ||
36
- @client_secret != client_secret ||
37
- @environment != environment
38
- end
39
-
40
- private_class_method :get_new_credentials
41
- private_class_method :new_management_credential?
42
- end
43
- end
44
- end
@@ -1,63 +0,0 @@
1
- require File.expand_path 'test_helper', __dir__
2
-
3
- # Test class for Credentials Helper Class
4
- class TestCredentials < Minitest::Test
5
- def setup
6
- @creds = credentials
7
- end
8
-
9
- def test_methods
10
- methods = [
11
- :get_credentials,
12
- :get_token
13
- ]
14
- methods.each do |method|
15
- assert Fog::Credentials::AzureRM.respond_to? method
16
- end
17
- end
18
-
19
- def test_get_credentials_method_with_same_client
20
- cred_obj_one = Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret])
21
- cred_obj_two = Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret])
22
- assert_equal cred_obj_one.object_id, cred_obj_two.object_id
23
- end
24
-
25
- def test_get_credentials_method_with_different_client
26
- cred_obj_one = Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret])
27
- @creds[:client_id] = '<NEW-CLIENT-ID>'
28
- cred_obj_two = Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret])
29
- refute_equal cred_obj_one.object_id, cred_obj_two.object_id
30
- end
31
-
32
- def test_get_token_method_with_default_environment
33
- Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret])
34
- token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
35
- token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
36
- assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
37
- end
38
- end
39
-
40
- def test_get_token_method_with_china_environment
41
- Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], Fog::AzureRM::ENVIRONMENT_AZURE_CHINA_CLOUD)
42
- token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
43
- token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
44
- assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
45
- end
46
- end
47
-
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], Fog::AzureRM::ENVIRONMENT_AZURE_US_GOVERNMENT)
50
- token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
51
- token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
52
- assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
53
- end
54
- end
55
-
56
- def test_get_token_method_with_german_environment
57
- Fog::Credentials::AzureRM.get_credentials(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret], Fog::AzureRM::ENVIRONMENT_AZURE_GERMAN_CLOUD)
58
- token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
59
- token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
60
- assert_equal Fog::Credentials::AzureRM.get_token(@creds[:tenant_id], @creds[:client_id], @creds[:client_secret]), 'Bearer <some-token>'
61
- end
62
- end
63
- end