diff --git a/lib/fog/aws/iam.rb b/lib/fog/aws/iam.rb index 8cbe558d7..a75466efd 100644 --- a/lib/fog/aws/iam.rb +++ b/lib/fog/aws/iam.rb @@ -92,6 +92,7 @@ module Fog :path => '/', :arn => "arn:aws:iam::#{Fog::AWS::Mock.owner_id}:user/#{ukey}", :access_keys => [], + :created_at => Time.now, :policies => {} } end, diff --git a/lib/fog/aws/models/iam/user.rb b/lib/fog/aws/models/iam/user.rb index 8b8dbfa55..3a2011f01 100644 --- a/lib/fog/aws/models/iam/user.rb +++ b/lib/fog/aws/models/iam/user.rb @@ -10,6 +10,7 @@ module Fog attribute :path, :aliases => 'Path' attribute :arn, :aliases => 'Arn' attribute :user_id, :aliases => 'UserId' + attribute :created_at, :aliases => 'CreateDate', :type => :time def save requires :id diff --git a/lib/fog/aws/parsers/iam/get_user.rb b/lib/fog/aws/parsers/iam/get_user.rb index 0c3f02936..1ab68e3be 100644 --- a/lib/fog/aws/parsers/iam/get_user.rb +++ b/lib/fog/aws/parsers/iam/get_user.rb @@ -14,6 +14,8 @@ module Fog case name when 'Arn', 'UserId', 'UserName', 'Path' @response['User'][name] = value + when 'CreateDate' + @response['User'][name] = Time.parse(value) when 'RequestId' @response[name] = value end diff --git a/lib/fog/aws/parsers/iam/list_users.rb b/lib/fog/aws/parsers/iam/list_users.rb index d0d9e0bf4..dc69e60ab 100644 --- a/lib/fog/aws/parsers/iam/list_users.rb +++ b/lib/fog/aws/parsers/iam/list_users.rb @@ -14,6 +14,8 @@ module Fog case name when 'Arn', 'UserId', 'UserName', 'Path' @user[name] = value + when 'CreateDate' + @user[name] = Time.parse(value) when 'member' @response['Users'] << @user @user = {} diff --git a/lib/fog/aws/requests/iam/create_user.rb b/lib/fog/aws/requests/iam/create_user.rb index b063d7e33..ecf398ae2 100644 --- a/lib/fog/aws/requests/iam/create_user.rb +++ b/lib/fog/aws/requests/iam/create_user.rb @@ -44,10 +44,11 @@ module Fog Excon::Response.new.tap do |response| response.status = 200 response.body = { 'User' => { - "UserId" => data[:users][user_name][:user_id], - "Path" => path, - "UserName" => user_name, - "Arn" => (data[:users][user_name][:arn]).strip + "UserId" => data[:users][user_name][:user_id], + "Path" => path, + "UserName" => user_name, + "Arn" => (data[:users][user_name][:arn]).strip, + "CreateDate" => data[:users][user_name][:created_at] }, 'RequestId' => Fog::AWS::Mock.request_id } diff --git a/lib/fog/aws/requests/iam/get_user.rb b/lib/fog/aws/requests/iam/get_user.rb index e69552a8f..9e7746932 100644 --- a/lib/fog/aws/requests/iam/get_user.rb +++ b/lib/fog/aws/requests/iam/get_user.rb @@ -41,10 +41,11 @@ module Fog ) unless self.data[:users].key?(user) Excon::Response.new.tap do |response| response.body = {'User' => { - 'UserId' => data[:users][user][:user_id], - 'Path' => data[:users][user][:path], - 'UserName' => user, - 'Arn' => (data[:users][user][:arn]).strip + 'UserId' => data[:users][user][:user_id], + 'Path' => data[:users][user][:path], + 'UserName' => user, + 'Arn' => (data[:users][user][:arn]).strip, + 'CreateDate' => data[:users][user][:created_at] }, 'RequestId' => Fog::AWS::Mock.request_id } response.status = 200 diff --git a/lib/fog/aws/requests/iam/list_users.rb b/lib/fog/aws/requests/iam/list_users.rb index 870adbaf3..2a6ed3c40 100644 --- a/lib/fog/aws/requests/iam/list_users.rb +++ b/lib/fog/aws/requests/iam/list_users.rb @@ -43,10 +43,11 @@ module Fog #FIXME: none of the options are currently supported Excon::Response.new.tap do |response| response.body = {'Users' => data[:users].map do |user, data| - { 'UserId' => data[:user_id], - 'Path' => data[:path], - 'UserName' => user, - 'Arn' => (data[:arn]).strip } + { 'UserId' => data[:user_id], + 'Path' => data[:path], + 'UserName' => user, + 'Arn' => (data[:arn]).strip, + 'CreateDate' => data[:created_at]} end, 'IsTruncated' => false, 'RequestId' => Fog::AWS::Mock.request_id } diff --git a/tests/aws/requests/iam/user_tests.rb b/tests/aws/requests/iam/user_tests.rb index 4f99f914f..c46dcc1df 100644 --- a/tests/aws/requests/iam/user_tests.rb +++ b/tests/aws/requests/iam/user_tests.rb @@ -6,10 +6,11 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do @user_format = { 'User' => { - 'Arn' => String, - 'Path' => String, - 'UserId' => String, - 'UserName' => String + 'Arn' => String, + 'Path' => String, + 'UserId' => String, + 'UserName' => String, + 'CreateDate' => Time }, 'RequestId' => String } @@ -20,10 +21,11 @@ Shindo.tests('AWS::IAM | user requests', ['aws']) do @users_format = { 'Users' => [{ - 'Arn' => String, - 'Path' => String, - 'UserId' => String, - 'UserName' => String + 'Arn' => String, + 'Path' => String, + 'UserId' => String, + 'UserName' => String, + 'CreateDate' => Time }], 'IsTruncated' => Fog::Boolean, 'RequestId' => String