Introduce scope_types in os-create-backup

oslo.policy introduced the scope_type feature which can
control the access level at system-level and project-level.
 - https://docs.openstack.org/oslo.policy/latest/user/usage.html#setting-scope
 - http://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/system-scope.html

Appropriate scope_type for nova case:
- https://specs.openstack.org/openstack/nova-specs/specs/ussuri/approved/policy-defaults-refresh.html#scope

This commit introduce scope_type for os-create-backup API policies
as 'system' and 'project'.

Also adds the test case with scope_type enabled and verify we
pass and fail the policy check with expected context.

Partial implement blueprint policy-defaults-refresh

Change-Id: I0d526bfffe44b59a75d46e7377e705447a349b04
This commit is contained in:
Ghanshyam Mann
2020-02-10 20:20:19 -06:00
parent b6692ee48a
commit 4a1afcd3ce
+6 -5
View File
@@ -23,15 +23,16 @@ BASE_POLICY_NAME = 'os_compute_api:os-create-backup'
create_backup_policies = [ create_backup_policies = [
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
BASE_POLICY_NAME, name=BASE_POLICY_NAME,
base.RULE_ADMIN_OR_OWNER, check_str=base.RULE_ADMIN_OR_OWNER,
'Create a back up of a server', description='Create a back up of a server',
[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/servers/{server_id}/action (createBackup)' 'path': '/servers/{server_id}/action (createBackup)'
} }
]) ],
scope_types=['system', 'project'])
] ]