forked from Kuadrant/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smoke test for authpolicy attached directly to gateway
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,37 @@ | ||
"""Conftest for gateway tests""" | ||
import pytest | ||
|
||
from testsuite.httpx.auth import HttpxOidcClientAuth | ||
from testsuite.policy.authorization.auth_policy import AuthPolicy | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def kuadrant(kuadrant): | ||
"""Skip if not running on Kuadrant""" | ||
if not kuadrant: | ||
pytest.skip("Gateway tests are only for Kuadrant") | ||
return kuadrant | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def gateway_ready(gateway): | ||
"""Returns ready gateway""" | ||
gateway.wait_for_ready() | ||
return gateway | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def authorization(gateway_ready, route, oidc_provider, authorization_name, openshift, module_label): | ||
# pylint: disable=unused-argument | ||
"""Create AuthPolicy attached to gateway""" | ||
authorization = AuthPolicy.create_instance( | ||
openshift, authorization_name, gateway_ready, labels={"testRun": module_label} | ||
) | ||
authorization.identity.add_oidc("rhsso", oidc_provider.well_known["issuer"]) | ||
return authorization | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def auth(oidc_provider): | ||
"""Returns RHSSO authentication object for HTTPX""" | ||
return HttpxOidcClientAuth(oidc_provider.get_token, "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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Test for AuthPolicy attached directly to gateway""" | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def rate_limit(): | ||
"""Basic gateway test doesn't utilize RateLimitPolicy component""" | ||
return None | ||
|
||
|
||
@pytest.mark.issue("https://github.com/Kuadrant/kuadrant-operator/pull/287") | ||
def test_smoke(client, auth): | ||
"""Test if AuthPolicy attached directly to gateway works""" | ||
response = client.get("/get", auth=auth) | ||
assert response.status_code == 200 | ||
|
||
response = client.get("/get") | ||
assert response.status_code == 401 |