1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|iam] FIX - make arguments AWS::IAM.get_user conform to expected standard for this module

This commit is contained in:
Benton Roberts 2012-06-13 10:12:57 -04:00
parent 907f294e8f
commit cdd8c20812
2 changed files with 10 additions and 8 deletions

View file

@ -8,6 +8,7 @@ module Fog
# Get User # Get User
# #
# ==== Parameters # ==== Parameters
# * username<String>
# * options<~Hash>: # * options<~Hash>:
# * 'UserName'<~String>: Name of the User. Defaults to current user # * 'UserName'<~String>: Name of the User. Defaults to current user
# #
@ -23,19 +24,21 @@ module Fog
# ==== See Also # ==== See Also
# http://docs.amazonwebservices.com/IAM/latest/APIReference/API_Getuser.html # http://docs.amazonwebservices.com/IAM/latest/APIReference/API_Getuser.html
# #
def get_user(options = {}) def get_user(username, options = {})
request({ request({
'Action' => 'GetUser', 'Action' => 'GetUser',
:parser => Fog::Parsers::AWS::IAM::GetUser.new 'UserName' => username,
:parser => Fog::Parsers::AWS::IAM::GetUser.new
}.merge!(options)) }.merge!(options))
end end
end end
class Mock class Mock
def get_user(options = {}) def get_user(user, options = {})
user = options['UserName'] raise Fog::AWS::IAM::NotFound.new(
raise Fog::AWS::IAM::NotFound.new("The user with name #{user} cannot be found.") unless self.data[:users].key?(user) "The user with name #{user} cannot be found."
) unless self.data[:users].key?(user)
Excon::Response.new.tap do |response| Excon::Response.new.tap do |response|
response.body = {'User' => { response.body = {'User' => {
'UserId' => data[:users][user][:user_id], 'UserId' => data[:users][user][:user_id],
@ -43,7 +46,6 @@ module Fog
'UserName' => user, 'UserName' => user,
'Arn' => (data[:users][user][:arn]).strip 'Arn' => (data[:users][user][:arn]).strip
}, },
'IsTruncated' => false,
'RequestId' => Fog::AWS::Mock.request_id } 'RequestId' => Fog::AWS::Mock.request_id }
response.status = 200 response.status = 200
end end

View file

@ -34,7 +34,7 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do
end end
tests("#get_user").formats(@user_format) do tests("#get_user").formats(@user_format) do
Fog::AWS[:iam].get_user('UserName' => 'fog_user').body Fog::AWS[:iam].get_user('fog_user').body
end end
tests("#add_user_to_group('fog_user_tests', 'fog_user')").formats(AWS::IAM::Formats::BASIC) do tests("#add_user_to_group('fog_user_tests', 'fog_user')").formats(AWS::IAM::Formats::BASIC) do