Add support for login profile deletion (#768)

* Add support for delete_login_profile.

Mock deletion of login profile. Set password to
none. Add tests to cover new endpoint.

* Fix typo in create_login_profile response.

Change CreateUserResult to CreateLoginProfileResult
in the CREATE_LOGIN_PROFILE_TEMPLATE. Caused KeyError
when using boto3.

Add test to cover boto3 in addition to boto.
This commit is contained in:
Sean Marlow 2016-11-11 15:05:02 -07:00 committed by Steve Pulec
commit fa3663c610
3 changed files with 40 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import boto
import boto3
import sure # noqa
from boto.exception import BotoServerError
from botocore.exceptions import ClientError
from moto import mock_iam
from moto.iam.models import aws_managed_policies
from nose.tools import assert_raises, assert_equals, assert_not_equals
@ -187,6 +188,7 @@ def test_get_user():
conn.create_user('my-user')
conn.get_user('my-user')
@mock_iam()
def test_list_users():
path_prefix = '/'
@ -211,6 +213,16 @@ def test_create_login_profile():
conn.create_login_profile('my-user', 'my-pass')
@mock_iam()
def test_delete_login_profile():
conn = boto.connect_iam()
conn.create_user('my-user')
with assert_raises(BotoServerError):
conn.delete_login_profile('my-user')
conn.create_login_profile('my-user', 'my-pass')
conn.delete_login_profile('my-user')
@mock_iam()
def test_create_access_key():
conn = boto.connect_iam()
@ -313,3 +325,17 @@ def test_managed_policy():
{'RoleName': role_name},
list_marker='AttachedPolicies')
resp['list_attached_role_policies_response']['list_attached_role_policies_result']['attached_policies'].should.have.length_of(2)
@mock_iam
def test_boto3_create_login_profile():
conn = boto3.client('iam')
with assert_raises(ClientError):
conn.create_login_profile(UserName='my-user', Password='Password')
conn.create_user(UserName='my-user')
conn.create_login_profile(UserName='my-user', Password='Password')
with assert_raises(ClientError):
conn.create_login_profile(UserName='my-user', Password='Password')