From bb0fca83c50eb51c44c9b67ef6c7a729da4e1cf3 Mon Sep 17 00:00:00 2001 From: Josh Lane Date: Wed, 20 May 2015 15:55:28 -0700 Subject: [PATCH] fix root iam arn * mock only change * root user arn doesn't have 'user/' key prefix --- lib/fog/aws/iam.rb | 5 +++++ tests/requests/iam/user_tests.rb | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/iam.rb b/lib/fog/aws/iam.rb index 96f2cc373..36c3b65e8 100644 --- a/lib/fog/aws/iam.rb +++ b/lib/fog/aws/iam.rb @@ -182,6 +182,11 @@ module Fog end def current_user + unless self.data[:users].key?("root") + root = self.data[:users]["root"] # sets the hash + root[:arn].gsub!("user/", "") # root user doesn't have "user/" key prefix + end + self.data[:users]["root"] end end diff --git a/tests/requests/iam/user_tests.rb b/tests/requests/iam/user_tests.rb index ff82cf845..e27b822d6 100644 --- a/tests/requests/iam/user_tests.rb +++ b/tests/requests/iam/user_tests.rb @@ -12,7 +12,6 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do Fog::AWS[:iam].create_group('fog_user_tests') - tests("#create_user('fog_user')").data_matches_schema(AWS::IAM::Formats::CREATE_USER) do Fog::AWS[:iam].create_user('fog_user').body end @@ -26,7 +25,15 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do end tests("#get_user").data_matches_schema(AWS::IAM::Formats::GET_CURRENT_USER) do - Fog::AWS[:iam].get_user.body + body = Fog::AWS[:iam].get_user.body + + if Fog.mocking? + tests("correct root arn").returns(true) { + body["User"]["Arn"].end_with?(":root") + } + end + + body end tests("#add_user_to_group('fog_user_tests', 'fog_user')").data_matches_schema(AWS::IAM::Formats::BASIC) do