fog-azure-rm 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/fog-azure-rm.gemspec +1 -1
  4. data/lib/fog/azurerm/constants.rb +4 -0
  5. data/lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb +1 -1
  6. data/lib/fog/azurerm/requests/compute/check_availability_set_exists.rb +1 -1
  7. data/lib/fog/azurerm/requests/compute/check_managed_disk_exists.rb +1 -1
  8. data/lib/fog/azurerm/requests/compute/check_vm_exists.rb +1 -1
  9. data/lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb +2 -2
  10. data/lib/fog/azurerm/requests/dns/check_record_set_exists.rb +1 -1
  11. data/lib/fog/azurerm/requests/dns/check_zone_exists.rb +3 -2
  12. data/lib/fog/azurerm/requests/key_vault/check_vault_exists.rb +1 -1
  13. data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +1 -1
  14. data/lib/fog/azurerm/requests/network/check_express_route_circuit_exists.rb +1 -1
  15. data/lib/fog/azurerm/requests/network/check_load_balancer_exists.rb +1 -1
  16. data/lib/fog/azurerm/requests/network/check_local_net_gateway_exists.rb +1 -1
  17. data/lib/fog/azurerm/requests/network/check_net_sec_group_exists.rb +1 -1
  18. data/lib/fog/azurerm/requests/network/check_net_sec_rule_exists.rb +1 -1
  19. data/lib/fog/azurerm/requests/network/check_network_interface_exists.rb +1 -1
  20. data/lib/fog/azurerm/requests/network/check_public_ip_exists.rb +1 -1
  21. data/lib/fog/azurerm/requests/network/check_subnet_exists.rb +1 -1
  22. data/lib/fog/azurerm/requests/network/check_virtual_network_exists.rb +1 -1
  23. data/lib/fog/azurerm/requests/network/check_vnet_gateway_connection_exists.rb +1 -1
  24. data/lib/fog/azurerm/requests/network/check_vnet_gateway_exists.rb +1 -1
  25. data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +3 -3
  26. data/lib/fog/azurerm/requests/storage/check_storage_account_exists.rb +1 -1
  27. data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_endpoint_exists.rb +1 -1
  28. data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_profile_exists.rb +1 -1
  29. data/lib/fog/azurerm/utilities/general.rb +15 -0
  30. data/lib/fog/azurerm/version.rb +1 -1
  31. data/test/requests/application_gateway/test_check_ag_exists.rb +11 -4
  32. data/test/requests/compute/test_check_availability_set_exists.rb +9 -2
  33. data/test/requests/compute/test_check_managed_disk_exists.rb +9 -2
  34. data/test/requests/compute/test_check_vm_exists.rb +9 -2
  35. data/test/requests/compute/test_check_vm_extension_exists.rb +9 -2
  36. data/test/requests/dns/test_check_record_set_exists.rb +9 -2
  37. data/test/requests/dns/test_check_zone_exists.rb +16 -2
  38. data/test/requests/key_vault/test_check_vault_exists.rb +9 -2
  39. data/test/requests/network/test_check_express_route_cir_auth_exists.rb +9 -2
  40. data/test/requests/network/test_check_express_route_circuit_exists.rb +9 -2
  41. data/test/requests/network/test_check_load_balancer_exists.rb +9 -2
  42. data/test/requests/network/test_check_local_net_gateway_exists.rb +11 -4
  43. data/test/requests/network/test_check_net_sec_group_exists.rb +9 -2
  44. data/test/requests/network/test_check_net_sec_rule_exists.rb +9 -2
  45. data/test/requests/network/test_check_network_interface_exists.rb +9 -2
  46. data/test/requests/network/test_check_public_ip_exists.rb +9 -2
  47. data/test/requests/network/test_check_subnet_exists.rb +9 -2
  48. data/test/requests/network/test_check_virtual_network_exists.rb +10 -4
  49. data/test/requests/network/test_check_vnet_gateway_connection_exists.rb +9 -2
  50. data/test/requests/network/test_check_vnet_gateway_exists.rb +9 -2
  51. data/test/requests/storage/test_check_storage_account_exists.rb +8 -1
  52. data/test/requests/traffic_manager/test_check_traffic_manager_endpoint_exists.rb +9 -2
  53. data/test/requests/traffic_manager/test_check_traffic_manager_profile_exists.rb +9 -2
  54. data/test/test_helper.rb +5 -0
  55. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a19921af4507084f3170dd448ce4193f7bcd9075b0fca9376b0270324a70664
4
- data.tar.gz: f44723252fdfa0cafb164e416643c04e5b212d6954cec36572408c461add8b5d
3
+ metadata.gz: 24eab57de64a1baaffb81c7e1ab2d7b0f1bcc1856cdfe89a97f2472f9b796dd6
4
+ data.tar.gz: c19bb3d44fa023fb03bb36ce8705d29d5ecf656eb8ad9cbc359dc8af721ddc80
5
5
  SHA512:
6
- metadata.gz: 9102c6cb48c96fa42d47b38ae5d5b73843bc63640e43178e78059fead565569847d65d628a84aefeae61be8a56abd6cf8eee28dbeff5118a90a3a5e3708ec069
7
- data.tar.gz: fc2ecb7465efca20e516a19ca555bf97f77aa50eee8bfd2b68a31f8fb59d6cbbb3e8d2031ab06f13cd5268a85243badb799aa30ff791e560c081e6bccc4cf419
6
+ metadata.gz: 68d789b370e855b6c34174685b76d47595d0882cb855dce39859bc3d0561e23723a1262dfea73b41a225797d583b64b8b40099cc1c9e4929f36950fb541bf91e
7
+ data.tar.gz: f1b2bac2be169c1e9753c07ded67cbb7d8e4aafc901bcb056a40408c021cd7bbc9dd704d52bd080371ed8042554e5b9ee7d8491d187df85ca5d3bf3b2d7a0482
@@ -1,3 +1,9 @@
1
+ ## 0.4.1
2
+
3
+ **Fixed:**
4
+ - Fixed check existence methods for all resources
5
+ - Fixed mime-types dependency issue
6
+
1
7
  ## 0.4.0
2
8
 
3
9
  **Added**
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'azure_mgmt_key_vault', '~> 0.9.0'
35
35
  spec.add_dependency 'azure-storage', '= 0.11.5.preview'
36
36
  spec.add_dependency 'vhd', '0.0.4'
37
- spec.add_dependency 'mime-types', '1.25'
37
+ spec.add_dependency 'mime-types', '~> 1.25'
38
38
  end
@@ -34,6 +34,8 @@ ENVIRONMENT_AZURE_GERMAN_CLOUD = 'AzureGermanCloud'.freeze
34
34
  # MsRestAzure::AzureOperationError class Error Codes
35
35
  ERROR_CODE_RESOURCE_NOT_FOUND = 'ResourceNotFound'.freeze
36
36
  ERROR_CODE_NOT_FOUND = 'NotFound'.freeze
37
+ ERROR_CODE_RESOURCE_GROUP_NOT_FOUND = 'ResourceGroupNotFound'.freeze
38
+ ERROR_CODE_PARENT_RESOURCE_NOT_FOUND = 'ParentResourceNotFound'.freeze
37
39
 
38
40
  PLATFORM_LINUX = 'linux'.freeze
39
41
 
@@ -65,3 +67,5 @@ AS_SKU_ALIGNED = 'Aligned'.freeze
65
67
  # The tag key and tag value for creating a temporary storage account for generalized image
66
68
  TEMPORARY_STORAGE_ACCOUNT_TAG_KEY = 'generalized_image'.freeze
67
69
  TEMPORARY_STORAGE_ACCOUNT_TAG_VALUE = 'delete'.freeze
70
+
71
+ HTTP_NOT_FOUND = 404
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Application Gateway #{application_gateway_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Application Gateway #{application_gateway_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Availability set #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Availability set #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Managed Disk #{disk_name} exist."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.error_code == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Managed Disk #{disk_name} doesn't exist."
16
16
  false
17
17
  else
@@ -13,7 +13,7 @@ module Fog
13
13
  @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView')
14
14
  end
15
15
  rescue MsRestAzure::AzureOperationError => e
16
- if e.body['error']['code'] == 'ResourceNotFound'
16
+ if resource_not_found?(e)
17
17
  Fog::Logger.debug "Virtual machine #{name} doesn't exist."
18
18
  return false
19
19
  else
@@ -11,8 +11,8 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Machine Extension #{vm_extension_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
15
- Fog::Logger.debug "Virtual machine #{vm_extension_name} doesn't exist."
14
+ if resource_not_found?(e)
15
+ Fog::Logger.debug "Virtual Machine Extension #{vm_extension_name} doesn't exist."
16
16
  false
17
17
  else
18
18
  raise_azure_exception(e, msg)
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Record set #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['code'] == 'NotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Record set #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -9,8 +9,9 @@ module Fog
9
9
  begin
10
10
  zone = @dns_client.zones.get(resource_group, name)
11
11
  rescue MsRestAzure::AzureOperationError => e
12
- if !e.body['error'].nil? && e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND
13
- zone = nil
12
+ if resource_not_found?(e)
13
+ Fog::Logger.debug "Zone #{name} doesn't exist."
14
+ return false
14
15
  else
15
16
  raise_azure_exception(e, msg)
16
17
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Vault #{vault_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Vault #{vault_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Express Route Circuit Authorization #{authorization_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'NotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Express Route Circuit Authorization #{authorization_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Express Route Circuit #{circuit_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Express Route Circuit #{circuit_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Load Balancer #{load_balancer_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Load Balancer #{load_balancer_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Local Network Gateway #{local_network_gateway_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Local Network Gateway #{local_network_gateway_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Security Group #{security_group_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Security Group #{security_group_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Security Rule #{security_rule_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if !e.body['error'].nil? && (e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND || e.body['error']['code'] == ERROR_CODE_NOT_FOUND)
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Security Rule #{security_rule_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Network Interface #{nic_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Network Interface #{nic_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Public IP #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Public IP #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Subnet #{subnet_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if !e.body['error'].nil? && (e.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND || e.body['error']['code'] == ERROR_CODE_NOT_FOUND)
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Subnet #{subnet_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network #{name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.error_code == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network #{name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network Gateway Connection #{gateway_connection_name} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Virtual Network Gateway #{network_gateway_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Virtual Network Gateway #{network_gateway_name} doesn't exist."
16
16
  false
17
17
  else
@@ -16,9 +16,9 @@ module Fog
16
16
  msg = "Checking Resource #{resource_name}"
17
17
  Fog::Logger.debug msg
18
18
  begin
19
- @rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
20
- Fog::Logger.debug "Resource #{resource_name} exists."
21
- true
19
+ resource_exists = @rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version)
20
+ Fog::Logger.debug "Resource #{resource_name} exists." if resource_exists
21
+ resource_exists
22
22
  rescue MsRestAzure::AzureOperationError => e
23
23
  if e.response.status == 405
24
24
  Fog::Logger.debug "Resource #{resource_name} doesn't exist."
@@ -9,7 +9,7 @@ module Fog
9
9
  begin
10
10
  storage_account = @storage_mgmt_client.storage_accounts.get_properties(resource_group_name, storage_account_name)
11
11
  rescue MsRestAzure::AzureOperationError => e
12
- if e.body['error']['code'] == 'ResourceNotFound'
12
+ if resource_not_found?(e)
13
13
  Fog::Logger.debug "Storage Account #{storage_account_name} doesn't exist."
14
14
  return false
15
15
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Traffic Manager Endpoint #{traffic_manager_end_point} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['code'] == 'NotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Traffic Manager Endpoint #{traffic_manager_end_point} doesn't exist."
16
16
  false
17
17
  else
@@ -11,7 +11,7 @@ module Fog
11
11
  Fog::Logger.debug "Traffic Manager Profile #{traffic_manager_profile_name} exists."
12
12
  true
13
13
  rescue MsRestAzure::AzureOperationError => e
14
- if e.body['error']['code'] == 'ResourceNotFound'
14
+ if resource_not_found?(e)
15
15
  Fog::Logger.debug "Traffic Manager Profile #{traffic_manager_profile_name} doesn't exist."
16
16
  false
17
17
  else
@@ -167,6 +167,21 @@ def parse_storage_object(object)
167
167
  data
168
168
  end
169
169
 
170
+ def resource_not_found?(azure_operation_error)
171
+ is_found = false
172
+ if azure_operation_error.response.status == HTTP_NOT_FOUND
173
+ if azure_operation_error.body['code']
174
+ is_found = azure_operation_error.body['code'] == ERROR_CODE_NOT_FOUND
175
+ elsif azure_operation_error.body['error']
176
+ is_found = azure_operation_error.body['error']['code'] == ERROR_CODE_NOT_FOUND ||
177
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_GROUP_NOT_FOUND ||
178
+ azure_operation_error.body['error']['code'] == ERROR_CODE_RESOURCE_NOT_FOUND ||
179
+ azure_operation_error.body['error']['code'] == ERROR_CODE_PARENT_RESOURCE_NOT_FOUND
180
+ end
181
+ end
182
+ is_found
183
+ end
184
+
170
185
  def get_image_name(id)
171
186
  id.split('/').last
172
187
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.4.1'.freeze
4
4
  end
5
5
  end
@@ -15,15 +15,22 @@ class TestCheckAGExists < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_check_ag_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
18
+ def test_check_app_gateway_exists_failure
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
20
  @gateways.stub :get, response do
21
21
  assert !@service.check_ag_exists('fog-test-rg', 'fogRM-rg')
22
22
  end
23
23
  end
24
24
 
25
- def test_check_ag_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
25
+ def test_check_app_gateway_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
27
+ @gateways.stub :get, response do
28
+ assert !@service.check_ag_exists('fog-test-rg', 'fogRM-rg')
29
+ end
30
+ end
31
+
32
+ def test_check_app_gateway_exists_exception
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @gateways.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_ag_exists('fog-test-rg', 'fogRM-rg') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckAvailabilitySetExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_availability_set_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @availability_sets.stub :get, response do
21
+ assert !@service.check_availability_set_exists('myrg1', 'myavset1')
22
+ end
23
+ end
24
+
25
+ def test_check_availability_set_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @availability_sets.stub :get, response do
21
28
  assert !@service.check_availability_set_exists('myrg1', 'myavset1')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_availability_set_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @availability_sets.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_availability_set_exists('myrg1', 'myavset1') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckManagedDiskExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_managed_disk_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @managed_disks.stub :get, response do
21
+ assert !@service.check_managed_disk_exists('myrg1', 'mydisk1')
22
+ end
23
+ end
24
+
25
+ def test_check_managed_disk_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @managed_disks.stub :get, response do
21
28
  assert !@service.check_managed_disk_exists('myrg1', 'mydisk1')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_managed_disk_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @managed_disks.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_managed_disk_exists('myrg1', 'mydisk1') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckVirtualMachineExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_vm_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @virtual_machines.stub :get, response do
21
+ assert !@service.check_vm_exists('fog-test-rg', 'fog-test-server', false)
22
+ end
23
+ end
24
+
25
+ def test_check_vm_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @virtual_machines.stub :get, response do
21
28
  assert !@service.check_vm_exists('fog-test-rg', 'fog-test-server', false)
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_vm_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @virtual_machines.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_vm_exists('fog-test-rg', 'fog-test-server', false) }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckVMExtensionExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_vm_extension_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @vm_extension.stub :get, response do
21
+ assert !@service.check_vm_extension_exists('fog-test-rg', 'fog-test-vm', 'fog-test-extension')
22
+ end
23
+ end
24
+
25
+ def test_check_vm_extension_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @vm_extension.stub :get, response do
21
28
  assert !@service.check_vm_extension_exists('fog-test-rg', 'fog-test-vm', 'fog-test-extension')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_vm_extension_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @vm_extension.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_vm_extension_exists('fog-test-rg', 'fog-test-vm', 'fog-test-extension') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckRecordSetExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_record_set_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'code' => 'NotFound' ) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'code' => 'NotFound') }
20
+ @record_sets.stub :get, response do
21
+ assert !@service.check_record_set_exists('fog-test-rg', 'fog-test-result', 'fog-test-zone', 'CNAME')
22
+ end
23
+ end
24
+
25
+ def test_check_record_set_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @record_sets.stub :get, response do
21
28
  assert !@service.check_record_set_exists('fog-test-rg', 'fog-test-result', 'fog-test-zone', 'CNAME')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_record_set_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @record_sets.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_record_set_exists('fog-test-rg', 'fog-test-result', 'fog-test-zone', 'CNAME') }
29
36
  end
@@ -15,7 +15,7 @@ class TestCheckZoneExists < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_check_zone_exists_failure
18
+ def test_check_zone_arguement_error
19
19
  response = ApiStub::Requests::DNS::RecordSet.list_record_sets_response(@dns_client)
20
20
  @zones.stub :get, response do
21
21
  assert_raises ArgumentError do
@@ -24,8 +24,22 @@ class TestCheckZoneExists < Minitest::Test
24
24
  end
25
25
  end
26
26
 
27
+ def test_check_zone_exists_failure
28
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
29
+ @zones.stub :get, response do
30
+ assert !@service.check_zone_exists('fog-test-rg', 'zone_name')
31
+ end
32
+ end
33
+
34
+ def test_check_zone_resource_group_exists_failure
35
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
36
+ @zones.stub :get, response do
37
+ assert !@service.check_zone_exists('fog-test-rg', 'zone_name')
38
+ end
39
+ end
40
+
27
41
  def test_check_zone_exists_exception
28
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
42
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
29
43
  @zones.stub :get, response do
30
44
  assert_raises RuntimeError do
31
45
  @service.check_zone_exists('fog-test-rg', 'zone_name')
@@ -16,14 +16,21 @@ class TestCheckVaultExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_vault_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @vaults.stub :get, response do
21
+ assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
22
+ end
23
+ end
24
+
25
+ def test_check_vault_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @vaults.stub :get, response do
21
28
  assert !@service.check_vault_exists('fog-test-rg', 'fog-test-kv')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_vault_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @vaults.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_vault_exists('fog-test-rg', 'fog-test-kv') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckExpressRouteCirAuthExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_express_route_cir_auth_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'NotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'NotFound' }) }
20
+ @circuit_authorization.stub :get, response do
21
+ assert !@service.check_express_route_cir_auth_exists('Fog-rg', 'testCircuit', 'auth-name')
22
+ end
23
+ end
24
+
25
+ def test_check_express_route_cir_auth_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @circuit_authorization.stub :get, response do
21
28
  assert !@service.check_express_route_cir_auth_exists('Fog-rg', 'testCircuit', 'auth-name')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_express_route_cir_auth_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @circuit_authorization.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_express_route_cir_auth_exists('Fog-rg', 'testCircuit', 'auth-name') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckExpressRouteCircuitExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_express_route_circuit_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @circuit.stub :get, response do
21
+ assert !@service.check_express_route_circuit_exists('fog-test-rg', 'testCircuit')
22
+ end
23
+ end
24
+
25
+ def test_check_express_route_circuit_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @circuit.stub :get, response do
21
28
  assert !@service.check_express_route_circuit_exists('fog-test-rg', 'testCircuit')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_express_route_circuit_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @circuit.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_express_route_circuit_exists('fog-test-rg', 'testCircuit') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckLoadBalancerExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_load_balancer_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @load_balancers.stub :get, response do
21
+ assert !@service.check_load_balancer_exists('fog-test-rg', 'mylb1')
22
+ end
23
+ end
24
+
25
+ def test_check_load_balancer_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @load_balancers.stub :get, response do
21
28
  assert !@service.check_load_balancer_exists('fog-test-rg', 'mylb1')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_load_balancer_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @load_balancers.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_load_balancer_exists('fog-test-rg', 'mylb1') }
29
36
  end
@@ -15,15 +15,22 @@ class TestCheckLocalNetworkGatewayExists < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_check_virtual_network_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
18
+ def test_check_local_net_gateway_exists_failure
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
20
  @local_network_gateways.stub :get, response do
21
21
  assert !@service.check_local_net_gateway_exists('fog-test-rg', 'fog-test-local-network-gateway')
22
22
  end
23
23
  end
24
24
 
25
- def test_check_fvirtual_network_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
25
+ def test_check_local_net_gateway_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
27
+ @local_network_gateways.stub :get, response do
28
+ assert !@service.check_local_net_gateway_exists('fog-test-rg', 'fog-test-local-network-gateway')
29
+ end
30
+ end
31
+
32
+ def test_check_local_net_gateway_exists_exception
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @local_network_gateways.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_local_net_gateway_exists('fog-test-rg', 'fog-test-local-network-gateway') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckNetworkSecurityGroupExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_net_sec_group_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @network_security_groups.stub :get, response do
21
+ assert !@service.check_net_sec_group_exists('fog-test-rg', 'fog-test-nsg')
22
+ end
23
+ end
24
+
25
+ def test_check_net_sec_group_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @network_security_groups.stub :get, response do
21
28
  assert !@service.check_net_sec_group_exists('fog-test-rg', 'fog-test-nsg')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_net_sec_group_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @network_security_groups.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_net_sec_group_exists('fog-test-rg', 'fog-test-nsg') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckNetworkSecurityRuleExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_net_sec_rule_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @network_security_rules.stub :get, response do
21
+ assert !@service.check_net_sec_rule_exists('fog-test-rg', 'fog-test-nsg', 'fog-test-nsr')
22
+ end
23
+ end
24
+
25
+ def test_check_net_sec_rule_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @network_security_rules.stub :get, response do
21
28
  assert !@service.check_net_sec_rule_exists('fog-test-rg', 'fog-test-nsg', 'fog-test-nsr')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_net_sec_rule_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @network_security_rules.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_net_sec_rule_exists('fog-test-rg', 'fog-test-nsg', 'fog-test-nsr') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckNetworkInterfaceExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_network_interface_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @network_interfaces.stub :get, response do
21
+ assert !@service.check_network_interface_exists('fog-test-rg', 'fog-test-network-interface')
22
+ end
23
+ end
24
+
25
+ def test_check_network_interface_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @network_interfaces.stub :get, response do
21
28
  assert !@service.check_network_interface_exists('fog-test-rg', 'fog-test-network-interface')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_network_interface_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @network_interfaces.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_network_interface_exists('fog-test-rg', 'fog-test-network-interface') }
29
36
  end
@@ -15,14 +15,21 @@ class TestCheckPublicIpExists < Minitest::Test
15
15
  end
16
16
 
17
17
  def test_check_public_ip_exists_failure
18
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
18
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ @public_ips.stub :get, response do
20
+ assert !@service.check_public_ip_exists('fog-test-rg', 'fog-test-public-ip')
21
+ end
22
+ end
23
+
24
+ def test_check_public_ip_resource_group_exists_failure
25
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
19
26
  @public_ips.stub :get, response do
20
27
  assert !@service.check_public_ip_exists('fog-test-rg', 'fog-test-public-ip')
21
28
  end
22
29
  end
23
30
 
24
31
  def test_check_public_ip_exists_exception
25
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
32
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
26
33
  @public_ips.stub :get, response do
27
34
  assert_raises(RuntimeError) { @service.check_public_ip_exists('fog-test-rg', 'fog-test-public-ip') }
28
35
  end
@@ -16,14 +16,21 @@ class TestCheckSubnetExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_subnet_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @subnets.stub :get, response do
21
+ assert !@service.check_subnet_exists('fog-test-rg', 'fog-test-virtual-network', 'fog-test-subnet')
22
+ end
23
+ end
24
+
25
+ def test_check_subnet_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @subnets.stub :get, response do
21
28
  assert !@service.check_subnet_exists('fog-test-rg', 'fog-test-virtual-network', 'fog-test-subnet')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_subnet_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @subnets.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_subnet_exists('fog-test-rg', 'fog-test-virtual-network', 'fog-test-subnet') }
29
36
  end
@@ -15,8 +15,15 @@ class TestCheckVirtualNetworkExists < Minitest::Test
15
15
  end
16
16
 
17
17
  def test_check_virtual_network_exists_failure
18
- faraday_response = Faraday::Response.new(nil)
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, faraday_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
18
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+
20
+ @virtual_networks.stub :get, response do
21
+ assert !@service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network')
22
+ end
23
+ end
24
+
25
+ def test_check_virtual_network_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
 
21
28
  @virtual_networks.stub :get, response do
22
29
  assert !@service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network')
@@ -24,8 +31,7 @@ class TestCheckVirtualNetworkExists < Minitest::Test
24
31
  end
25
32
 
26
33
  def test_check_virtual_network_exists_exception
27
- faraday_response = Faraday::Response.new(nil)
28
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, faraday_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
34
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
29
35
 
30
36
  @virtual_networks.stub :get, response do
31
37
  assert_raises(RuntimeError) { @service.check_virtual_network_exists('fog-test-rg', 'fog-test-virtual-network') }
@@ -16,14 +16,21 @@ class TestCheckVirtualNetworkGatewayConnectionExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_vnet_gateway_connection_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @gateway_connections.stub :get, response do
21
+ assert !@service.check_vnet_gateway_connection_exists('fog-test-rg', 'fog-test-gateway-connection')
22
+ end
23
+ end
24
+
25
+ def test_check_vnet_gateway_connection_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @gateway_connections.stub :get, response do
21
28
  assert !@service.check_vnet_gateway_connection_exists('fog-test-rg', 'fog-test-gateway-connection')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_vnet_gateway_connection_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @gateway_connections.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_vnet_gateway_connection_exists('fog-test-rg', 'fog-test-gateway-connection') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckVirtualNetworkGatewayExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_vnet_gateway_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @network_gateways.stub :get, response do
21
+ assert !@service.check_vnet_gateway_exists('fog-test-rg', 'fog-test-network-gateway')
22
+ end
23
+ end
24
+
25
+ def test_check_vnet_gateway_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @network_gateways.stub :get, response do
21
28
  assert !@service.check_vnet_gateway_exists('fog-test-rg', 'fog-test-network-gateway')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_vnet_gateway_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @network_gateways.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_vnet_gateway_exists('fog-test-rg', 'fog-test-network-gateway') }
29
36
  end
@@ -25,8 +25,15 @@ class TestCheckStorageAccountExists < Minitest::Test
25
25
  end
26
26
  end
27
27
 
28
+ def test_check_storage_account_resource_group_exists_failure
29
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
30
+ @storage_accounts.stub :get_properties, response do
31
+ assert !@service.check_storage_account_exists('fog_test_rg', 'fogtestsasecond')
32
+ end
33
+ end
34
+
28
35
  def test_check_storage_account_exists_exception
29
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
36
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
30
37
  @storage_accounts.stub :get_properties, response do
31
38
  assert_raises(RuntimeError) { @service.check_storage_account_exists('fog_test_rg', 'fogtestsasecond') }
32
39
  end
@@ -16,14 +16,21 @@ class TestCheckTrafficManagerEndpointExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_traffic_manager_endpoint_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'code' => 'NotFound' ) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'code' => 'NotFound') }
20
+ @end_points.stub :get, response do
21
+ assert !@service.check_traffic_manager_endpoint_exists('fog-test-rg', 'fog-test-profile', 'fog-test-endpoint-name', 'fog-test-endpoint-type')
22
+ end
23
+ end
24
+
25
+ def test_check_traffic_manager_endpoint_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @end_points.stub :get, response do
21
28
  assert !@service.check_traffic_manager_endpoint_exists('fog-test-rg', 'fog-test-profile', 'fog-test-endpoint-name', 'fog-test-endpoint-type')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_traffic_manager_endpoint_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @end_points.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_traffic_manager_endpoint_exists('fog-test-rg', 'fog-test-profile', 'fog-test-endpoint-name', 'fog-test-endpoint-type') }
29
36
  end
@@ -16,14 +16,21 @@ class TestCheckTrafficManagerProfileExists < Minitest::Test
16
16
  end
17
17
 
18
18
  def test_check_traffic_manager_profile_exists_failure
19
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceNotFound' }) }
20
+ @profiles.stub :get, response do
21
+ assert !@service.check_traffic_manager_profile_exists('fog-test-rg', 'fog-test-profile')
22
+ end
23
+ end
24
+
25
+ def test_check_traffic_manager_profile_resource_group_exists_failure
26
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
20
27
  @profiles.stub :get, response do
21
28
  assert !@service.check_traffic_manager_profile_exists('fog-test-rg', 'fog-test-profile')
22
29
  end
23
30
  end
24
31
 
25
32
  def test_check_traffic_manager_profile_exists_exception
26
- response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
33
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, create_mock_response, 'error' => { 'message' => 'mocked exception', 'code' => 'Exception' }) }
27
34
  @profiles.stub :get, response do
28
35
  assert_raises(RuntimeError) { @service.check_traffic_manager_profile_exists('fog-test-rg', 'fog-test-profile') }
29
36
  end
@@ -824,3 +824,8 @@ def key_vault(service)
824
824
  service: service
825
825
  )
826
826
  end
827
+
828
+ def create_mock_response
829
+ response_headers = { 'status' => HTTP_NOT_FOUND }
830
+ Faraday::Response.new(response_headers)
831
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-azure-rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
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: 2017-12-12 00:00:00.000000000 Z
21
+ date: 2017-12-19 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: rake
@@ -248,14 +248,14 @@ dependencies:
248
248
  name: mime-types
249
249
  requirement: !ruby/object:Gem::Requirement
250
250
  requirements:
251
- - - '='
251
+ - - "~>"
252
252
  - !ruby/object:Gem::Version
253
253
  version: '1.25'
254
254
  type: :runtime
255
255
  prerelease: false
256
256
  version_requirements: !ruby/object:Gem::Requirement
257
257
  requirements:
258
- - - '='
258
+ - - "~>"
259
259
  - !ruby/object:Gem::Version
260
260
  version: '1.25'
261
261
  description: |-