
With the move of existing policy.json files into code, the file may no longer be shipped by packaging. The json augeas lens requires that the file exist or it fails. This change adds a file resource to ensure the file exists with a basic json construct prior to managing the contents with augeas. Change-Id: I26e8b1384f4f69712da9d06a4c565dfd1f17c9ed Related-Bug: #1742154
66 lines
1.8 KiB
Ruby
66 lines
1.8 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe 'openstacklib::policy::base' do
|
|
|
|
|
|
shared_examples_for 'openstacklib::policy::base' do
|
|
context 'with some basic parameters' do
|
|
let :title do
|
|
'nova-contest_is_admin'
|
|
end
|
|
|
|
let :params do
|
|
{
|
|
:file_path => '/etc/nova/policy.json',
|
|
:key => 'context_is_admin or owner',
|
|
:value => 'foo:bar',
|
|
:file_mode => '0644',
|
|
:file_user => 'foo',
|
|
:file_group => 'bar'
|
|
}
|
|
end
|
|
|
|
it {
|
|
is_expected.to contain_file('/etc/nova/policy.json').with(
|
|
:mode => '0644',
|
|
:owner => 'foo',
|
|
:group => 'bar')
|
|
}
|
|
|
|
it 'configures (modifies) the proper policy' do
|
|
is_expected.to contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar').with(
|
|
'lens' => 'Json.lns',
|
|
'incl' => '/etc/nova/policy.json',
|
|
'changes' => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"',
|
|
)
|
|
end
|
|
|
|
it 'configures (adds) the proper policy' do
|
|
is_expected.to contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar-add').with(
|
|
'lens' => 'Json.lns',
|
|
'incl' => '/etc/nova/policy.json',
|
|
'changes' => [
|
|
'set dict/entry[last()+1] "context_is_admin or owner"',
|
|
'set dict/entry[last()]/string "foo:bar"'
|
|
],
|
|
'onlyif' => 'match dict/entry[*][.="context_is_admin or owner"] size == 0'
|
|
)
|
|
end
|
|
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_configures 'openstacklib::policy::base'
|
|
end
|
|
end
|
|
|
|
end
|
|
|