You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* File mapping: Unit test files map directly to the .py files in the Policy Sentry package
78
+
* Folder mapping: Folder structure of the test files maps directly to the folder structure in the Policy Sentry package
79
+
* GitHub issue mapping: Add unit tests that correspond directly to those GitHub issues to show that the fix work specifically for the issue raised. prefix test name with issue number.
80
+
For example: [test_gh_211_write_with_empty_access_level_lists](https://github.com/salesforce/policy_sentry/blob/0b3398a365f4cf0901bd779c6156207688e7858b/test/writing/test_write_policy_library_usage.py#L269) is prefixed with issue number 111.
81
+
* Adaptable to IAM Definition changes:
82
+
* For tests that are dependent on current state of the IAM definition (aka the IAM Database, iam_definition.json), avoid doing equals comparision of the results with the expected_results.
83
+
* Over time, as IAM definiton changes, chances are that such tests would fail.
84
+
* Example: let's say that hypothetically the secretsmanager service had 4 actions at the "write" access level that could be restricted to the secret resource type. If I wrote the tests so that they tested the value of the generated policy, that works for the initial tests. But if AWS adds two new actions that can be restricted to that access level and resource type, then the tests would fail.
85
+
* This only really applies for where the expected test values would be dependent on the current state of the IAM definition (aka the IAM Database, iam_definition.json) and the actions in there. So, validating the output of write-policy related commands, and query related commands.
86
+
* After I realized that, I started writing my tests so that the expected output that showed what actions you'd want would be in the comments instead of the expected_results, so the human knows what's going on. And then I would just check that the size of the array holding the actions is greater than or equal to the size that it is currently at.
87
+
So, in the secretsmanager example above, the test would probably just check that the size of the actions is greater than or equal to 4.
88
+
89
+
90
+
91
+
### Quick and Easy way to run tests
92
+
93
+
Just run this from the root of the repository:
74
94
75
95
We highly suggest that you run all the tests before pushing a
76
96
significant commit. It would be painful to copy/paste all of those lines
77
97
above - so we've compiled a test script in the `utils`
0 commit comments