Refactors exceptions in rbac_rule_validation decorator.
Currently, rbac_rule_validation decorator repeats code
underneath "except expected_exception" and "except RbacActionFailed".
These 2 blocks of code can be merged by using a tuple that
contains both of these exceptions on 1 line.
This patch makes the above change. It also adds a new exception
block for a wildcard exception. If a 404 is expected but a 403 is
thrown, the 403 is caught and an error message saying that the
expected error code differs from the one caught is then re-raised.
That is, a more informative error message is thrown than
otherwise would be.
This patch finally improves upon rbac_rule_validation unit tests by:
- removing redundant tests
- renames tests to make them more understandable
- adds docstrings to each tests to make them more understandable
Change-Id: Idea4a45f721893c997acbfb2a1beb978ccfe11e6
2 files changed