From 05dcff185f67efa73fb86a35e89ea7b5a8a60f76 Mon Sep 17 00:00:00 2001 From: gregburek Date: Wed, 4 Sep 2013 18:05:54 -0700 Subject: [PATCH] Add mocks for GetFederationToken and enable use --- .../aws/requests/sts/get_federation_token.rb | 17 +++++++++++++++++ .../requests/sts/get_federation_token_tests.rb | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/fog/aws/requests/sts/get_federation_token.rb b/lib/fog/aws/requests/sts/get_federation_token.rb index 05d1a6748..2a8ce0e3f 100644 --- a/lib/fog/aws/requests/sts/get_federation_token.rb +++ b/lib/fog/aws/requests/sts/get_federation_token.rb @@ -41,6 +41,23 @@ module Fog }) end end + class Mock + def get_federation_token(name, policy, duration=43200) + Excon::Response.new.tap do |response| + response.status = 200 + response.body = { + 'SessionToken' => Fog::Mock.random_base64(580), + 'SecretAccessKey' => Fog::Mock.random_base64(40), + 'Expiration' => (DateTime.now + duration).strftime('%FT%TZ'), + 'AccessKeyId' => Fog::AWS::Mock.key_id(20), + 'Arn' => "arn:aws:sts::#{Fog::AWS::Mock.owner_id}:federated-user/#{name}", + 'FederatedUserId' => "#{Fog::AWS::Mock.owner_id}:#{name}", + 'PackedPolicySize' => Fog::Mock.random_numbers(2), + 'RequestId' => Fog::AWS::Mock.request_id + } + end + end + end end end end diff --git a/tests/aws/requests/sts/get_federation_token_tests.rb b/tests/aws/requests/sts/get_federation_token_tests.rb index 758f2ab9e..469569aa3 100644 --- a/tests/aws/requests/sts/get_federation_token_tests.rb +++ b/tests/aws/requests/sts/get_federation_token_tests.rb @@ -14,7 +14,6 @@ Shindo.tests('AWS::STS | session tokens', ['aws']) do } tests("#get_federation_token('test@fog.io', #{@policy.inspect})").formats(@federation_format) do - pending if Fog.mocking? Fog::AWS[:sts].get_federation_token("test@fog.io", @policy).body end