File: ike_policy_tests.rb

package info (click to toggle)
ruby-fog-openstack 1.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,784 kB
  • sloc: ruby: 47,937; makefile: 5; sh: 4
file content (92 lines) | stat: -rw-r--r-- 2,989 bytes parent folder | download
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
require 'test_helper'

describe "Fog::OpenStack::Network | ike_policy requests" do
  describe "success" do
    before do
      @ike_policy_format = {
        'id'                      => String,
        'name'                    => String,
        'description'             => String,
        'tenant_id'               => String,
        'auth_algorithm'          => String,
        'encryption_algorithm'    => String,
        'pfs'                     => String,
        'phase1_negotiation_mode' => String,
        'lifetime'                => Hash,
        'ike_version'             => String
      }

      attributes = {
        :name                    => 'test-ike-policy',
        :description             => 'Test VPN IKE Policy',
        :tenant_id               => 'tenant_id',
        :auth_algorithm          => 'sha1',
        :encryption_algorithm    => 'aes-256',
        :pfs                     => 'group5',
        :phase1_negotiation_mode => 'main',
        :lifetime                => {'units' => 'seconds', 'value' => 3600},
        :ike_version             => 'v1'
      }

      @ike_policy = network.create_ike_policy(attributes).body
    end

    it "#create_ike_policy" do
      @ike_policy.must_match_schema('ikepolicy' => @ike_policy_format)
    end

    it "#list_ike_policies" do
      network.list_ike_policies.body.
        must_match_schema('ikepolicies' => [@ike_policy_format])
    end

    it "#get_ike_policy" do
      ike_policy_id = network.ike_policies.all.first.id
      network.get_ike_policy(ike_policy_id).body.
        must_match_schema('ikepolicy' => @ike_policy_format)
    end

    it "#update_ike_policy" do
      ike_policy_id = network.ike_policies.all.first.id
      attributes = {
        :name                    => 'rename-test-ike-policy',
        :description             => 'Test VPN IKE Policy',
        :tenant_id               => 'tenant_id',
        :auth_algorithm          => 'sha1',
        :encryption_algorithm    => 'aes-256',
        :pfs                     => 'group5',
        :phase1_negotiation_mode => 'main',
        :lifetime                => {'units' => 'seconds', 'value' => 3600},
        :ike_version             => 'v1'
      }

      network.update_ike_policy(ike_policy_id, attributes).body.
        must_match_schema('ikepolicy' => @ike_policy_format)
    end

    it "#delete_ike_policy" do
      ike_policy_id = network.ike_policies.all.first.id
      network.delete_ike_policy(ike_policy_id).status.must_equal 204
    end
  end

  describe "failure" do
    it "#get_ike_policy" do
      proc do
        network.get_ike_policy(0)
      end.must_raise Fog::OpenStack::Network::NotFound
    end

    it "#update_ike_policy" do
      proc do
        network.update_ike_policy(0, {})
      end.must_raise Fog::OpenStack::Network::NotFound
    end

    it "#delete_ike_policy" do
      proc do
        network.delete_ike_policy(0)
      end.must_raise Fog::OpenStack::Network::NotFound
    end
  end
end