-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from jsmolar/metadata
Move Mockserver fixture to higher conftest
- Loading branch information
Showing
8 changed files
with
47 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
testsuite/tests/kuadrant/authorino/authorization/opa/conftest.py
This file was deleted.
Oops, something went wrong.
Empty file.
27 changes: 27 additions & 0 deletions
27
testsuite/tests/kuadrant/authorino/authorization/opa/external_registry/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Conftest for OPA policy located on external registry""" | ||
import pytest | ||
|
||
from testsuite.utils import rego_allow_header | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def header(): | ||
"""Header used by OPA policy""" | ||
return "opa", "opa-test" | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def opa_policy_expectation(request, mockserver, module_label, header): | ||
"""Creates Mockserver Expectation that returns Rego query and returns its endpoint""" | ||
request.addfinalizer(lambda: mockserver.clear_expectation(module_label)) | ||
return mockserver.create_expectation(module_label, f"/{module_label}/opa", rego_allow_header(*header)) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorization(authorization, opa_policy_expectation): | ||
""" | ||
Adds OPA policy. Rego query is located on external registry (Mockserver). | ||
Policy accepts requests that contain `header`. | ||
""" | ||
authorization.add_external_opa_policy("opa", opa_policy_expectation, 1) | ||
return authorization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...thorization/opa/test_external_registry.py → ...ternal_registry/test_external_registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters