blob: 178e538984f5a7ccaed9618547fd4cfe18d2e6dc [file] [log] [blame]
Felipe Monteiro7bc35dc2017-04-19 21:11:46 +01001Patrole Style Commandments
2==========================
DavidPurcell663aedf2017-01-03 10:01:14 -05003
Felipe Monteiro0854ded2017-05-05 16:30:55 +01004- Step 1: Read the OpenStack Style Commandments: `<http://docs.openstack.org/developer/hacking/>`__
5- Step 2: Review Tempest's Style Commandments: `<https://docs.openstack.org/developer/tempest/HACKING.html>`__
6- Step 3: Read on
Felipe Monteiro7bc35dc2017-04-19 21:11:46 +01007
Felipe Monteiro0854ded2017-05-05 16:30:55 +01008Patrole Specific Commandments
9------------------------------
10
11Patrole borrows the following commandments from Tempest; refer to
12`Tempest's Commandments <https://docs.openstack.org/developer/tempest/HACKING.html>`__
13for more information:
14
15.. note::
16
17 The original Tempest Commandments do not include Patrole-specific paths.
18 Patrole-specific paths replace the Tempest-specific paths within Patrole's
19 hacking checks.
20..
21
22- [T102] Cannot import OpenStack python clients in patrole_tempest_plugin/tests/api
23- [T105] Tests cannot use setUpClass/tearDownClass
24- [T106] vim configuration should not be kept in source files.
25- [T107] Check that a service tag isn't in the module path
26- [T108] Check no hyphen at the end of rand_name() argument
27- [T109] Cannot use testtools.skip decorator; instead use
28 decorators.skip_because from tempest.lib
29- [T113] Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
30- [N322] Method's default argument shouldn't be mutable
31
32The following are Patrole's specific Commandments:
33
34- [P100] The ``rbac_rule_validation.action`` decorator must be applied to
35 an RBAC test (the check fails if the decorator is not one of the
36 two decorators directly above the function declaration)
37- [P101] RBAC test filenames must end with "_rbac.py"; for example,
38 test_servers_rbac.py, not test_servers.py
39- [P102] RBAC test class names must end in 'RbacTest'
Samantha Blancocd870772017-05-22 14:23:17 -040040- [P103] ``self.client`` must not be used as a client alias; this allows for
41 code that is more maintainable and easier to read
Felipe Monteiro0854ded2017-05-05 16:30:55 +010042
43Role Switching
44--------------
45
46Correct role switching is vital to correct RBAC testing within Patrole. If a
47test does not call ``rbac_utils.switch_role`` with ``toggle_rbac_role=True``
48within the RBAC test, then the test is *not* a valid RBAC test: The API
49endpoint under test will be performed with admin credentials, which is always
50wrong unless ``CONF.rbac_test_role`` is admin.
51
52.. note::
53
54 Switching back to the admin role for setup and clean up is automatically
55 performed. Toggling ``switch_role`` with ``toggle_rbac_role=False`` within
56 the context of a test should *never* be performed and doing so will likely
57 result in an error being thrown.
58..
59
60Patrole does not have a hacking check for role switching, but does use a
61built-in mechanism for verifying that role switching is being correctly
62executed across tests. If a test does not call ``switch_role`` with
63``toggle_rbac_role=True``, then an ``RbacResourceSetupFailed`` exception
64will be raised.