mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
mock #put_user_policy
This commit is contained in:
parent
d353165a68
commit
b12e373ce3
2 changed files with 19 additions and 5 deletions
|
@ -31,6 +31,23 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
#FIXME: You can't actually use the credentials for anything elsewhere in Fog
|
||||
#FIXME: Doesn't do any validation on the policy
|
||||
def put_user_policy(user_name, policy_name, policy_document)
|
||||
if data[:users].keys.include? user_name
|
||||
response = Excon::Response.new
|
||||
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }
|
||||
response.status = 200
|
||||
data[:users][user_name][:policies][policy_name] = policy_document
|
||||
response
|
||||
else
|
||||
raise Fog::AWS::IAM::NotFound.new("The user with name #{user_name} cannot be found.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
Shindo.tests('AWS::IAM | user policy requests', ['aws']) do
|
||||
|
||||
unless Fog.mocking?
|
||||
Fog::AWS[:iam].create_user('fog_user_policy_tests')
|
||||
end
|
||||
Fog::AWS[:iam].create_user('fog_user_policy_tests')
|
||||
|
||||
tests('success') do
|
||||
|
||||
@policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]}
|
||||
|
||||
tests("#put_user_policy('fog_user_policy_tests', 'fog_policy', #{@policy.inspect})").formats(AWS::IAM::Formats::BASIC) do
|
||||
pending if Fog.mocking?
|
||||
Fog::AWS[:iam].put_user_policy('fog_user_policy_tests', 'fog_policy', @policy).body
|
||||
end
|
||||
|
||||
|
@ -39,4 +36,4 @@ Shindo.tests('AWS::IAM | user policy requests', ['aws']) do
|
|||
Fog::AWS[:iam].delete_user('fog_user_policy_tests')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue