fog-azure-rm-temp 0.0.3 → 0.0.4

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 +0 -5
  3. data/fog-azure-rm.gemspec +1 -1
  4. data/lib/fog/azurerm/compute.rb +2 -0
  5. data/lib/fog/azurerm/docs/storage.md +66 -0
  6. data/lib/fog/azurerm/models/compute/creation_data.rb +4 -2
  7. data/lib/fog/azurerm/models/compute/data_disk.rb +26 -0
  8. data/lib/fog/azurerm/models/compute/managed_disk.rb +5 -4
  9. data/lib/fog/azurerm/models/compute/server.rb +24 -3
  10. data/lib/fog/azurerm/models/storage/recovery_vault.rb +50 -0
  11. data/lib/fog/azurerm/models/storage/recovery_vaults.rb +27 -0
  12. data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +49 -13
  13. data/lib/fog/azurerm/requests/compute/detach_data_disk_from_vm.rb +1 -2
  14. data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +54 -0
  15. data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +35 -0
  16. data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +60 -0
  17. data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +61 -0
  18. data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +56 -0
  19. data/lib/fog/azurerm/requests/storage/get_backup_container.rb +53 -0
  20. data/lib/fog/azurerm/requests/storage/get_backup_item.rb +58 -0
  21. data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +53 -0
  22. data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +64 -0
  23. data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +49 -0
  24. data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +48 -0
  25. data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +36 -0
  26. data/lib/fog/azurerm/requests/storage/start_backup.rb +54 -0
  27. data/lib/fog/azurerm/storage.rb +18 -1
  28. data/lib/fog/azurerm/version.rb +1 -1
  29. data/test/api_stub.rb +2 -0
  30. data/test/api_stub/models/compute/server.rb +62 -0
  31. data/test/api_stub/models/storage/recovery_vault.rb +23 -0
  32. data/test/api_stub/requests/compute/virtual_machine.rb +77 -0
  33. data/test/api_stub/requests/storage/recovery_vault.rb +189 -0
  34. data/test/models/{storage → compute}/test_data_disk.rb +2 -2
  35. data/test/models/compute/test_server.rb +27 -1
  36. data/test/models/storage/test_recovery_vault.rb +61 -0
  37. data/test/models/storage/test_recovery_vaults.rb +47 -0
  38. data/test/requests/compute/test_attach_data_disk_to_vm.rb +21 -6
  39. data/test/requests/storage/test_create_recovery_vault.rb +35 -0
  40. data/test/requests/storage/test_delete_recovery_vault.rb +34 -0
  41. data/test/requests/storage/test_disable_backup_protection.rb +52 -0
  42. data/test/requests/storage/test_enable_backup_protection.rb +66 -0
  43. data/test/requests/storage/test_get_all_backup_jobs.rb +35 -0
  44. data/test/requests/storage/test_get_backup_container.rb +35 -0
  45. data/test/requests/storage/test_get_backup_item.rb +35 -0
  46. data/test/requests/storage/test_get_backup_job_for_vm.rb +26 -0
  47. data/test/requests/storage/test_get_backup_protection_policy.rb +35 -0
  48. data/test/requests/storage/test_get_recovery_vault.rb +35 -0
  49. data/test/requests/storage/test_list_recovery_vault.rb +35 -0
  50. data/test/requests/storage/test_set_recovery_vault_context.rb +34 -0
  51. data/test/requests/storage/test_start_backup.rb +55 -0
  52. data/test/test_helper.rb +14 -0
  53. metadata +38 -13
  54. data/.arclint +0 -8
  55. data/lib/fog/azurerm/models/storage/data_disk.rb +0 -27
@@ -3,8 +3,8 @@ require File.expand_path '../../test_helper', __dir__
3
3
  # Test class for Data Disk Model
4
4
  class TestDataDisk < Minitest::Test
5
5
  def setup
6
- @service = Fog::Storage::AzureRM.new(credentials)
7
- @data_disk = Fog::Storage::AzureRM::DataDisk.new
6
+ @service = Fog::Compute::AzureRM.new(credentials)
7
+ @data_disk = Fog::Compute::AzureRM::DataDisk.new
8
8
  end
9
9
 
10
10
  def test_model_attributes
@@ -20,7 +20,9 @@ class TestServer < Minitest::Test
20
20
  :redeploy,
21
21
  :list_available_sizes,
22
22
  :attach_data_disk,
23
- :detach_data_disk
23
+ :detach_data_disk,
24
+ :attach_managed_disk,
25
+ :detach_managed_disk
24
26
  ]
25
27
  methods.each do |method|
26
28
  assert_respond_to @server, method
@@ -198,4 +200,28 @@ class TestServer < Minitest::Test
198
200
  assert_instance_of Fog::AzureRM::AsyncResponse, @server.detach_data_disk('disk1', true)
199
201
  end
200
202
  end
203
+
204
+ def test_attach_managed_disk_response
205
+ response = ApiStub::Models::Compute::Server.attach_managed_disk_response(@compute_client)
206
+ @service.stub :attach_data_disk_to_vm, response do
207
+ assert_instance_of Fog::Compute::AzureRM::Server, @server.attach_managed_disk('disk_name', 'resoure_group')
208
+ end
209
+
210
+ async_response = Concurrent::Promise.execute { 10 }
211
+ @service.stub :attach_data_disk_to_vm, async_response do
212
+ assert_instance_of Fog::AzureRM::AsyncResponse, @server.attach_managed_disk('managed_disk_name', 'resoure_group', true)
213
+ end
214
+ end
215
+
216
+ def test_detach_managed_disk_response
217
+ response = ApiStub::Models::Compute::Server.create_linux_virtual_machine_response(@compute_client)
218
+ @service.stub :detach_data_disk_from_vm, response do
219
+ assert_instance_of Fog::Compute::AzureRM::Server, @server.detach_managed_disk('managed_disk_name')
220
+ end
221
+
222
+ async_response = Concurrent::Promise.execute { 10 }
223
+ @service.stub :detach_data_disk_from_vm, async_response do
224
+ assert_instance_of Fog::AzureRM::AsyncResponse, @server.detach_managed_disk('managed_disk_name', true)
225
+ end
226
+ end
201
227
  end
@@ -0,0 +1,61 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Recovery Vault model
4
+ class TestRecoveryVault < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @recovery_vault = recovery_vault(@service)
8
+ end
9
+
10
+ def test_model_methods
11
+ methods = [
12
+ :save,
13
+ :enable_backup_protection,
14
+ :disable_backup_protection,
15
+ :start_backup,
16
+ :destroy
17
+ ]
18
+ methods.each do |method|
19
+ assert_respond_to @recovery_vault, method
20
+ end
21
+ end
22
+
23
+ def test_model_attributes
24
+ attributes = [
25
+ :id,
26
+ :name,
27
+ :resource_group,
28
+ :location,
29
+ :type,
30
+ :sku_name
31
+ ]
32
+ attributes.each do |attribute|
33
+ assert_respond_to @recovery_vault, attribute
34
+ end
35
+ end
36
+
37
+ def test_save_method_response
38
+ create_response = ApiStub::Models::Storage::RecoveryVault.create_method_response
39
+ @service.stub :create_or_update_recovery_vault, create_response do
40
+ assert_instance_of Fog::Storage::AzureRM::RecoveryVault, @recovery_vault.save
41
+ end
42
+ end
43
+
44
+ def test_enable_backup_protection_method_response
45
+ @service.stub :enable_backup_protection, true do
46
+ assert @recovery_vault.enable_backup_protection('test-vm', 'test-vm-rg')
47
+ end
48
+ end
49
+
50
+ def test_disable_backup_protection_method_response
51
+ @service.stub :disable_backup_protection, true do
52
+ assert @recovery_vault.disable_backup_protection('test-vm', 'test-vm-rg')
53
+ end
54
+ end
55
+
56
+ def test_destroy_method_response
57
+ @service.stub :delete_recovery_vault, true do
58
+ assert @recovery_vault.destroy
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test Class for RecoveryVault Collections
4
+ class TestRecoveryVaults < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @recovery_vaults = Fog::Storage::AzureRM::RecoveryVaults.new(resource_group: 'fog-test-rg', service: @service)
8
+ end
9
+
10
+ def test_collection_methods
11
+ methods = [
12
+ :all,
13
+ :get
14
+ ]
15
+ methods.each do |method|
16
+ assert_respond_to @recovery_vaults, method
17
+ end
18
+ end
19
+
20
+ def test_collection_attributes
21
+ attributes = [
22
+ :resource_group,
23
+ :name
24
+ ]
25
+ attributes.each do |attribute|
26
+ assert_respond_to @recovery_vaults, attribute
27
+ end
28
+ end
29
+
30
+ def test_all_method_response
31
+ response = [ApiStub::Models::Storage::RecoveryVault.create_method_response]
32
+ @service.stub :list_recovery_vaults, response do
33
+ assert_instance_of Fog::Storage::AzureRM::RecoveryVaults, @recovery_vaults.all
34
+ assert @recovery_vaults.all.size >= 1
35
+ @recovery_vaults.all.each do |recovery_vault|
36
+ assert_instance_of Fog::Storage::AzureRM::RecoveryVault, recovery_vault
37
+ end
38
+ end
39
+ end
40
+
41
+ def test_get_method_response
42
+ response = ApiStub::Models::Storage::RecoveryVault.create_method_response
43
+ @service.stub :get_recovery_vault, response do
44
+ assert_instance_of Fog::Storage::AzureRM::RecoveryVault, @recovery_vaults.get('fog-test-rg', 'fog-test-vault')
45
+ end
46
+ end
47
+ end
@@ -11,6 +11,10 @@ class TestAttachDataDiskToVM < Minitest::Test
11
11
  @get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response(@compute_client)
12
12
  @update_vm_response = ApiStub::Requests::Compute::VirtualMachine.update_virtual_machine_response(@compute_client)
13
13
  @storage_access_keys_response = ApiStub::Requests::Storage::StorageAccount.list_keys_response
14
+ @disks = @compute_client.disks
15
+ @get_managed_disk_response = ApiStub::Requests::Compute::VirtualMachine.get_managed_disk_response(@compute_client)
16
+ @get_vm_managed_disk_response = ApiStub::Requests::Compute::VirtualMachine.get_vm_with_managed_disk_response(@compute_client)
17
+ @input_params = {vm_name: "fog-test-vm", vm_resource_group: "fog-test-rg", disk_name: "disk1", disk_size_gb: 1, storage_account_name: "mystorage1"}
14
18
  end
15
19
 
16
20
  def test_attach_data_disk_to_vm_success
@@ -20,7 +24,7 @@ class TestAttachDataDiskToVM < Minitest::Test
20
24
  @virtual_machines.stub :get, @get_vm_response do
21
25
  @storage_accounts.stub :list_keys, @storage_access_keys_response do
22
26
  @virtual_machines.stub :create_or_update, @update_vm_response do
23
- assert_equal @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false), @update_vm_response
27
+ assert_equal @service.attach_data_disk_to_vm(@input_params, false), @update_vm_response
24
28
  blob_service.verify
25
29
  end
26
30
  end
@@ -29,13 +33,24 @@ class TestAttachDataDiskToVM < Minitest::Test
29
33
  end
30
34
  end
31
35
 
36
+ def test_attach_managed_disk_to_vm_success
37
+ @virtual_machines.stub :get, @get_vm_response do
38
+ @disks.stub :get, @get_managed_disk_response do
39
+ @virtual_machines.stub :create_or_update, @get_vm_managed_disk_response do
40
+ input_params = {vm_name: "ManagedVM", vm_resource_group: "ManagedRG", disk_name: "ManagedDataDisk1", disk_size_gb: 100, disk_resource_group: "ManagedRG"}
41
+ assert_equal @service.attach_data_disk_to_vm(input_params, false), @get_vm_managed_disk_response
42
+ end
43
+ end
44
+ end
45
+ end
46
+
32
47
  def test_attach_data_disk_to_vm_failure
33
48
  get_vm_response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_15_data_disks_response(@compute_client)
34
49
  @virtual_machines.stub :get, get_vm_response do
35
50
  @storage_accounts.stub :list_keys, @storage_access_keys_response do
36
51
  @virtual_machines.stub :create_or_update, @update_vm_response do
37
52
  assert_raises RuntimeError do
38
- @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false)
53
+ @service.attach_data_disk_to_vm(@input_params, false)
39
54
  end
40
55
  end
41
56
  end
@@ -48,7 +63,7 @@ class TestAttachDataDiskToVM < Minitest::Test
48
63
  @storage_accounts.stub :list_keys, @storage_access_keys_response do
49
64
  @virtual_machines.stub :create_or_update, update_vm_response do
50
65
  assert_raises RuntimeError do
51
- @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false)
66
+ @service.attach_data_disk_to_vm(@input_params, false)
52
67
  end
53
68
  end
54
69
  end
@@ -61,7 +76,7 @@ class TestAttachDataDiskToVM < Minitest::Test
61
76
  @storage_accounts.stub :list_keys, @storage_access_keys_response do
62
77
  @virtual_machines.stub :create_or_update, update_vm_response do
63
78
  assert_raises RuntimeError do
64
- @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false)
79
+ @service.attach_data_disk_to_vm(@input_params, false)
65
80
  end
66
81
  end
67
82
  end
@@ -72,7 +87,7 @@ class TestAttachDataDiskToVM < Minitest::Test
72
87
  get_vm_response = proc { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
73
88
  @virtual_machines.stub :get, get_vm_response do
74
89
  assert_raises RuntimeError do
75
- @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false)
90
+ @service.attach_data_disk_to_vm(@input_params, false)
76
91
  end
77
92
  end
78
93
  end
@@ -82,7 +97,7 @@ class TestAttachDataDiskToVM < Minitest::Test
82
97
  @virtual_machines.stub :get, @get_vm_response do
83
98
  @storage_accounts.stub :list_keys, storage_access_keys_response do
84
99
  assert_raises RuntimeError do
85
- @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1', false)
100
+ @service.attach_data_disk_to_vm(@input_params, false)
86
101
  end
87
102
  end
88
103
  end
@@ -0,0 +1,35 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Create Recovery Vault request
4
+ class TestCreateRecoveryVault < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
8
+ end
9
+
10
+ def test_create_recovery_vault_success
11
+ response = ApiStub::Requests::Storage::RecoveryVault.create_recovery_vault_response
12
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
13
+ RestClient.stub :put, response do
14
+ assert_equal @service.create_or_update_recovery_vault('fog-test-rg', 'westus', 'fog-test-vault'), JSON.parse(response)
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_create_recovery_vault_argument_error
20
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
21
+ assert_raises ArgumentError do
22
+ @service.create_or_update_recovery_vault('fog-test-rg', 'fog-test-vault')
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_create_recovery_vault_exception
28
+ response = -> { fail Exception.new('mocked exception') }
29
+ @token_provider.stub :get_authentication_header, response do
30
+ assert_raises Exception do
31
+ @service.create_or_update_recovery_vault('fog-test-rg', 'westus', 'fog-test-vault')
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Delete Recovery Vault request
4
+ class TestDeleteRecoveryVault < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
8
+ end
9
+
10
+ def test_delete_recovery_vault_success
11
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
12
+ RestClient.stub :delete, true do
13
+ assert @service.delete_recovery_vault('fog-test-rg', 'fog-test-vault'), true
14
+ end
15
+ end
16
+ end
17
+
18
+ def test_delete_recovery_vault_argument_error
19
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
20
+ assert_raises ArgumentError do
21
+ @service.delete_recovery_vault('fog-test-rg')
22
+ end
23
+ end
24
+ end
25
+
26
+ def test_delete_recovery_vault_exception
27
+ response = -> { fail Exception.new('mocked exception') }
28
+ @token_provider.stub :get_authentication_header, response do
29
+ assert_raises Exception do
30
+ assert @service.delete_recovery_vault('fog-test-rg')
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Disable Backup Protection request
4
+ class TestDisableBackupProtection < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
8
+
9
+ @compute_service = Fog::Compute::AzureRM.new(credentials)
10
+ @compute_client = @compute_service.instance_variable_get(:@compute_mgmt_client)
11
+ end
12
+
13
+ def test_disable_backup_protection_success
14
+ response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_response(@compute_client)
15
+ @service.stub :set_recovery_vault_context, true do
16
+ @service.stub :get_virtual_machine_id, response.id do
17
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
18
+ RestClient.stub :put, true do
19
+ assert_equal @service.disable_backup_protection('fog-test-vault', 'fog-test-rg', 'fog-test-vm', 'fog-test-vm-rg'), true
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def test_disable_backup_protection_argument_error
27
+ response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_response(@compute_client)
28
+ @service.stub :set_recovery_vault_context, true do
29
+ @service.stub :get_virtual_machine_id, response.id do
30
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
31
+ assert_raises ArgumentError do
32
+ @service.disable_backup_protection('fog-test-vault', 'fog-test-rg')
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def test_disable_backup_protection_exception
40
+ response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_response(@compute_client)
41
+ rest_client_response = -> { fail RestClient::Exception.new("'body': {'error': {'code': 'ResourceNotFound', 'message': 'mocked exception message'}}") }
42
+ @service.stub :set_recovery_vault_context, true do
43
+ @service.stub :get_virtual_machine_id, response.id do
44
+ @token_provider.stub :get_authentication_header, rest_client_response do
45
+ assert_raises Exception do
46
+ @service.disable_backup_protection('fog-test-vault', 'fog-test-rg', 'fog-test-vm', 'fog-test-vm-rg')
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,66 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Enable Backup Protection request
4
+ class TestEnableBackupProtection < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
8
+
9
+ @compute_service = Fog::Compute::AzureRM.new(credentials)
10
+ @compute_client = @compute_service.instance_variable_get(:@compute_mgmt_client)
11
+
12
+ @response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_response(@compute_client)
13
+ @policy_response = ApiStub::Requests::Storage::RecoveryVault.get_backup_protection_policy_response
14
+ end
15
+
16
+ def test_enable_backup_protection_success
17
+ @service.stub :set_recovery_vault_context, true do
18
+ @service.stub :get_backup_protection_policy, JSON.parse(@policy_response)['value'] do
19
+ @service.stub :get_virtual_machine_id, @response.id do
20
+ @service.stub :get_backup_job_for_vm, nil do
21
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
22
+ RestClient.stub :put, true do
23
+ assert_equal @service.enable_backup_protection('fog-test-vault', 'fog-test-rg', 'fog-test-vm', 'fog-test-vm-rg'), true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ def test_enable_backup_protection_argument_error
33
+ @service.stub :set_recovery_vault_context, true do
34
+ @service.stub :get_backup_protection_policy, JSON.parse(@policy_response)['value'] do
35
+ @service.stub :get_virtual_machine_id, @response.id do
36
+ @service.stub :get_backup_job_for_vm, nil do
37
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
38
+ assert_raises ArgumentError do
39
+ @service.enable_backup_protection('fog-test-vault', 'fog-test-rg')
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def test_enable_backup_protection_exception
49
+ response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_response(@compute_client)
50
+ policy_response = ApiStub::Requests::Storage::RecoveryVault.get_backup_protection_policy_response
51
+ rest_client_response = -> { fail RestClient::Exception.new("'body': {'error': {'code': 'ResourceNotFound', 'message': 'mocked exception message'}}") }
52
+ @service.stub :set_recovery_vault_context, true do
53
+ @service.stub :get_backup_protection_policy, JSON.parse(policy_response)['value'] do
54
+ @service.stub :get_virtual_machine_id, response.id do
55
+ @service.stub :get_backup_job_for_vm, nil do
56
+ @token_provider.stub :get_authentication_header, rest_client_response do
57
+ assert_raises Exception do
58
+ @service.enable_backup_protection('fog-test-vault', 'fog-test-rg', 'fog-test-vm', 'fog-test-vm-rg')
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Get All Backup Jobs request
4
+ class TestGetAllBackupJobs < Minitest::Test
5
+ def setup
6
+ @service = Fog::Storage::AzureRM.new(credentials)
7
+ @token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
8
+ end
9
+
10
+ def test_get_all_backup_jobs_success
11
+ response = ApiStub::Requests::Storage::RecoveryVault.get_all_backup_jobs_response
12
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
13
+ RestClient.stub :get, response do
14
+ assert_equal @service.get_all_backup_jobs('fog-test-vault', 'fog-test-rg'), JSON.parse(response)['value']
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_get_all_backup_jobs_argument_error
20
+ @token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
21
+ assert_raises ArgumentError do
22
+ @service.get_all_backup_jobs('fog-test-vault')
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_get_all_backup_jobs_exception
28
+ response = -> { fail Exception.new('mocked exception') }
29
+ @token_provider.stub :get_authentication_header, response do
30
+ assert_raises Exception do
31
+ @service.get_all_backup_jobs('fog-test-vault', 'fog-test-rg')
32
+ end
33
+ end
34
+ end
35
+ end