Merge "Simplify policies definition"
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
# (required) Path to the policy.json file
|
# (required) Path to the policy.json file
|
||||||
#
|
#
|
||||||
# [*key*]
|
# [*key*]
|
||||||
# (required) The key to replace the value for
|
# (optional) The key to replace the value for
|
||||||
|
# Defaults to $name
|
||||||
#
|
#
|
||||||
# [*value*]
|
# [*value*]
|
||||||
# (optional) The value to set
|
# (optional) The value to set
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
#
|
#
|
||||||
define openstacklib::policy::base (
|
define openstacklib::policy::base (
|
||||||
Stdlib::Absolutepath $file_path,
|
Stdlib::Absolutepath $file_path,
|
||||||
String[1] $key,
|
String[1] $key = $name,
|
||||||
String $value = '',
|
String $value = '',
|
||||||
$file_mode = '0640',
|
$file_mode = '0640',
|
||||||
$file_user = undef,
|
$file_user = undef,
|
||||||
|
@@ -2,15 +2,14 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe 'openstacklib::policy::base' do
|
describe 'openstacklib::policy::base' do
|
||||||
shared_examples 'openstacklib::policy::base' do
|
shared_examples 'openstacklib::policy::base' do
|
||||||
context 'with policy.json' do
|
let :title do
|
||||||
let :title do
|
'context_is_admin or owner'
|
||||||
'nova-contest_is_admin'
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
context 'with policy.json' do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:file_path => '/etc/nova/policy.json',
|
:file_path => '/etc/nova/policy.json',
|
||||||
:key => 'context_is_admin or owner',
|
|
||||||
:value => 'foo:bar',
|
:value => 'foo:bar',
|
||||||
:file_mode => '0644',
|
:file_mode => '0644',
|
||||||
:file_user => 'foo',
|
:file_user => 'foo',
|
||||||
@@ -45,14 +44,9 @@ describe 'openstacklib::policy::base' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with policy.yaml' do
|
context 'with policy.yaml' do
|
||||||
let :title do
|
|
||||||
'nova-contest_is_admin'
|
|
||||||
end
|
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:file_path => '/etc/nova/policy.yaml',
|
:file_path => '/etc/nova/policy.yaml',
|
||||||
:key => 'context_is_admin or owner',
|
|
||||||
:value => 'foo:bar',
|
:value => 'foo:bar',
|
||||||
:file_mode => '0644',
|
:file_mode => '0644',
|
||||||
:file_user => 'foo',
|
:file_user => 'foo',
|
||||||
@@ -105,14 +99,9 @@ describe 'openstacklib::policy::base' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with purge_config enabled' do
|
context 'with purge_config enabled' do
|
||||||
let :title do
|
|
||||||
'nova-contest_is_admin'
|
|
||||||
end
|
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:file_path => '/etc/nova/policy.yaml',
|
:file_path => '/etc/nova/policy.yaml',
|
||||||
:key => 'context_is_admin or owner',
|
|
||||||
:value => 'foo:bar',
|
:value => 'foo:bar',
|
||||||
:file_mode => '0644',
|
:file_mode => '0644',
|
||||||
:file_user => 'foo',
|
:file_user => 'foo',
|
||||||
@@ -132,14 +121,9 @@ describe 'openstacklib::policy::base' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'with json file_path and yaml file format' do
|
context 'with json file_path and yaml file format' do
|
||||||
let :title do
|
|
||||||
'nova-contest_is_admin'
|
|
||||||
end
|
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:file_path => '/etc/nova/policy.json',
|
:file_path => '/etc/nova/policy.json',
|
||||||
:key => 'context_is_admin or owner',
|
|
||||||
:value => 'foo:bar',
|
:value => 'foo:bar',
|
||||||
:file_mode => '0644',
|
:file_mode => '0644',
|
||||||
:file_user => 'foo',
|
:file_user => 'foo',
|
||||||
@@ -150,6 +134,26 @@ describe 'openstacklib::policy::base' do
|
|||||||
|
|
||||||
it { should raise_error(Puppet::Error) }
|
it { should raise_error(Puppet::Error) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with key overridden' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:file_path => '/etc/nova/policy.yaml',
|
||||||
|
:key => 'context_is_admin',
|
||||||
|
:value => 'foo:bar',
|
||||||
|
:file_mode => '0644',
|
||||||
|
:file_user => 'foo',
|
||||||
|
:file_group => 'bar',
|
||||||
|
:file_format => 'yaml',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_file_line('/etc/nova/policy.yaml-context_is_admin').with(
|
||||||
|
:path => '/etc/nova/policy.yaml',
|
||||||
|
:line => '\'context_is_admin\': \'foo:bar\'',
|
||||||
|
:match => '^[\'"]?context_is_admin(?!:)[\'"]?\s*:.+'
|
||||||
|
) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
|
Reference in New Issue
Block a user