Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #246 from rapid7/issue-237
Browse files Browse the repository at this point in the history
Support setting Id on policy documents
  • Loading branch information
erran-r7 authored Mar 6, 2017
2 parents 2a2ae57 + 52380cf commit 348a160
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/convection/model/mixin/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def deny(sid = nil, &block)
end

def document
{
doc = {
'Version' => version,
'Statement' => statement.map(&:render)
}
doc['Id'] = id if id
doc
end

def render(parent = {})
Expand Down
17 changes: 17 additions & 0 deletions spec/convection/model/template/resource/policy_document_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

module Convection::Model::Mixin
describe Policy do
let(:template) { double(:template) }
subject { described_class.new(name: 'test-policy', template: template) }

it 'does not set Id on #document if absent' do
expect(subject.document['Id']).to be_nil
end

it 'sets Id on #document if provided' do
subject.id('MyDocumentId')
expect(subject.document['Id']).to eq('MyDocumentId')
end
end
end

0 comments on commit 348a160

Please sign in to comment.