Provide the appropriate Tester instance for security tests. Dynamically instantiates the correct tester class based on which test module is requesting the fixture.
(request, api_server_required)
| 305 | |
| 306 | @pytest.fixture |
| 307 | def tester(request, api_server_required): |
| 308 | """ |
| 309 | Provide the appropriate Tester instance for security tests. |
| 310 | |
| 311 | Dynamically instantiates the correct tester class based on which |
| 312 | test module is requesting the fixture. |
| 313 | """ |
| 314 | module_name = request.module.__name__ |
| 315 | |
| 316 | if "test_api_vulnerabilities" in module_name: |
| 317 | from security.test_api_vulnerabilities import SecurityTester |
| 318 | |
| 319 | return SecurityTester() |
| 320 | elif "test_access_control" in module_name: |
| 321 | from security.test_access_control import AuthBypassTester |
| 322 | |
| 323 | return AuthBypassTester() |
| 324 | elif "test_denial_of_service" in module_name: |
| 325 | from security.test_denial_of_service import DoSTester |
| 326 | |
| 327 | return DoSTester() |
| 328 | else: |
| 329 | # Default fallback |
| 330 | from security.test_api_vulnerabilities import SecurityTester |
| 331 | |
| 332 | return SecurityTester() |
| 333 | |
| 334 | |
| 335 | @pytest.fixture |
nothing calls this directly
no test coverage detected