| --- |
| features: |
| - | |
| In order to test the list actions which doesn't have its own policy, |
| implemented the ``override_role_and_validate_list`` function. |
| The function has two modes: |
| |
| * Validating the number of the resources in a ``ResponseBody`` before |
| calling the ``override_role`` and after. |
| |
| .. code-block:: python |
| |
| # make sure at least one resource is available |
| self.ntp_client.create_policy_dscp_marking_rule() |
| # the list of resources available for a user with admin role |
| admin_resources = self.ntp_client.list_dscp_marking_rules( |
| policy_id=self.policy_id)["dscp_marking_rules"] |
| with self.rbac_utils.override_role_and_validate_list( |
| self, admin_resources=admin_resources) as ctx: |
| # the list of resources available for a user with member role |
| ctx.resources = self.ntp_client.list_dscp_marking_rules( |
| policy_id=self.policy_id)["dscp_marking_rules"] |
| |
| * Validating that a resource, created before ``override_role``, is not |
| present in a ``ResponseBody``. |
| |
| .. code-block:: python |
| |
| # the resource created by a user with admin role |
| admin_resource_id = ( |
| self.ntp_client.create_dscp_marking_rule() |
| ["dscp_marking_rule"]["id']) |
| with self.rbac_utils.override_role_and_validate_list( |
| self, admin_resource_id=admin_resource_id) as ctx: |
| # the list of resources available for a user wirh member role |
| ctx.resources = self.ntp_client.list_dscp_marking_rules( |
| policy_id=self.policy_id)["dscp_marking_rules"] |