| 
									
										
										
										
											2014-08-27 11:17:06 -04:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							| 
									
										
										
										
											2013-02-21 23:13:01 -05:00
										 |  |  | import boto | 
					
						
							| 
									
										
										
										
											2013-08-03 17:21:25 -04:00
										 |  |  | import sure  # noqa | 
					
						
							| 
									
										
										
										
											2020-10-06 07:54:49 +02:00
										 |  |  | import pytest | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | from boto.exception import EC2ResponseError | 
					
						
							| 
									
										
										
										
											2013-02-21 23:13:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | from moto import mock_ec2_deprecated | 
					
						
							| 
									
										
										
										
											2013-02-21 23:13:01 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_ec2_deprecated | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | def test_create_customer_gateways(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     conn = boto.connect_vpc("the_key", "the_secret") | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534) | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  |     customer_gateway.should_not.be.none | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     customer_gateway.id.should.match(r"cgw-\w+") | 
					
						
							|  |  |  |     customer_gateway.type.should.equal("ipsec.1") | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  |     customer_gateway.bgp_asn.should.equal(65534) | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     customer_gateway.ip_address.should.equal("205.251.242.54") | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 21:37:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_ec2_deprecated | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | def test_describe_customer_gateways(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     conn = boto.connect_vpc("the_key", "the_secret") | 
					
						
							|  |  |  |     customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534) | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  |     cgws = conn.get_all_customer_gateways() | 
					
						
							|  |  |  |     cgws.should.have.length_of(1) | 
					
						
							|  |  |  |     cgws[0].id.should.match(customer_gateway.id) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 21:37:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_ec2_deprecated | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | def test_delete_customer_gateways(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     conn = boto.connect_vpc("the_key", "the_secret") | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534) | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  |     customer_gateway.should_not.be.none | 
					
						
							|  |  |  |     cgws = conn.get_all_customer_gateways() | 
					
						
							|  |  |  |     cgws[0].id.should.match(customer_gateway.id) | 
					
						
							|  |  |  |     deleted = conn.delete_customer_gateway(customer_gateway.id) | 
					
						
							|  |  |  |     cgws = conn.get_all_customer_gateways() | 
					
						
							|  |  |  |     cgws.should.have.length_of(0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 21:37:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-15 22:35:45 -05:00
										 |  |  | @mock_ec2_deprecated | 
					
						
							| 
									
										
										
										
											2016-01-08 16:48:01 -05:00
										 |  |  | def test_delete_customer_gateways_bad_id(): | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |     conn = boto.connect_vpc("the_key", "the_secret") | 
					
						
							| 
									
										
										
										
											2020-10-06 07:54:49 +02:00
										 |  |  |     with pytest.raises(EC2ResponseError) as cm: | 
					
						
							| 
									
										
										
										
											2019-10-31 08:44:26 -07:00
										 |  |  |         conn.delete_customer_gateway("cgw-0123abcd") |