Add create_login_profile for iam service
This commit is contained in:
parent
2881c9b20c
commit
5aec4d9de5
@ -128,6 +128,7 @@ class User(object):
|
|||||||
|
|
||||||
self.policies = {}
|
self.policies = {}
|
||||||
self.access_keys = []
|
self.access_keys = []
|
||||||
|
self.password = None
|
||||||
|
|
||||||
def get_policy(self, policy_name):
|
def get_policy(self, policy_name):
|
||||||
policy_json = None
|
policy_json = None
|
||||||
@ -270,6 +271,16 @@ class IAMBackend(BaseBackend):
|
|||||||
|
|
||||||
return user
|
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):
|
def add_user_to_group(self, group_name, user_name):
|
||||||
group = None
|
group = None
|
||||||
user = None
|
user = None
|
||||||
|
@ -112,6 +112,14 @@ class IamResponse(BaseResponse):
|
|||||||
template = Template(USER_TEMPLATE)
|
template = Template(USER_TEMPLATE)
|
||||||
return template.render(action='Get', user=user)
|
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):
|
def add_user_to_group(self):
|
||||||
group_name = self._get_param('GroupName')
|
group_name = self._get_param('GroupName')
|
||||||
user_name = self._get_param('UserName')
|
user_name = self._get_param('UserName')
|
||||||
@ -439,6 +447,20 @@ USER_TEMPLATE = """<{{ action }}UserResponse>
|
|||||||
</ResponseMetadata>
|
</ResponseMetadata>
|
||||||
</{{ action }}UserResponse>"""
|
</{{ 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>
|
GET_USER_POLICY_TEMPLATE = """<GetUserPolicyResponse>
|
||||||
<GetUserPolicyResult>
|
<GetUserPolicyResult>
|
||||||
<UserName>{{ user_name }}</UserName>
|
<UserName>{{ user_name }}</UserName>
|
||||||
|
@ -96,6 +96,17 @@ def test_get_user():
|
|||||||
conn.get_user('my-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()
|
@mock_iam()
|
||||||
def test_add_user_to_group():
|
def test_add_user_to_group():
|
||||||
conn = boto.connect_iam()
|
conn = boto.connect_iam()
|
||||||
|
Loading…
Reference in New Issue
Block a user