Switch role using contextmanager for automatic role re-switch
By using a ``@contextmanager`` above ``switch_role`` role-switching can be streamlined. This approach offers the following
advantages:
1) Role switching is performed in 1 class only. There is no
need to call ``test_
from ``rbac_
leads to cleaner, more readable code.
2) Improves test code readability.
3) Improve policy granularity.
4) Simplifies interface.
Rather than doing:
# setup code here
rand_name = data_utils.
# ...
# more setup code here
self.
# execute the test here
(Without newlines, this code is very hard to read.)
It can instead be possible to do:
# setup code here
rand_name = data_utils.
# ...
# more setup code here
with self.rbac_
# execute the test here
# notice the indentation... visually it is easy to see
# that this block here is where the role is switched
# now we are back to admin credentials in case we still
# need it in the test... this was not possible before w/o
# calling ``switch_role`` yet again...
waiters.
Blueprint information
- Status:
- Complete
- Approver:
- Felipe Monteiro
- Priority:
- High
- Drafter:
- Felipe Monteiro
- Direction:
- Approved
- Assignee:
- Felipe Monteiro
- Definition:
- Approved
- Series goal:
- Accepted for 0.3.0
- Implementation:
- Implemented
- Milestone target:
- None
- Started by
- Ghanshyam Mann
- Completed by
- Ghanshyam Mann
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
Role switch using contextmanager for automatic role re-switch
Gerrit topic: https:/
Addressed by: https:/
Base implementation of override_role for automatic role re-switch
Gerrit topic: https:/
Addressed by: https:/
Migrate to override_role for compute module (part 1)
Addressed by: https:/
Migrate to override_role for compute module (part 2)
Addressed by: https:/
[TrivialFix] Use _override_role in rbac_rule_
Addressed by: https:/
Migrate to override_role for compute module (part 3)
Addressed by: https:/
[docs] Update rbac_utils.rst documentation
Addressed by: https:/
Migrate to override_role for identity module (part 1)
Addressed by: https:/
Migrate to override_role for identity module (part 2)
Addressed by: https:/
Migrate to override_role for image module (part 1)
Addressed by: https:/
Migrate to override_role for network tests
Addressed by: https:/
Migrate to override_role for network tests-2
Addressed by: https:/
Migrate to override_role for compute module (part 3)
Addressed by: https:/
Migrate to override_role for compute module (part 3)
Addressed by: https:/
Migrate to override_role for volume module (part 1)
Addressed by: https:/
Migrate to override_role for volume module (part 2)
Addressed by: https:/
Migrate to override_role for volume module (part 3)
Addressed by: https:/
Migrate to override_role for volume module (part 4)
Addressed by: https:/
Migrate to override_role for volume module (last)
Gerrit topic: https:/
Addressed by: https:/
Migrate to override_role for network multiprovider tests
Gerrit topic: https:/
Addressed by: https:/
Migrate to override_role for network port tests
Addressed by: https:/
Migrate to override_role for network metering tests
Addressed by: https:/
Migrate to override_role for volume module (part 3)
Addressed by: https:/
Migrate to override_role for network test_networks_rbac
Gerrit topic: https:/
Addressed by: https:/
Migrate to override_role for image module (part 2)
Addressed by: https:/
Migrate to override_role for network security group tests
Addressed by: https:/
Migrate to override_role for identity v2 module
Addressed by: https:/
override_role cleanup: Remove superfluous call in rbac_rule_