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

Add mocks for GetFederationToken and enable use

This commit is contained in:
gregburek 2013-09-04 18:05:54 -07:00
parent b6f5165a5b
commit 05dcff185f
2 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -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