Add support for the oslo_policy/enforce_scope parameter

Depends-on: https://review.opendev.org/#/c/759008/
Change-Id: Ibdebe7a447dedbcf16ab9a27a0cc7ac38df4f4c4
This commit is contained in:
Takashi Kajinami 2021-03-16 18:46:26 +09:00
parent b7ea086fdd
commit 58ccef2a9c
3 changed files with 25 additions and 10 deletions

View File

@ -4,6 +4,10 @@
#
# === Parameters
#
# [*enforce_scope*]
# (Optional) Whether or not to enforce scope when evaluating policies.
# Defaults to $::os_service_default.
#
# [*policies*]
# (Optional) Set of policies to configure for zaqar
# Example :
@ -24,6 +28,7 @@
# Defaults to /etc/zaqar/policy.yaml
#
class zaqar::policy (
$enforce_scope = $::os_service_default,
$policies = {},
$policy_path = '/etc/zaqar/policy.yaml',
) {
@ -42,5 +47,9 @@ class zaqar::policy (
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'zaqar_config': policy_file => $policy_path }
oslo::policy { 'zaqar_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
}

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``zaqar::policy::enforce_scope`` parameter has been added to
support the corresponding parameter in oslo.policy library.

View File

@ -1,10 +1,10 @@
require 'spec_helper'
describe 'zaqar::policy' do
shared_examples_for 'zaqar policies' do
shared_examples 'zaqar::policy' do
let :params do
{
:enforce_scope => false,
:policy_path => '/etc/zaqar/policy.yaml',
:policies => {
'context_is_admin' => {
@ -24,6 +24,7 @@ describe 'zaqar::policy' do
:file_format => 'yaml',
})
is_expected.to contain_oslo__policy('zaqar_config').with(
:enforce_scope => false,
:policy_file => '/etc/zaqar/policy.yaml',
)
end
@ -37,7 +38,7 @@ describe 'zaqar::policy' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'zaqar policies'
it_behaves_like 'zaqar::policy'
end
end
end