Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest smoke target #640

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ testsuite/%: FORCE poetry-no-dev
test: ## Run all non mgc tests
test pytest tests: kuadrant

smoke: poetry-no-dev
$(PYTEST) -n4 -m 'smoke' --dist loadfile --enforce $(flags) testsuite/tests

authorino: ## Run only authorino related tests
authorino: poetry-no-dev
$(PYTEST) -n4 -m 'authorino and not multicluster' --dist loadfile --enforce $(flags) testsuite/tests/singlecluster
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ markers = [
"limitador: Test is using Limitador features",
"tlspolicy: Test is using TLSPolicy",
"dnspolicy: Test is using DNSPolicy",
"smoke: Build verification test",
"disruptive: Test is disruptive",
"multicluster: Test is specifc to Multicluster deployment",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def authorization(authorization, oidc_provider):
return authorization


@pytest.fixture(scope="module", params=("keycloak", "auth0"))
def oidc_provider(request) -> OIDCProvider:
"""Fixture which enables switching out OIDC providers for individual modules"""
return request.getfixturevalue(request.param)
Expand All @@ -31,25 +30,21 @@ def wrong_auth(oidc_provider, auth0, keycloak):
return HttpxOidcClientAuth(token)


def test_correct_auth(client, auth):
"""Tests correct auth"""
@pytest.mark.parametrize(
"oidc_provider",
[pytest.param("keycloak", marks=[pytest.mark.smoke]), pytest.param("auth0")],
indirect=True,
)
def test_auth_identity(client, auth, wrong_auth):
"""Tests endpoint protection with auth identity"""
response = client.get("/get")
assert response.status_code == 401

response = client.get("/get", auth=auth)
assert response.status_code == 200


def test_wrong_auth(wrong_auth, client):
"""Tests request with wrong token"""
response = client.get("/get", auth=wrong_auth)
assert response.status_code == 401


def test_no_auth(client):
"""Tests request without any auth"""
response = client.get("/get")
assert response.status_code == 401


def test_invalid_auth(client):
"""Tests request with invalid token"""
response = client.get("/get", headers={"Authorization": "Bearer xyz"})
assert response.status_code == 401
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Test for AuthPolicy attached directly to gateway"""

import pytest

pytestmark = [pytest.mark.kuadrant_only]


@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_authpolicy_attached_gateway(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
29 changes: 16 additions & 13 deletions testsuite/tests/singlecluster/gateway/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
"""Test for AuthPolicy attached directly to gateway"""
"""
This module contains the most basic happy path test for both DNSPolicy and TLSPolicy
"""

import pytest

pytestmark = [pytest.mark.kuadrant_only]
pytestmark = [pytest.mark.kuadrant_only, pytest.mark.dnspolicy, pytest.mark.tlspolicy, pytest.mark.smoke]


@pytest.fixture(scope="module")
def rate_limit():
"""Basic gateway test doesn't utilize RateLimitPolicy component"""
return None
def test_gateway_readiness(gateway):
"""Tests whether the Gateway was successfully placed by having its IP address assigned"""
assert gateway.is_ready()


@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
def test_gateway_basic_dns_tls(client, auth):
"""
Tests whether the backend, exposed using the HTTPRoute and Gateway, was exposed correctly,
having a tls secured endpoint with a hostname managed by Kuadrant
"""

response = client.get("/get")
assert response.status_code == 401
result = client.get("/get", auth=auth)
assert not result.has_dns_error()
assert not result.has_cert_verify_error()
assert result.status_code == 200
24 changes: 0 additions & 24 deletions testsuite/tests/singlecluster/gateway/test_dns.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@pytest.fixture(
scope="module",
params=[
pytest.param(Limit(2, "15s"), id="2 requests every 15 sec"),
pytest.param(Limit(2, "15s"), id="2 requests every 15 sec", marks=[pytest.mark.smoke]),
pytest.param(Limit(5, "10s"), id="5 requests every 10 sec"),
pytest.param(Limit(3, "5s"), id="3 request every 5 sec"),
],
Expand Down