
openstacklib::policy has never been used in any other modules because it was implemented as a class not reusable for each service. This change re-implements openstacklib::policy as a defined resource type so that we can use this implementation from each puppet modules. The openstacklib::policy resource type provides the purge_config parameter. When this parameter is set to true, a policy file is cleared during configuration process. This allows users to remove any existing rules before applying their own (no) rules. Change-Id: I9bb486c9191c50c11717dcb9c6af00d17c3aa8f5
88 lines
1.9 KiB
Ruby
88 lines
1.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe 'openstacklib::policy::default' do
|
|
shared_examples 'openstacklib::policy::default' do
|
|
context 'with policy.json' do
|
|
let :title do
|
|
'/etc/nova/policy.json'
|
|
end
|
|
|
|
let :params do
|
|
{
|
|
:file_mode => '0644',
|
|
:file_user => 'foo',
|
|
:file_group => 'bar',
|
|
:file_format => 'json',
|
|
}
|
|
end
|
|
|
|
it { should contain_file('/etc/nova/policy.json').with(
|
|
:mode => '0644',
|
|
:owner => 'foo',
|
|
:group => 'bar',
|
|
:content => '{}',
|
|
:replace => false
|
|
)}
|
|
end
|
|
|
|
context 'with policy.yaml' do
|
|
let :title do
|
|
'/etc/nova/policy.yaml'
|
|
end
|
|
|
|
let :params do
|
|
{
|
|
:file_mode => '0644',
|
|
:file_user => 'foo',
|
|
:file_group => 'bar',
|
|
:file_format => 'yaml',
|
|
}
|
|
end
|
|
|
|
it { should contain_file('/etc/nova/policy.yaml').with(
|
|
:mode => '0644',
|
|
:owner => 'foo',
|
|
:group => 'bar',
|
|
:content => '',
|
|
:replace => false
|
|
)}
|
|
end
|
|
|
|
context 'with purge_config enabled' do
|
|
let :title do
|
|
'/etc/nova/policy.yaml'
|
|
end
|
|
|
|
let :params do
|
|
{
|
|
:file_mode => '0644',
|
|
:file_user => 'foo',
|
|
:file_group => 'bar',
|
|
:file_format => 'yaml',
|
|
:purge_config => true,
|
|
}
|
|
end
|
|
|
|
it { should contain_file('/etc/nova/policy.yaml').with(
|
|
:mode => '0644',
|
|
:owner => 'foo',
|
|
:group => 'bar',
|
|
:content => '',
|
|
:replace => true
|
|
)}
|
|
end
|
|
end
|
|
|
|
on_supported_os({
|
|
:supported_os => OSDefaults.get_supported_os
|
|
}).each do |os,facts|
|
|
context "on #{os}" do
|
|
let (:facts) do
|
|
facts.merge!(OSDefaults.get_facts())
|
|
end
|
|
|
|
it_behaves_like 'openstacklib::policy::default'
|
|
end
|
|
end
|
|
end
|