Skip to content

Commit

Permalink
Add pytest smoke target
Browse files Browse the repository at this point in the history
Signed-off-by: averevki <[email protected]>
  • Loading branch information
averevki committed Feb 19, 2025
1 parent 8713552 commit b93071f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 53 deletions.
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) -n6 -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

0 comments on commit b93071f

Please sign in to comment.