Merge "Disallow duplicate policy rules with the same key"

This commit is contained in:
Zuul
2022-08-01 09:04:11 +00:00
committed by Gerrit Code Review
2 changed files with 6 additions and 6 deletions

View File

@@ -61,7 +61,7 @@ define openstacklib::policy::base (
warning('Json format is deprecated and will be removed in a future release') warning('Json format is deprecated and will be removed in a future release')
# Add entry if it doesn't exists # Add entry if it doesn't exists
augeas { "${file_path}-${key}-${value}-add": augeas { "${file_path}-${key}-add":
lens => 'Json.lns', lens => 'Json.lns',
incl => $file_path, incl => $file_path,
changes => [ changes => [
@@ -72,15 +72,15 @@ define openstacklib::policy::base (
} }
# Requires that the entry is added before this call or it will fail. # Requires that the entry is added before this call or it will fail.
augeas { "${file_path}-${key}-${value}" : augeas { "${file_path}-${key}" :
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}\"",
} }
Openstacklib::Policy::Default<| title == $file_path |> Openstacklib::Policy::Default<| title == $file_path |>
-> Augeas<| title == "${file_path}-${key}-${value}-add" |> -> Augeas<| title == "${file_path}-${key}-add" |>
~> Augeas<| title == "${file_path}-${key}-${value}" |> ~> Augeas<| title == "${file_path}-${key}" |>
} }
'yaml': { 'yaml': {
# NOTE(tkajianm): Currently we use single quotes('') to quote the whole # NOTE(tkajianm): Currently we use single quotes('') to quote the whole

View File

@@ -27,13 +27,13 @@ describe 'openstacklib::policy::base' do
:purge_config => false, :purge_config => false,
)} )}
it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar').with( it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner').with(
:lens => 'Json.lns', :lens => 'Json.lns',
:incl => '/etc/nova/policy.json', :incl => '/etc/nova/policy.json',
:changes => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"', :changes => 'set dict/entry[*][.="context_is_admin or owner"]/string "foo:bar"',
)} )}
it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-foo:bar-add').with( it { should contain_augeas('/etc/nova/policy.json-context_is_admin or owner-add').with(
:lens => 'Json.lns', :lens => 'Json.lns',
:incl => '/etc/nova/policy.json', :incl => '/etc/nova/policy.json',
:changes => [ :changes => [