2014-08-27 15:17:06 +00:00
|
|
|
from __future__ import unicode_literals
|
2013-02-22 04:13:01 +00:00
|
|
|
import boto
|
2015-12-03 11:51:21 +00:00
|
|
|
from nose.tools import assert_raises
|
2013-08-03 21:21:25 +00:00
|
|
|
import sure # noqa
|
2015-12-03 11:19:10 +00:00
|
|
|
from boto.exception import EC2ResponseError
|
2013-02-22 04:13:01 +00:00
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
from moto import mock_ec2_deprecated
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_ec2_deprecated
|
2015-12-03 11:19:10 +00:00
|
|
|
def test_create_vpn_connections():
|
2019-10-31 15:44:26 +00:00
|
|
|
conn = boto.connect_vpc("the_key", "the_secret")
|
2017-02-24 02:37:43 +00:00
|
|
|
vpn_connection = conn.create_vpn_connection(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ipsec.1", "vgw-0123abcd", "cgw-0123abcd"
|
|
|
|
)
|
2015-12-03 11:19:10 +00:00
|
|
|
vpn_connection.should_not.be.none
|
2019-10-31 15:44:26 +00:00
|
|
|
vpn_connection.id.should.match(r"vpn-\w+")
|
|
|
|
vpn_connection.type.should.equal("ipsec.1")
|
2015-12-03 11:19:10 +00:00
|
|
|
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_ec2_deprecated
|
2015-12-03 11:19:10 +00:00
|
|
|
def test_delete_vpn_connections():
|
2019-10-31 15:44:26 +00:00
|
|
|
conn = boto.connect_vpc("the_key", "the_secret")
|
2017-02-24 02:37:43 +00:00
|
|
|
vpn_connection = conn.create_vpn_connection(
|
2019-10-31 15:44:26 +00:00
|
|
|
"ipsec.1", "vgw-0123abcd", "cgw-0123abcd"
|
|
|
|
)
|
2015-12-03 11:19:10 +00:00
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections()
|
|
|
|
list_of_vpn_connections.should.have.length_of(1)
|
|
|
|
conn.delete_vpn_connection(vpn_connection.id)
|
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections()
|
|
|
|
list_of_vpn_connections.should.have.length_of(0)
|
|
|
|
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_ec2_deprecated
|
2015-12-03 11:19:10 +00:00
|
|
|
def test_delete_vpn_connections_bad_id():
|
2019-10-31 15:44:26 +00:00
|
|
|
conn = boto.connect_vpc("the_key", "the_secret")
|
2015-12-03 11:51:21 +00:00
|
|
|
with assert_raises(EC2ResponseError):
|
2019-10-31 15:44:26 +00:00
|
|
|
conn.delete_vpn_connection("vpn-0123abcd")
|
2015-12-03 11:19:10 +00:00
|
|
|
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_ec2_deprecated
|
2015-12-03 11:19:10 +00:00
|
|
|
def test_describe_vpn_connections():
|
2019-10-31 15:44:26 +00:00
|
|
|
conn = boto.connect_vpc("the_key", "the_secret")
|
2015-12-03 11:19:10 +00:00
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections()
|
|
|
|
list_of_vpn_connections.should.have.length_of(0)
|
2019-10-31 15:44:26 +00:00
|
|
|
conn.create_vpn_connection("ipsec.1", "vgw-0123abcd", "cgw-0123abcd")
|
2015-12-03 11:19:10 +00:00
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections()
|
|
|
|
list_of_vpn_connections.should.have.length_of(1)
|
2019-10-31 15:44:26 +00:00
|
|
|
vpn = conn.create_vpn_connection("ipsec.1", "vgw-1234abcd", "cgw-1234abcd")
|
2015-12-03 11:19:10 +00:00
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections()
|
|
|
|
list_of_vpn_connections.should.have.length_of(2)
|
|
|
|
list_of_vpn_connections = conn.get_all_vpn_connections(vpn.id)
|
|
|
|
list_of_vpn_connections.should.have.length_of(1)
|