commit
2f66709583
7 changed files with 627 additions and 6 deletions
|
|
@ -195,3 +195,22 @@ def test_authorize_group_in_vpc():
|
|||
# And check that it gets revoked
|
||||
security_group = [group for group in conn.get_all_security_groups() if group.name == 'test1'][0]
|
||||
security_group.rules.should.have.length_of(0)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_get_all_security_groups():
|
||||
conn = boto.connect_ec2()
|
||||
conn.create_security_group(name='test1', description='test1', vpc_id='vpc-mjm05d27')
|
||||
conn.create_security_group(name='test2', description='test2')
|
||||
|
||||
resp = conn.get_all_security_groups(groupnames=['test1'])
|
||||
resp.should.have.length_of(1)
|
||||
|
||||
resp = conn.get_all_security_groups(filters={'vpc_id': ['vpc-mjm05d27']})
|
||||
resp.should.have.length_of(1)
|
||||
|
||||
resp = conn.get_all_security_groups(filters={'description': ['test1']})
|
||||
resp.should.have.length_of(1)
|
||||
|
||||
resp = conn.get_all_security_groups()
|
||||
resp.should.have.length_of(2)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
import boto
|
||||
|
||||
import sure # noqa
|
||||
|
||||
from nose.tools import assert_raises, assert_equals, assert_not_equals
|
||||
from boto.exception import BotoServerError
|
||||
|
||||
from moto import mock_iam
|
||||
|
||||
|
||||
|
|
@ -58,3 +60,105 @@ def test_create_role_and_instance_profile():
|
|||
|
||||
conn.list_roles().roles[0].role_name.should.equal('my-role')
|
||||
conn.list_instance_profiles().instance_profiles[0].instance_profile_name.should.equal("my-profile")
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_create_group():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_group('my-group')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_group('my-group')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_get_group():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_group('my-group')
|
||||
conn.get_group('my-group')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.get_group('not-group')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_create_user():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_user('my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_user('my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_get_user():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.get_user('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.get_user('my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_add_user_to_group():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.create_group('my-group')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_remove_user_from_group():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
conn.create_group('my-group')
|
||||
conn.create_user('my-user')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
conn.add_user_to_group('my-group', 'my-user')
|
||||
conn.remove_user_from_group('my-group', 'my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_create_access_key():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_access_key('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.create_access_key('my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_get_all_access_keys():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_user('my-user')
|
||||
response = conn.get_all_access_keys('my-user')
|
||||
assert_equals(
|
||||
response['list_access_keys_response']['list_access_keys_result']['access_key_metadata'],
|
||||
[]
|
||||
)
|
||||
conn.create_access_key('my-user')
|
||||
response = conn.get_all_access_keys('my-user')
|
||||
assert_not_equals(
|
||||
response['list_access_keys_response']['list_access_keys_result']['access_key_metadata'],
|
||||
[]
|
||||
)
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_delete_access_key():
|
||||
conn = boto.connect_iam()
|
||||
conn.create_user('my-user')
|
||||
access_key_id = conn.create_access_key('my-user')['create_access_key_response']['create_access_key_result']['access_key']['access_key_id']
|
||||
conn.delete_access_key(access_key_id, 'my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_delete_user():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.delete_user('my-user')
|
||||
conn.create_user('my-user')
|
||||
conn.delete_user('my-user')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue