Merge pull request #248 from ttacon/master
Add create_login_profile for iam service
This commit is contained in:
commit
5c9fec17b5
@ -128,6 +128,7 @@ class User(object):
|
||||
|
||||
self.policies = {}
|
||||
self.access_keys = []
|
||||
self.password = None
|
||||
|
||||
def get_policy(self, policy_name):
|
||||
policy_json = None
|
||||
@ -270,6 +271,16 @@ class IAMBackend(BaseBackend):
|
||||
|
||||
return user
|
||||
|
||||
def create_login_profile(self, user_name, password):
|
||||
if not user_name in self.users:
|
||||
raise BotoServerError(404, 'Not Found')
|
||||
|
||||
# This does not currently deal with PasswordPolicyViolation.
|
||||
user = self.users[user_name]
|
||||
if user.password:
|
||||
raise BotoServerError(409, 'Conflict')
|
||||
user.password = password
|
||||
|
||||
def add_user_to_group(self, group_name, user_name):
|
||||
group = None
|
||||
user = None
|
||||
|
@ -112,6 +112,14 @@ class IamResponse(BaseResponse):
|
||||
template = Template(USER_TEMPLATE)
|
||||
return template.render(action='Get', user=user)
|
||||
|
||||
def create_login_profile(self):
|
||||
user_name = self._get_param('UserName')
|
||||
password = self._get_param('Password')
|
||||
iam_backend.create_login_profile(user_name, password)
|
||||
|
||||
template = Template(CREATE_LOGIN_PROFILE_TEMPLATE)
|
||||
return template.render(user_name=user_name)
|
||||
|
||||
def add_user_to_group(self):
|
||||
group_name = self._get_param('GroupName')
|
||||
user_name = self._get_param('UserName')
|
||||
@ -439,6 +447,20 @@ USER_TEMPLATE = """<{{ action }}UserResponse>
|
||||
</ResponseMetadata>
|
||||
</{{ action }}UserResponse>"""
|
||||
|
||||
CREATE_LOGIN_PROFILE_TEMPLATE = """
|
||||
<CreateLoginProfileResponse>
|
||||
<CreateUserResult>
|
||||
<LoginProfile>
|
||||
<UserName>{{ user_name }}</UserName>
|
||||
<CreateDate>2011-09-19T23:00:56Z</CreateDate>
|
||||
</LoginProfile>
|
||||
</CreateUserResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestId>
|
||||
</ResponseMetadata>
|
||||
</CreateLoginProfileResponse>
|
||||
"""
|
||||
|
||||
GET_USER_POLICY_TEMPLATE = """<GetUserPolicyResponse>
|
||||
<GetUserPolicyResult>
|
||||
<UserName>{{ user_name }}</UserName>
|
||||
|
@ -96,6 +96,17 @@ def test_get_user():
|
||||
conn.get_user('my-user')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_create_login_profile():
|
||||
conn = boto.connect_iam()
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_login_profile('my-user', 'my-pass')
|
||||
conn.create_user('my-user')
|
||||
conn.create_login_profile('my-user', 'my-pass')
|
||||
with assert_raises(BotoServerError):
|
||||
conn.create_login_profile('my-user', 'my-pass')
|
||||
|
||||
|
||||
@mock_iam()
|
||||
def test_add_user_to_group():
|
||||
conn = boto.connect_iam()
|
||||
|
Loading…
Reference in New Issue
Block a user