diff --git a/lib/fog/aws/models/iam/role.rb b/lib/fog/aws/models/iam/role.rb index 458613e49..9efb2c135 100644 --- a/lib/fog/aws/models/iam/role.rb +++ b/lib/fog/aws/models/iam/role.rb @@ -17,7 +17,7 @@ module Fog requires :rolename requires :assume_role_policy_document - data = service.create_role(rolename, assume_role_policy_document).body["Role"] + data = service.create_role(rolename, assume_role_policy_document, path).body["Role"] merge_attributes(data) true end diff --git a/lib/fog/aws/models/iam/roles.rb b/lib/fog/aws/models/iam/roles.rb index db7c6e169..c3f567746 100644 --- a/lib/fog/aws/models/iam/roles.rb +++ b/lib/fog/aws/models/iam/roles.rb @@ -20,7 +20,7 @@ module Fog role = nil begin role = service.roles.new( service.get_role( identity ).data[:body]["Role"] ) - rescue Excon::Errors::NotFound # ignore not found error + rescue Excon::Errors::NotFound, Fog::AWS::IAM::NotFound # ignore not found error end role end diff --git a/tests/aws/models/iam/access_keys_tests.rb b/tests/aws/models/iam/access_keys_tests.rb index 35fca76cf..e21757d15 100644 --- a/tests/aws/models/iam/access_keys_tests.rb +++ b/tests/aws/models/iam/access_keys_tests.rb @@ -1,6 +1,5 @@ Shindo.tests("Fog::Compute[:iam] | access_keys", ['aws','iam']) do - Fog.mock! iam = Fog::AWS[:iam] @username = 'fake_user' @@ -48,6 +47,7 @@ Shindo.tests("Fog::Compute[:iam] | access_keys", ['aws','iam']) do end # clean up + @user.access_keys.map(&:destroy) @user.destroy end diff --git a/tests/aws/models/iam/policies_tests.rb b/tests/aws/models/iam/policies_tests.rb index a50eeda36..33b4ff1b0 100644 --- a/tests/aws/models/iam/policies_tests.rb +++ b/tests/aws/models/iam/policies_tests.rb @@ -1,6 +1,5 @@ Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do - Fog.mock! iam = Fog::AWS[:iam] @username = 'fake_user' @@ -50,6 +49,8 @@ Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do end # clean up + @user.access_keys.map(&:destroy) + @user.policies.map(&:destroy) @user.destroy diff --git a/tests/aws/models/iam/users_tests.rb b/tests/aws/models/iam/users_tests.rb index ea937c67d..f44fb515a 100644 --- a/tests/aws/models/iam/users_tests.rb +++ b/tests/aws/models/iam/users_tests.rb @@ -1,6 +1,5 @@ Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do - Fog.mock! @iam = Fog::AWS[:iam] @user_one_name = 'fake_user_one' @user_two_name = 'fake_user_two' @@ -9,17 +8,21 @@ Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do @user_three_path = '/path/to/fake_user_three/' @user_four_name = 'fake_user_four' + def all_users + @iam.users.all.select{|user| user.id =~ /^fake_user/ } + end + tests('#create').succeeds do @user_one = @iam.users.create(:id => @user_one_name) @user_one.id == @user_one_name end tests('#all','there is only one user').succeeds do - @iam.users.size == 1 + all_users.size == 1 end tests('#all','the only user should match').succeeds do - @iam.users.first.id == @user_one_name + all_users.first.id == @user_one_name end tests('#create','a second user').succeeds do @@ -28,7 +31,7 @@ Shindo.tests("Fog::Compute[:iam] | users", ['aws','iam']) do end tests('#all','there are two users').succeeds do - @iam.users.size == 2 + all_users.size == 2 end tests('#get','an existing user').succeeds do