mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix encoding issue: https://github.com/fog/fog/pull/189
This commit is contained in:
parent
30a1a8f190
commit
cfdd1d34e3
2 changed files with 20 additions and 8 deletions
|
@ -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
|
||||||
|
|
|
@ -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('a valid policy').succeeds do
|
||||||
|
policy = @user.policies.create(id: @policy_name, document: @policy_document)
|
||||||
|
policy.id == @policy_name
|
||||||
|
policy.username == @username
|
||||||
|
policy.document == @policy_document
|
||||||
|
end
|
||||||
|
|
||||||
tests('#create','a policy').succeeds do
|
# The mocking doesn't validate the document policy
|
||||||
policy = @user.policies.create(id: @policy_name, document: @policy_document)
|
#tests('an invalid valid policy').succeeds do
|
||||||
policy.id == @policy_name
|
# raises(Fog::AWS::IAM::Error) { @user.policies.create(id: 'non-valid-document', document: 'invalid json blob') }
|
||||||
policy.username == @username
|
#end
|
||||||
#policy.document == @policy_document # FIXME, the format isn't right
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue