fog-azure-rm 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +9 -0
- data/lib/fog/azurerm/docs/compute.md +1 -1
- data/lib/fog/azurerm/docs/sql.md +39 -0
- data/lib/fog/azurerm/docs/storage.md +89 -2
- data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -7
- data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -6
- data/lib/fog/azurerm/models/compute/servers.rb +5 -8
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +0 -3
- data/lib/fog/azurerm/models/dns/record_sets.rb +5 -9
- data/lib/fog/azurerm/models/dns/zones.rb +4 -7
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +0 -3
- data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +5 -9
- data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -7
- data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -5
- data/lib/fog/azurerm/models/network/load_balancers.rb +4 -7
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +0 -3
- data/lib/fog/azurerm/models/network/network_interfaces.rb +4 -7
- data/lib/fog/azurerm/models/network/network_security_groups.rb +4 -7
- data/lib/fog/azurerm/models/network/network_security_rules.rb +2 -6
- data/lib/fog/azurerm/models/network/public_ips.rb +4 -7
- data/lib/fog/azurerm/models/network/subnets.rb +5 -9
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +0 -3
- data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -7
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -7
- data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -5
- data/lib/fog/azurerm/models/resources/deployments.rb +4 -7
- data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -7
- data/lib/fog/azurerm/models/sql/firewall_rule.rb +52 -0
- data/lib/fog/azurerm/models/sql/firewall_rules.rb +28 -0
- data/lib/fog/azurerm/models/storage/data_disk.rb +1 -0
- data/lib/fog/azurerm/models/storage/directories.rb +1 -4
- data/lib/fog/azurerm/models/storage/files.rb +1 -4
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +50 -0
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +27 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +23 -4
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +5 -7
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +4 -4
- data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +56 -0
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +4 -5
- data/lib/fog/azurerm/requests/sql/delete_database.rb +4 -4
- data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +36 -0
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +2 -2
- data/lib/fog/azurerm/requests/sql/get_database.rb +2 -2
- data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +43 -0
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +2 -2
- data/lib/fog/azurerm/requests/sql/list_databases.rb +2 -2
- data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +55 -0
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_disk.rb +36 -0
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +54 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +13 -2
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +5 -9
- data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +35 -0
- data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +60 -0
- data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +61 -0
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +56 -0
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +53 -0
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +58 -0
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +53 -0
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +64 -0
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +49 -0
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +48 -0
- data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +36 -0
- data/lib/fog/azurerm/requests/storage/start_backup.rb +54 -0
- data/lib/fog/azurerm/requests/storage/update_storage_account.rb +59 -0
- data/lib/fog/azurerm/sql.rb +9 -0
- data/lib/fog/azurerm/storage.rb +24 -0
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +8 -0
- data/rakefile +11 -3
- data/test/api_stub.rb +4 -0
- data/test/api_stub/models/sql/sql_firewall_rule.rb +22 -0
- data/test/api_stub/models/storage/recovery_vault.rb +23 -0
- data/test/api_stub/requests/sql/firewall_rule.rb +46 -0
- data/test/api_stub/requests/storage/recovery_vault.rb +189 -0
- data/test/api_stub/requests/storage/storageaccount.rb +2 -1
- data/test/integration/container.rb +4 -3
- data/test/integration/data_disk.rb +77 -0
- data/test/integration/express_route_circuit.rb +9 -9
- data/test/integration/server.rb +9 -2
- data/test/integration/sql_server.rb +35 -0
- data/test/integration/storage_account.rb +9 -1
- data/test/models/sql/test_firewall_rule.rb +54 -0
- data/test/models/sql/test_firewall_rules.rb +41 -0
- data/test/models/storage/test_recovery_vault.rb +61 -0
- data/test/models/storage/test_recovery_vaults.rb +47 -0
- data/test/models/storage/test_storage_account.rb +8 -1
- data/test/requests/sql/test_create_or_update_firewall_rule.rb +27 -0
- data/test/requests/sql/test_delete_firewall_rule.rb +34 -0
- data/test/requests/sql/test_get_firewall_rule.rb +35 -0
- data/test/requests/sql/test_list_firewall_rules.rb +35 -0
- data/test/requests/storage/test_create_disk.rb +17 -0
- data/test/requests/storage/test_create_recovery_vault.rb +35 -0
- data/test/requests/storage/test_delete_disk.rb +23 -0
- data/test/requests/storage/test_delete_recovery_vault.rb +34 -0
- data/test/requests/storage/test_disable_backup_protection.rb +52 -0
- data/test/requests/storage/test_enable_backup_protection.rb +66 -0
- data/test/requests/storage/test_get_all_backup_jobs.rb +35 -0
- data/test/requests/storage/test_get_backup_container.rb +35 -0
- data/test/requests/storage/test_get_backup_item.rb +35 -0
- data/test/requests/storage/test_get_backup_job_for_vm.rb +26 -0
- data/test/requests/storage/test_get_backup_protection_policy.rb +35 -0
- data/test/requests/storage/test_get_recovery_vault.rb +35 -0
- data/test/requests/storage/test_list_recovery_vault.rb +35 -0
- data/test/requests/storage/test_set_recovery_vault_context.rb +34 -0
- data/test/requests/storage/test_start_backup.rb +55 -0
- data/test/requests/storage/test_update_storage_account.rb +34 -0
- data/test/smoke_tests/compute/test_resource_group_smoke.rb +34 -24
- data/test/test_helper.rb +26 -0
- metadata +55 -2
@@ -28,7 +28,8 @@ class TestStorageAccount < Minitest::Test
|
|
28
28
|
:location,
|
29
29
|
:resource_group,
|
30
30
|
:sku_name,
|
31
|
-
:replication
|
31
|
+
:replication,
|
32
|
+
:encryption
|
32
33
|
]
|
33
34
|
attributes.each do |attribute|
|
34
35
|
assert_respond_to @storage_account, attribute
|
@@ -56,6 +57,12 @@ class TestStorageAccount < Minitest::Test
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
60
|
+
def test_update_method_response
|
61
|
+
@service.stub :update_storage_account, @storage_account_response do
|
62
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccount, @storage_account.update({})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
59
66
|
def test_get_access_keys_method_response
|
60
67
|
key1 = Azure::ARM::Storage::Models::StorageAccountKey.new
|
61
68
|
key1.key_name = 'key1'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Create Sql Server Firewall Rule
|
4
|
+
class TestCreateOrUpdateFirewallRule < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Sql::AzureRM.new(credentials)
|
7
|
+
@token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_create_or_update_sql_server_firewall_rule_success
|
11
|
+
firewall_rule_response = ApiStub::Requests::Sql::FirewallRule.create_firewall_rule_response
|
12
|
+
data_hash = ApiStub::Requests::Sql::FirewallRule.firewall_rule_hash
|
13
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
14
|
+
RestClient.stub :put, firewall_rule_response do
|
15
|
+
assert_equal @service.create_or_update_firewall_rule(data_hash), JSON.parse(firewall_rule_response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_create_or_update_sql_server_firewall_rule_failure
|
21
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
22
|
+
assert_raises ArgumentError do
|
23
|
+
@service.create_or_update_firewall_rule('test-resource-group', 'test-server-name')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Delete Sql Server Firewall Rule
|
4
|
+
class TestDeleteFirewallRule < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Sql::AzureRM.new(credentials)
|
7
|
+
@token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_delete_sql_server_firewall_rule_success
|
11
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
12
|
+
RestClient.stub :delete, true do
|
13
|
+
assert @service.delete_firewall_rule('fog-test-rg', 'fog-test-server-name', 'rule-name')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_delete_sql_server_firewall_rule_failure
|
19
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
20
|
+
assert_raises ArgumentError do
|
21
|
+
@service.delete_firewall_rule('fog-test-name')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_delete_sql_server_firewall_rule_exception
|
27
|
+
response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
28
|
+
@token_provider.stub :get_authentication_header, response do
|
29
|
+
assert_raises Exception do
|
30
|
+
assert @service.delete_firewall_rule('fog-test-rg', 'fog-test-server-name', 'rule-name')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Get Sql Server Firewall Rule
|
4
|
+
class TestGetFirewallRule < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Sql::AzureRM.new(credentials)
|
7
|
+
@token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_get_sql_server_firewall_rule_success
|
11
|
+
create_response = ApiStub::Requests::Sql::FirewallRule.create_firewall_rule_response
|
12
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
13
|
+
RestClient.stub :get, create_response do
|
14
|
+
assert_equal @service.get_firewall_rule('fog-test-rg', 'fog-test-server-name', 'rule-name'), JSON.parse(create_response)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_sql_server_firewall_rule_failure
|
20
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
@service.get_firewall_rule('fog-test-rg')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_sql_server_firewall_rule_exception
|
28
|
+
response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
29
|
+
@token_provider.stub :get_authentication_header, response do
|
30
|
+
assert_raises Exception do
|
31
|
+
@service.get_firewall_rule('fog-test-rg', 'fog-test-server-name', 'rule-name')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for List Sql Server Firewall Rule Request
|
4
|
+
class TestListFirewallRules < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Sql::AzureRM.new(credentials)
|
7
|
+
@token_provider = Fog::Credentials::AzureRM.instance_variable_get(:@token_provider)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_list_sql_server_firewall_rules_success
|
11
|
+
list_response = ApiStub::Requests::Sql::FirewallRule.list_firewall_rule_response
|
12
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
13
|
+
RestClient.stub :get, list_response do
|
14
|
+
assert_equal @service.list_firewall_rules('fog-test-rg', 'server-name'), JSON.parse(list_response)['value']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_list_sql_servers_firewall_rules_failure
|
20
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
@service.list_firewall_rules('fog-test-rg')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_list_sql_servers_firewall_rules_exception
|
28
|
+
response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
29
|
+
@token_provider.stub :get_authentication_header, response do
|
30
|
+
assert_raises Exception do
|
31
|
+
@service.list_firewall_rules('fog-test-rg', 'server-name')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Data Disk Class
|
4
|
+
class TestCreateDisk < Minitest::Test
|
5
|
+
# This class posesses the test cases for the request of create disk.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@storage_data_disk_object = ApiStub::Requests::Storage::File.upload_block_blob_from_file
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create_disk_success
|
13
|
+
@service.stub :upload_block_blob_from_file, @storage_data_disk_object do
|
14
|
+
assert @service.create_disk('test_blob', options = {})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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,23 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Data Disk Class
|
4
|
+
class TestDeleteDisk < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of deleting data disks.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@storage_data_disk_object = ApiStub::Requests::Storage::File.get_blob_properties
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_delete_disk_success
|
13
|
+
@service.stub :delete_blob, nil do
|
14
|
+
assert @service.delete_disk('testblob1')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_delete_disk_failure
|
19
|
+
@service.stub :delete_blob, @storage_data_disk_object do
|
20
|
+
assert !@service.delete_disk('testblob1')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Get Backup Container request
|
4
|
+
class TestGetBackupContainer < 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_backup_container_success
|
11
|
+
response = ApiStub::Requests::Storage::RecoveryVault.get_backup_container_response
|
12
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
13
|
+
RestClient.stub :get, response do
|
14
|
+
assert_equal @service.get_backup_container('fog-test-rg', 'fog-test-vault', 'fog-test-vm'), JSON.parse(response)['value']
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_backup_container_argument_error
|
20
|
+
@token_provider.stub :get_authentication_header, 'Bearer <some-token>' do
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
@service.get_backup_container('fog-test-rg', 'fog-test-vault')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_get_backup_container_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_backup_container('fog-test-rg', 'fog-test-vault', 'fog-test-vm')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|