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)
|
||||
case name
|
||||
when 'UserName', 'PolicyName', 'PolicyDocument'
|
||||
when 'UserName', 'PolicyName'
|
||||
@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'
|
||||
@response[name] = value
|
||||
end
|
||||
|
|
|
@ -12,12 +12,18 @@ Shindo.tests("Fog::Compute[:iam] | policies", ['aws','iam']) do
|
|||
@user.policies.empty?
|
||||
end
|
||||
|
||||
|
||||
tests('#create','a policy').succeeds do
|
||||
policy = @user.policies.create(id: @policy_name, document: @policy_document)
|
||||
policy.id == @policy_name
|
||||
policy.username == @username
|
||||
#policy.document == @policy_document # FIXME, the format isn't right
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
@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.id == @polic_name
|
||||
policy.username == @username
|
||||
#policy.document == @policy_document # FIXME, the format isn't right
|
||||
policy.document == @policy_document
|
||||
end
|
||||
|
||||
tests('an invalid policy').succeeds do
|
||||
|
|
Loading…
Reference in a new issue