From 587893f0c7c1001e6c6b320f090ab1c0d9ccddea Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Thu, 3 Dec 2015 21:59:55 -0500 Subject: [PATCH] Duplicate user needs to be EntityAlreadyExists error code. --- moto/iam/exceptions.py | 4 ++-- moto/iam/models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/moto/iam/exceptions.py b/moto/iam/exceptions.py index f63ad4771..b4d89c0f2 100644 --- a/moto/iam/exceptions.py +++ b/moto/iam/exceptions.py @@ -13,9 +13,9 @@ class IAMNotFoundException(RESTError): class IAMConflictException(RESTError): code = 409 - def __init__(self, message): + def __init__(self, code='Conflict', message=""): super(IAMConflictException, self).__init__( - "Conflict", message) + code, message) class IAMReportNotPresentException(RESTError): diff --git a/moto/iam/models.py b/moto/iam/models.py index f6864b7c9..05e440954 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -344,7 +344,7 @@ class IAMBackend(BaseBackend): def create_user(self, user_name, path='/'): if user_name in self.users: - raise IAMConflictException("User {0} already exists".format(user_name)) + raise IAMConflictException("EntityAlreadyExists", "User {0} already exists".format(user_name)) user = User(user_name, path) self.users[user_name] = user