Merge "Introduce scope_types in list migrations"

This commit is contained in:
Zuul 2020-04-02 23:08:18 +00:00 committed by Gerrit Code Review
commit 394ef32790
2 changed files with 18 additions and 5 deletions

View File

@ -23,15 +23,16 @@ POLICY_ROOT = 'os_compute_api:os-migrations:%s'
migrations_policies = [
policy.DocumentedRuleDefault(
POLICY_ROOT % 'index',
base.RULE_ADMIN_API,
"List migrations",
[
name=POLICY_ROOT % 'index',
check_str=base.RULE_ADMIN_API,
description="List migrations",
operations=[
{
'method': 'GET',
'path': '/os-migrations'
}
]),
],
scope_types=['system']),
]

View File

@ -68,3 +68,15 @@ class MigrationsScopeTypePolicyTest(MigrationsPolicyTest):
def setUp(self):
super(MigrationsScopeTypePolicyTest, self).setUp()
self.flags(enforce_scope=True, group="oslo_policy")
# Check that system admin is able to list migrations.
self.admin_authorized_contexts = [
self.system_admin_context]
# Check that non system admin is not able to list migrations.
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
]