Add new default roles in server diagnostics policies

This adds new defaults roles in server diagnostics API policies.
This policy is default to SYSTEM_ADMIN role.

Also add tests to simulates the future where we drop the deprecation
fall back in the policy by overriding the rules with a version where
there are no deprecated rule options. Operators can do the same by
adding overrides in their policy files that match the default but
stop the rule deprecation fallback from happening.

Partial implement blueprint policy-defaults-refresh

Change-Id: Ibecf2ea61d75ec574123094a1783f9d664000d98
This commit is contained in:
Ghanshyam Mann
2020-04-01 20:07:32 -05:00
parent c26fc5da04
commit f69951fd25
2 changed files with 24 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ BASE_POLICY_NAME = 'os_compute_api:os-server-diagnostics'
server_diagnostics_policies = [
policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME,
check_str=base.RULE_ADMIN_API,
check_str=base.SYSTEM_ADMIN,
description="Show the usage data for a server",
operations=[
{

View File

@@ -80,3 +80,26 @@ class ServerDiagnosticsScopeTypePolicyTest(ServerDiagnosticsPolicyTest):
def setUp(self):
super(ServerDiagnosticsScopeTypePolicyTest, self).setUp()
self.flags(enforce_scope=True, group="oslo_policy")
class ServerDiagnosticsNoLegacyPolicyTest(
ServerDiagnosticsScopeTypePolicyTest):
"""Test Server Diagnostics APIs policies with system scope enabled,
and no more deprecated rules.
"""
without_deprecated_rules = True
def setUp(self):
super(ServerDiagnosticsNoLegacyPolicyTest, self).setUp()
# Check that system admin is able to get server diagnostics.
self.admin_authorized_contexts = [
self.system_admin_context
]
# Check that non system admin is not able to get server diagnostics.
self.admin_unauthorized_contexts = [
self.legacy_admin_context, self.project_admin_context,
self.system_member_context, self.system_reader_context,
self.system_foo_context, self.project_member_context,
self.project_reader_context, self.project_foo_context,
self.other_project_member_context
]