Merge "Properly handle policy values containing spaces"

This commit is contained in:
Jenkins
2015-02-19 17:16:52 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ define openstacklib::policy::base (
augeas { "${file_path}-${key}-${value}" : augeas { "${file_path}-${key}-${value}" :
lens => 'Json.lns', lens => 'Json.lns',
incl => $file_path, incl => $file_path,
changes => "set dict/entry[*][.=\"${key}\"]/string ${value}", changes => "set dict/entry[*][.=\"${key}\"]/string \"${value}\"",
require => Augeas["${file_path}-${key}-${value}-add"] require => Augeas["${file_path}-${key}-${value}-add"]
} }

View File

@@ -8,28 +8,28 @@ describe 'openstacklib::policy::base' do
let :params do let :params do
{:file_path => '/etc/nova/policy.json', {:file_path => '/etc/nova/policy.json',
:key => 'context_is_admin', :key => 'context_is_admin or owner',
:value => 'foo:bar'} :value => 'foo:bar'}
end end
it 'configures the proper policy' do it 'configures (modifies) the proper policy' do
should contain_augeas('/etc/nova/policy.json-context_is_admin-foo:bar').with( should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar').with(
'lens' => 'Json.lns', 'lens' => 'Json.lns',
'incl' => '/etc/nova/policy.json', 'incl' => '/etc/nova/policy.json',
'changes' => 'set dict/entry[*][.="context_is_admin"]/string foo:bar', 'changes' => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"',
'require' => 'Augeas[/etc/nova/policy.json-context_is_admin-foo:bar-add]' 'require' => 'Augeas[/etc/nova/policy.json-context_is_admin or owner-foo:bar-add]'
) )
end end
it 'configures the proper policy' do it 'configures (adds) the proper policy' do
should contain_augeas('/etc/nova/policy.json-context_is_admin-foo:bar-add').with( should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar-add').with(
'lens' => 'Json.lns', 'lens' => 'Json.lns',
'incl' => '/etc/nova/policy.json', 'incl' => '/etc/nova/policy.json',
'changes' => [ 'changes' => [
'set dict/entry[last()+1] "context_is_admin"', 'set dict/entry[last()+1] "context_is_admin or owner"',
'set dict/entry[last()]/string "foo:bar"' 'set dict/entry[last()]/string "foo:bar"'
], ],
'onlyif' => 'match dict/entry[*][.="context_is_admin"] size == 0' 'onlyif' => 'match dict/entry[*][.="context_is_admin or owner"] size == 0'
) )
end end