| 1 | """ |
| 2 | Prepare for custom root CA tests on macOS. |
| 3 | """ |
| 4 | |
| 5 | import Builder |
| 6 | |
| 7 | from pathlib import Path |
| 8 | |
| 9 | |
| 10 | class CustomKeychainTestSetup(Builder.Action): |
| 11 | """ |
| 12 | Create and populate a custom keychain for testing. |
| 13 | The actual logic is implemented in $ROOT/tests/resources/import_custom_cert_to_keychain.sh since shell commands |
| 14 | are more suitable for this. |
| 15 | |
| 16 | This action should be run in the 'pre_build_steps' or 'build_steps' stage. |
| 17 | """ |
| 18 | |
| 19 | def run(self, env): |
| 20 | if not env.project.needs_tests(env): |
| 21 | print("Skipping Custom Keychain Test setup because tests disabled for project") |
| 22 | return |
| 23 | |
| 24 | self.env = env |
| 25 | |
| 26 | root_dir = Path(__file__).resolve().parent / '..' / '..' |
| 27 | resource_dir = root_dir / 'tests' / 'resources' |
| 28 | |
| 29 | env.shell.exec(["bash", "import_custom_cert_to_keychain.sh"], working_dir=resource_dir, check=True) |