Files
puppet-openstacklib/spec/defines/openstacklib_policy_spec.rb
Mike Dorman f8c3ed0fc9 Properly handle policy values containing spaces
Add quotes around the ${value} for the augeas resources, which
will properly handle values that contain spaces.  Otherwise,
the value gets truncated at the first space.

Change-Id: I24ee5312a0e492e264b38756649654b9d5930f4c
Closes-bug: 1416523
2015-02-18 10:26:59 -07:00

38 lines
1.1 KiB
Ruby

require 'spec_helper'
describe 'openstacklib::policy::base' 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'}
end
it 'configures (modifies) the proper policy' do
should 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"',
'require' => 'Augeas[/etc/nova/policy.json-context_is_admin or owner-foo:bar-add]'
)
end
it 'configures (adds) the proper policy' do
should 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