Merge branch 'master' into ts/throw-client-error-on-head-bucket
This commit is contained in:
commit
e66b6173c9
8 changed files with 136 additions and 18 deletions
|
|
@ -569,7 +569,6 @@ def test_describe_stack_events_shows_create_update_and_delete():
|
|||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
@mock_route53_deprecated
|
||||
def test_create_stack_lambda_and_dynamodb():
|
||||
conn = boto.connect_cloudformation()
|
||||
dummy_template = {
|
||||
|
|
@ -643,3 +642,31 @@ def test_create_stack_lambda_and_dynamodb():
|
|||
stack = conn.describe_stacks()[0]
|
||||
resources = stack.list_resources()
|
||||
assert len(resources) == 4
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_create_stack_kinesis():
|
||||
conn = boto.connect_cloudformation()
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack Kinesis Test 1",
|
||||
"Parameters": {},
|
||||
"Resources": {
|
||||
"stream1": {
|
||||
"Type" : "AWS::Kinesis::Stream",
|
||||
"Properties" : {
|
||||
"Name": "stream1",
|
||||
"ShardCount": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
conn.create_stack(
|
||||
"test_stack_kinesis_1",
|
||||
template_body=json.dumps(dummy_template),
|
||||
parameters={}.items()
|
||||
)
|
||||
|
||||
stack = conn.describe_stacks()[0]
|
||||
resources = stack.list_resources()
|
||||
assert len(resources) == 1
|
||||
|
|
|
|||
|
|
@ -9,12 +9,6 @@ from boto.ec2.elb.attributes import (
|
|||
ConnectionDrainingAttribute,
|
||||
AccessLogAttribute,
|
||||
)
|
||||
from boto.ec2.elb.policies import (
|
||||
Policies,
|
||||
AppCookieStickinessPolicy,
|
||||
LBCookieStickinessPolicy,
|
||||
OtherPolicy,
|
||||
)
|
||||
from botocore.exceptions import ClientError
|
||||
from boto.exception import BotoServerError
|
||||
from nose.tools import assert_raises
|
||||
|
|
@ -24,17 +18,22 @@ from moto import mock_elb, mock_ec2, mock_elb_deprecated, mock_ec2_deprecated
|
|||
|
||||
|
||||
@mock_elb_deprecated
|
||||
@mock_ec2_deprecated
|
||||
def test_create_load_balancer():
|
||||
conn = boto.connect_elb()
|
||||
ec2 = boto.connect_ec2('the_key', 'the_secret')
|
||||
|
||||
security_group = ec2.create_security_group('sg-abc987', 'description')
|
||||
|
||||
zones = ['us-east-1a', 'us-east-1b']
|
||||
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
|
||||
conn.create_load_balancer('my-lb', zones, ports, scheme='internal')
|
||||
conn.create_load_balancer('my-lb', zones, ports, scheme='internal', security_groups=[security_group.id])
|
||||
|
||||
balancers = conn.get_all_load_balancers()
|
||||
balancer = balancers[0]
|
||||
balancer.name.should.equal("my-lb")
|
||||
balancer.scheme.should.equal("internal")
|
||||
list(balancer.security_groups).should.equal([security_group.id])
|
||||
set(balancer.availability_zones).should.equal(
|
||||
set(['us-east-1a', 'us-east-1b']))
|
||||
listener1 = balancer.listeners[0]
|
||||
|
|
@ -143,6 +142,38 @@ def test_describe_paginated_balancers():
|
|||
assert 'NextToken' not in resp2.keys()
|
||||
|
||||
|
||||
@mock_elb
|
||||
@mock_ec2
|
||||
def test_apply_security_groups_to_load_balancer():
|
||||
client = boto3.client('elb', region_name='us-east-1')
|
||||
ec2 = boto3.resource('ec2', region_name='us-east-1')
|
||||
|
||||
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
|
||||
security_group = ec2.create_security_group(
|
||||
GroupName='sg01', Description='Test security group sg01', VpcId=vpc.id)
|
||||
|
||||
client.create_load_balancer(
|
||||
LoadBalancerName='my-lb',
|
||||
Listeners=[
|
||||
{'Protocol': 'tcp', 'LoadBalancerPort': 80, 'InstancePort': 8080}],
|
||||
AvailabilityZones=['us-east-1a', 'us-east-1b']
|
||||
)
|
||||
|
||||
response = client.apply_security_groups_to_load_balancer(
|
||||
LoadBalancerName='my-lb',
|
||||
SecurityGroups=[security_group.id])
|
||||
|
||||
assert response['SecurityGroups'] == [security_group.id]
|
||||
balancer = client.describe_load_balancers()['LoadBalancerDescriptions'][0]
|
||||
assert balancer['SecurityGroups'] == [security_group.id]
|
||||
|
||||
# Using a not-real security group raises an error
|
||||
with assert_raises(ClientError) as error:
|
||||
response = client.apply_security_groups_to_load_balancer(
|
||||
LoadBalancerName='my-lb',
|
||||
SecurityGroups=['not-really-a-security-group'])
|
||||
assert "One or more of the specified security groups do not exist." in str(error.exception)
|
||||
|
||||
|
||||
@mock_elb_deprecated
|
||||
def test_add_listener():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue