Merge pull request #2542 from ianyon/create_policy_already_exist
Added Exception for create_policy when policy exists
This commit is contained in:
commit
7ca35514ca
3 changed files with 31 additions and 4 deletions
|
|
@ -408,6 +408,21 @@ def test_create_policy():
|
|||
)
|
||||
|
||||
|
||||
@mock_iam
|
||||
def test_create_policy_already_exists():
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
response = conn.create_policy(
|
||||
PolicyName="TestCreatePolicy", PolicyDocument=MOCK_POLICY
|
||||
)
|
||||
with assert_raises(conn.exceptions.EntityAlreadyExistsException) as ex:
|
||||
response = conn.create_policy(
|
||||
PolicyName="TestCreatePolicy", PolicyDocument=MOCK_POLICY
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("EntityAlreadyExists")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(409)
|
||||
ex.exception.response["Error"]["Message"].should.contain("TestCreatePolicy")
|
||||
|
||||
|
||||
@mock_iam
|
||||
def test_delete_policy():
|
||||
conn = boto3.client("iam", region_name="us-east-1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue