Raise premature exceptions that happen before switch role

Registered by Felipe Monteiro

Currently, the following bad scenarios are possible:

1) Forbidden expected, Forbidden thrown prematurely

    @rbac_rule_validation.action(
        service="nova",
        rule="os_compute_api:os-agents")
    def test_list_agents_rbac(self):
        # During test set up, a Forbidden exception is raised
        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.agents_client.list_agents()

What should happen: The Forbidden is raised by the test and results in test failure.
What actually happens: The Forbidden exception is treated as a test success.

2) NotFound expected, NotFound thrown prematurely

    @rbac_rule_validation.action(
        service="nova",
        rule="os_compute_api:os-agents",
         expected_error_code=404)
    def test_list_agents_rbac(self):
        # During test set up, a NotFound exception is raised
        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.agents_client.list_agents()

What should happen: The NotFound is raised by the test and results in test failure.
What actually happens: The NotFound exception is treated as a test success.

Validation should be added to prevent either case from happening. Patrole should only validate that the exception raised following switch_role is the expected one -- any exceptions (except for skipException) raised before switch_role should result in an error and test failure because that is a result of bad setup.

Blueprint information

Status:
Complete
Approver:
Felipe Monteiro
Priority:
Medium
Drafter:
Felipe Monteiro
Direction:
Approved
Assignee:
None
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Felipe Monteiro

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/premature-exception-validation,n,z

Addressed by: https://review.openstack.org/473680
    Raise premature exceptions that happen before switch role

This is not a valid issue because if a premature exception is raised, then switch_role will not be called the correct number of times -- for which validation already exists -- causing the test to fail.

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.