1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
require "test_helper"
describe "Fog::OpenStack::Network | ipsec_policy requests" do
before do
@ipsec_policy_format = {
'id' => String,
'name' => String,
'description' => String,
'tenant_id' => String,
'lifetime' => Hash,
'pfs' => String,
'transform_protocol' => String,
'auth_algorithm' => String,
'encapsulation_mode' => String,
'encryption_algorithm' => String
}
end
describe "success" do
before do
attributes = {
:name => 'test-ipsec-policy',
:description => 'Test VPN ipsec Policy',
:tenant_id => 'tenant_id',
:auth_algorithm => 'sha1',
:encryption_algorithm => 'aes-128',
:pfs => 'group5',
:transform_protocol => 'esp',
:lifetime => {'units' => 'seconds', 'value' => 3600},
:encapsulation_mode => 'tunnel'
}
@create_ipsec_policy = network.create_ipsec_policy(attributes).body
end
it "#create_ipsec_policy" do
@create_ipsec_policy.must_match_schema('ipsecpolicy' => @ipsec_policy_format)
end
it "#list_ipsec_policies" do
network.list_ipsec_policies.body.
must_match_schema('ipsecpolicies' => [@ipsec_policy_format])
end
it "#get_ipsec_policy" do
ipsec_policy_id = network.ipsec_policies.all.first.id
network.get_ipsec_policy(ipsec_policy_id).body.
must_match_schema('ipsecpolicy' => @ipsec_policy_format)
end
it "#update_ipsec_policy" do
ipsec_policy_id = network.ipsec_policies.all.first.id
attributes = {
:name => 'rename-test-ipsec-policy',
:description => 'Test VPN ipsec Policy',
:tenant_id => 'tenant_id',
:auth_algorithm => 'sha1',
:encryption_algorithm => 'aes-128',
:pfs => 'group5',
:transform_protocol => 'esp',
:lifetime => {'units' => 'seconds', 'value' => 3600},
:encapsulation_mode => 'tunnel'
}
network.update_ipsec_policy(ipsec_policy_id, attributes).body.
must_match_schema('ipsecpolicy' => @ipsec_policy_format)
end
it "#delete_ipsec_policy" do
ipsec_policy_id = network.ipsec_policies.all.first.id
network.delete_ipsec_policy(ipsec_policy_id).status.must_equal 204
end
end
describe "failure" do
it "#get_ipsec_policy" do
proc do
network.get_ipsec_policy(0)
end.must_raise Fog::OpenStack::Network::NotFound
end
it "#update_ipsec_policy" do
proc do
network.update_ipsec_policy(0, {})
end.must_raise Fog::OpenStack::Network::NotFound
end
it "#delete_ipsec_policy" do
proc do
network.delete_ipsec_policy(0)
end.must_raise Fog::OpenStack::Network::NotFound
end
end
end
|