1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
This commit is contained in:
Rodrigo Estebanez 2012-06-05 17:46:41 +02:00
parent 30a1a8f190
commit cfdd1d34e3
2 changed files with 20 additions and 8 deletions

View file

@ -12,8 +12,14 @@ module Fog
def end_element(name) def end_element(name)
case name case name
when 'UserName', 'PolicyName', 'PolicyDocument' when 'UserName', 'PolicyName'
@response[name] = value @response[name] = value
when 'PolicyDocument'
@response[name] = if decoded_string = URI.decode(value)
Fog::JSON.decode(decoded_string) rescue value
else
value
end
when 'RequestId' when 'RequestId'
@response[name] = value @response[name] = value
end end

View file

@ -12,12 +12,18 @@ Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do
@user.policies.empty? @user.policies.empty?
end end
tests('#create') do
tests('#create','a policy').succeeds do tests('a valid policy').succeeds do
policy = @user.policies.create(id: @policy_name, document: @policy_document) policy = @user.policies.create(id: @policy_name, document: @policy_document)
policy.id == @policy_name policy.id == @policy_name
policy.username == @username policy.username == @username
#policy.document == @policy_document # FIXME, the format isn't right policy.document == @policy_document
end
# The mocking doesn't validate the document policy
#tests('an invalid valid policy').succeeds do
# raises(Fog::AWS::IAM::Error) { @user.policies.create(id: 'non-valid-document', document: 'invalid json blob') }
#end
end end
@user.policies.create(id: 'another-policy', document: {}) @user.policies.create(id: 'another-policy', document: {})
@ -31,7 +37,7 @@ Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do
policy = @user.policies.get(@policy_name) policy = @user.policies.get(@policy_name)
policy.id == @polic_name policy.id == @polic_name
policy.username == @username policy.username == @username
#policy.document == @policy_document # FIXME, the format isn't right policy.document == @policy_document
end end
tests('an invalid policy').succeeds do tests('an invalid policy').succeeds do