mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Incorrectly used policy_name rather than arn
Correct request name to delete_policy_version Correct policy list version parser Correct update assume role policy
This commit is contained in:
parent
9afc985ba5
commit
9c1cdb90c1
5 changed files with 43 additions and 7 deletions
|
|
@ -5,8 +5,20 @@ module Fog
|
|||
class ListPolicyVersions < Fog::Parsers::Base
|
||||
def reset
|
||||
super
|
||||
@version = {}
|
||||
@response = { 'Versions' => [] }
|
||||
@stack = []
|
||||
@response = { 'Versions' => [], 'Marker' => '', 'IsTruncated' => false }
|
||||
end
|
||||
|
||||
def start_element(name,attrs = [])
|
||||
case name
|
||||
when 'Versions'
|
||||
@stack << name
|
||||
when 'member'
|
||||
if @stack.last == 'Versions'
|
||||
@version = {}
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
|
|
@ -21,6 +33,30 @@ module Fog
|
|||
end
|
||||
super
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'VersionId'
|
||||
@version[name] = value
|
||||
when 'CreateDate'
|
||||
@version[name] = Time.parse(value)
|
||||
when 'IsDefaultVersion'
|
||||
@version[name] = (value == 'true')
|
||||
when 'Versions'
|
||||
if @stack.last == 'Versions'
|
||||
@stack.pop
|
||||
end
|
||||
when 'member'
|
||||
if @stack.last == 'Versions'
|
||||
finished_version(@version)
|
||||
@version = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def finished_version(version)
|
||||
@response['Versions'] << version
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module Fog
|
|||
def create_policy_version(policy_arn, policy_document, set_as_default=true)
|
||||
request({
|
||||
'Action' => 'CreatePolicyVersion',
|
||||
'PolicyArn' => policy_name,
|
||||
'PolicyArn' => policy_arn,
|
||||
'PolicyDocument' => Fog::JSON.encode(policy_document),
|
||||
'SetAsDefault' => set_as_default,
|
||||
:parser => Fog::Parsers::AWS::IAM::PolicyVersion.new
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module Fog
|
|||
# ==== See Also
|
||||
# http://docs.aws.amazon.com/IAM/latest/APIReference/API_DeletePolicyVersion.html
|
||||
#
|
||||
def delete_policy(policy_arn, version_id)
|
||||
def delete_policy_version(policy_arn, version_id)
|
||||
request(
|
||||
'Action' => 'DeletePolicyVersion',
|
||||
'PolicyArn' => policy_arn,
|
||||
|
|
@ -28,7 +28,7 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
def delete_policy(policy_arn, version_id)
|
||||
def delete_policy_version(policy_arn, version_id)
|
||||
Excon::Response.new.tap do |response|
|
||||
response.body = { 'RequestId' => Fog::AWS::Mock.request_id }
|
||||
response.status = 200
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ module Fog
|
|||
request({
|
||||
'Action' => 'UpdateAssumeRolePolicy',
|
||||
'PolicyDocument' => Fog::JSON.encode(policy_document),
|
||||
'RoleName' => policy_name,
|
||||
'RoleName' => role_name,
|
||||
:parser => Fog::Parsers::AWS::IAM::Basic.new
|
||||
}.reject {|_, value| value.nil?})
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Shindo.tests('AWS::IAM | versioned managed policy requests', ['aws']) do
|
|||
|
||||
tests('success') do
|
||||
@policy = {'Version' => '2012-10-17', "Statement" => [{"Effect" => "Deny", "Action" => "*", "Resource" => "*"}]}
|
||||
@policy_v2 = {'Version' => '2012-10-17', "Statement" => [{"Effect" => "Deny", "Action" => "*", "Resource" => "EC2:*"}]}
|
||||
@policy_v2 = {'Version' => '2012-10-17', "Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]}
|
||||
|
||||
@policy_format = {
|
||||
'Arn' => String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue