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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
# -*- coding: UTF-8 -*-
from tests.compat import OrderedDict
from tests.unit import unittest
from tests.unit import AWSMockServiceTestCase
from boto.vpc import VPCConnection, VpnGateway, Attachment
class TestDescribeVpnGateways(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<DescribeVpnGatewaysResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<vpnGatewaySet>
<item>
<vpnGatewayId>vgw-8db04f81</vpnGatewayId>
<state>available</state>
<type>ipsec.1</type>
<availabilityZone>us-east-1a</availabilityZone>
<attachments>
<item>
<vpcId>vpc-1a2b3c4d</vpcId>
<state>attached</state>
</item>
</attachments>
<tagSet/>
</item>
</vpnGatewaySet>
</DescribeVpnGatewaysResponse>
"""
def test_get_all_vpn_gateways(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.get_all_vpn_gateways(
'vgw-8db04f81', filters=OrderedDict([('state', ['pending', 'available']),
('availability-zone', 'us-east-1a')]))
self.assert_request_parameters({
'Action': 'DescribeVpnGateways',
'VpnGatewayId.1': 'vgw-8db04f81',
'Filter.1.Name': 'state',
'Filter.1.Value.1': 'pending',
'Filter.1.Value.2': 'available',
'Filter.2.Name': 'availability-zone',
'Filter.2.Value.1': 'us-east-1a'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertEqual(len(api_response), 1)
self.assertIsInstance(api_response[0], VpnGateway)
self.assertEqual(api_response[0].id, 'vgw-8db04f81')
class TestCreateVpnGateway(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<CreateVpnGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<vpnGateway>
<vpnGatewayId>vgw-8db04f81</vpnGatewayId>
<state>pending</state>
<type>ipsec.1</type>
<availabilityZone>us-east-1a</availabilityZone>
<attachments/>
<tagSet/>
</vpnGateway>
</CreateVpnGatewayResponse>
"""
def test_delete_vpn_gateway(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.create_vpn_gateway('ipsec.1', 'us-east-1a')
self.assert_request_parameters({
'Action': 'CreateVpnGateway',
'AvailabilityZone': 'us-east-1a',
'Type': 'ipsec.1'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertIsInstance(api_response, VpnGateway)
self.assertEquals(api_response.id, 'vgw-8db04f81')
class TestDeleteVpnGateway(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<DeleteVpnGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<return>true</return>
</DeleteVpnGatewayResponse>
"""
def test_delete_vpn_gateway(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.delete_vpn_gateway('vgw-8db04f81')
self.assert_request_parameters({
'Action': 'DeleteVpnGateway',
'VpnGatewayId': 'vgw-8db04f81'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertEqual(api_response, True)
class TestAttachVpnGateway(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<AttachVpnGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<attachment>
<vpcId>vpc-1a2b3c4d</vpcId>
<state>attaching</state>
</attachment>
</AttachVpnGatewayResponse>
"""
def test_attach_vpn_gateway(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.attach_vpn_gateway('vgw-8db04f81', 'vpc-1a2b3c4d')
self.assert_request_parameters({
'Action': 'AttachVpnGateway',
'VpnGatewayId': 'vgw-8db04f81',
'VpcId': 'vpc-1a2b3c4d'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertIsInstance(api_response, Attachment)
self.assertEquals(api_response.vpc_id, 'vpc-1a2b3c4d')
self.assertEquals(api_response.state, 'attaching')
class TestDetachVpnGateway(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<DetachVpnGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
<return>true</return>
</DetachVpnGatewayResponse>
"""
def test_detach_vpn_gateway(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.detach_vpn_gateway('vgw-8db04f81', 'vpc-1a2b3c4d')
self.assert_request_parameters({
'Action': 'DetachVpnGateway',
'VpnGatewayId': 'vgw-8db04f81',
'VpcId': 'vpc-1a2b3c4d'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertEqual(api_response, True)
class TestDisableVgwRoutePropagation(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<DisableVgwRoutePropagationResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>4f35a1b2-c2c3-4093-b51f-abb9d7311990</requestId>
<return>true</return>
</DisableVgwRoutePropagationResponse>
"""
def test_disable_vgw_route_propagation(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.disable_vgw_route_propagation(
'rtb-c98a35a0', 'vgw-d8e09e8a')
self.assert_request_parameters({
'Action': 'DisableVgwRoutePropagation',
'GatewayId': 'vgw-d8e09e8a',
'RouteTableId': 'rtb-c98a35a0'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertEqual(api_response, True)
class TestEnableVgwRoutePropagation(AWSMockServiceTestCase):
connection_class = VPCConnection
def default_body(self):
return b"""
<DisableVgwRoutePropagationResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>4f35a1b2-c2c3-4093-b51f-abb9d7311990</requestId>
<return>true</return>
</DisableVgwRoutePropagationResponse>
"""
def test_enable_vgw_route_propagation(self):
self.set_http_response(status_code=200)
api_response = self.service_connection.enable_vgw_route_propagation(
'rtb-c98a35a0', 'vgw-d8e09e8a')
self.assert_request_parameters({
'Action': 'EnableVgwRoutePropagation',
'GatewayId': 'vgw-d8e09e8a',
'RouteTableId': 'rtb-c98a35a0'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
self.assertEqual(api_response, True)
if __name__ == '__main__':
unittest.main()
|