IAM: get_role should thrown when role is unexisting
This commit is contained in:
parent
20306c9b24
commit
db7d7a9330
@ -249,6 +249,7 @@ class IAMBackend(BaseBackend):
|
|||||||
for role in self.get_roles():
|
for role in self.get_roles():
|
||||||
if role.name == role_name:
|
if role.name == role_name:
|
||||||
return role
|
return role
|
||||||
|
raise BotoServerError(404, 'Not Found')
|
||||||
|
|
||||||
def get_roles(self):
|
def get_roles(self):
|
||||||
return self.roles.values()
|
return self.roles.values()
|
||||||
|
@ -6,6 +6,7 @@ from nose.tools import assert_raises, assert_equals, assert_not_equals
|
|||||||
from boto.exception import BotoServerError
|
from boto.exception import BotoServerError
|
||||||
import base64
|
import base64
|
||||||
from moto import mock_iam
|
from moto import mock_iam
|
||||||
|
from nose.tools import raises
|
||||||
|
|
||||||
|
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
@ -39,6 +40,12 @@ def test_upload_server_cert():
|
|||||||
cert.server_certificate_name.should.equal("certname")
|
cert.server_certificate_name.should.equal("certname")
|
||||||
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
|
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
|
||||||
|
|
||||||
|
@mock_iam()
|
||||||
|
@raises(BotoServerError)
|
||||||
|
def test_get_role__should_throw__when_role_does_not_exist():
|
||||||
|
conn = boto.connect_iam()
|
||||||
|
|
||||||
|
conn.get_role('unexisting_role')
|
||||||
|
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
def test_create_role_and_instance_profile():
|
def test_create_role_and_instance_profile():
|
||||||
|
Loading…
Reference in New Issue
Block a user