File: assign_private_ip_tests.rb

package info (click to toggle)
ruby-fog-aws 3.33.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,180 kB
  • sloc: ruby: 75,405; javascript: 14; makefile: 9; sh: 4
file content (55 lines) | stat: -rw-r--r-- 2,368 bytes parent folder | download | duplicates (5)
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
Shindo.tests('Fog::Compute[:aws] | internet_gateway requests', ['aws']) do

  tests('success') do
    Fog::AWS::Compute::Mock.reset if Fog.mocking?

    @vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
    @vpc_id = @vpc.id

    @subnet=Fog::Compute[:aws].subnets.create('vpc_id' => @vpc_id, 'cidr_block' => '10.0.10.0/24')
    @subnet_id = @subnet.subnet_id

    @network_interface = Fog::Compute[:aws].network_interfaces.new(:subnet_id => @subnet_id)
    @network_interface.save
    @network_interface_id =  @network_interface.network_interface_id

    @ip_address = Fog::AWS::Mock.ip_address
    @second_ip_address = Fog::AWS::Mock.ip_address

    tests("#assign_private_ip_addresses('#{@network_interface_id}', {'PrivateIpAddresses'=>['#{@ip_address}','#{@second_ip_address}']})").formats(AWS::Compute::Formats::BASIC) do
      Fog::Compute[:aws].assign_private_ip_addresses(@network_interface_id, { 'PrivateIpAddresses' =>[@ip_address, @second_ip_address]}).body
    end

    tests("#assign_private_ip_addresses('#{@network_interface_id}', {'SecondaryPrivateIpAddressCount'=>4})").formats(AWS::Compute::Formats::BASIC) do
      Fog::Compute[:aws].assign_private_ip_addresses(@network_interface_id, {'SecondaryPrivateIpAddressCount'=>4}).body
    end

    @network_interface.destroy
    @subnet.destroy
    @vpc.destroy
  end

  tests('failure') do
    Fog::AWS::Compute::Mock.reset if Fog.mocking?

    @vpc=Fog::Compute[:aws].vpcs.create('cidr_block' => '10.0.10.0/24')
    @vpc_id = @vpc.id

    @subnet=Fog::Compute[:aws].subnets.create('vpc_id' => @vpc_id, 'cidr_block' => '10.0.10.0/24')
    @subnet_id = @subnet.subnet_id

    @network_interface = Fog::Compute[:aws].network_interfaces.new(:subnet_id => @subnet_id)
    @network_interface.save
    @network_interface_id =  @network_interface.network_interface_id

    @ip_address = Fog::AWS::Mock.ip_address

    tests("#assign_private_ip_addresses('#{@network_interface_id}', {'PrivateIpAddresses'=>['#{@ip_address}','#{@second_ip_address}'], 'SecondaryPrivateIpAddressCount'=>4 })").raises(Fog::AWS::Compute::Error) do
      Fog::Compute[:aws].assign_private_ip_addresses(@network_interface_id, { 'PrivateIpAddresses' =>[@ip_address, @second_ip_address], 'SecondaryPrivateIpAddressCount'=>4 }).body
    end

    @network_interface.destroy
    @subnet.destroy
    @vpc.destroy
  end
end