diff --git a/moto/iam/models.py b/moto/iam/models.py
index 304a3ee16..84f3274c1 100644
--- a/moto/iam/models.py
+++ b/moto/iam/models.py
@@ -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
diff --git a/moto/iam/responses.py b/moto/iam/responses.py
index 3d6cf3c20..422977bfe 100644
--- a/moto/iam/responses.py
+++ b/moto/iam/responses.py
@@ -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>
{{ action }}UserResponse>"""
+CREATE_LOGIN_PROFILE_TEMPLATE = """
+
+
+
+ {{ user_name }}
+ 2011-09-19T23:00:56Z
+
+
+
+ 7a62c49f-347e-4fc4-9331-6e8eEXAMPLE
+
+
+"""
+
GET_USER_POLICY_TEMPLATE = """
{{ user_name }}
diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py
index b5f75f578..e9121a5aa 100644
--- a/tests/test_iam/test_iam.py
+++ b/tests/test_iam/test_iam.py
@@ -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()