Skip to content

Commit 82d3a1d

Browse files
committed
Add pytest smoke target
Signed-off-by: averevki <[email protected]>
1 parent 8713552 commit 82d3a1d

File tree

7 files changed

+52
-53
lines changed

7 files changed

+52
-53
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ testsuite/%: FORCE poetry-no-dev
3838
test: ## Run all non mgc tests
3939
test pytest tests: kuadrant
4040

41+
smoke: poetry-no-dev
42+
$(PYTEST) -n4 -m 'smoke' --dist loadfile --enforce $(flags) testsuite/tests
43+
4144
authorino: ## Run only authorino related tests
4245
authorino: poetry-no-dev
4346
$(PYTEST) -n4 -m 'authorino and not multicluster' --dist loadfile --enforce $(flags) testsuite/tests/singlecluster

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ markers = [
4646
"limitador: Test is using Limitador features",
4747
"tlspolicy: Test is using TLSPolicy",
4848
"dnspolicy: Test is using DNSPolicy",
49+
"smoke: Build verification test",
4950
"disruptive: Test is disruptive",
5051
"multicluster: Test is specifc to Multicluster deployment",
5152
]

testsuite/tests/singlecluster/authorino/identity/auth/test_auth_identity.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def authorization(authorization, oidc_provider):
1616
return authorization
1717

1818

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

3332

34-
def test_correct_auth(client, auth):
35-
"""Tests correct auth"""
33+
@pytest.mark.parametrize(
34+
"oidc_provider",
35+
[pytest.param("keycloak", marks=[pytest.mark.smoke]), pytest.param("auth0")],
36+
indirect=True,
37+
)
38+
def test_auth_identity(client, auth, wrong_auth):
39+
"""Tests endpoint protection with auth identity"""
40+
response = client.get("/get")
41+
assert response.status_code == 401
42+
3643
response = client.get("/get", auth=auth)
3744
assert response.status_code == 200
3845

39-
40-
def test_wrong_auth(wrong_auth, client):
41-
"""Tests request with wrong token"""
4246
response = client.get("/get", auth=wrong_auth)
4347
assert response.status_code == 401
4448

45-
46-
def test_no_auth(client):
47-
"""Tests request without any auth"""
48-
response = client.get("/get")
49-
assert response.status_code == 401
50-
51-
52-
def test_invalid_auth(client):
53-
"""Tests request with invalid token"""
5449
response = client.get("/get", headers={"Authorization": "Bearer xyz"})
5550
assert response.status_code == 401
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Test for AuthPolicy attached directly to gateway"""
2+
3+
import pytest
4+
5+
pytestmark = [pytest.mark.kuadrant_only]
6+
7+
8+
@pytest.fixture(scope="module")
9+
def rate_limit():
10+
"""Basic gateway test doesn't utilize RateLimitPolicy component"""
11+
return None
12+
13+
14+
@pytest.mark.issue("https://github.com/Kuadrant/kuadrant-operator/pull/287")
15+
def test_authpolicy_attached_gateway(client, auth):
16+
"""Test if AuthPolicy attached directly to gateway works"""
17+
response = client.get("/get", auth=auth)
18+
assert response.status_code == 200
19+
20+
response = client.get("/get")
21+
assert response.status_code == 401
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
"""Test for AuthPolicy attached directly to gateway"""
1+
"""
2+
This module contains the most basic happy path test for both DNSPolicy and TLSPolicy
3+
"""
24

35
import pytest
46

5-
pytestmark = [pytest.mark.kuadrant_only]
7+
pytestmark = [pytest.mark.kuadrant_only, pytest.mark.dnspolicy, pytest.mark.tlspolicy, pytest.mark.smoke]
68

79

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

1314

14-
@pytest.mark.issue("https://github.com/Kuadrant/kuadrant-operator/pull/287")
15-
def test_smoke(client, auth):
16-
"""Test if AuthPolicy attached directly to gateway works"""
17-
response = client.get("/get", auth=auth)
18-
assert response.status_code == 200
15+
def test_gateway_basic_dns_tls(client, auth):
16+
"""
17+
Tests whether the backend, exposed using the HTTPRoute and Gateway, was exposed correctly,
18+
having a tls secured endpoint with a hostname managed by Kuadrant
19+
"""
1920

20-
response = client.get("/get")
21-
assert response.status_code == 401
21+
result = client.get("/get", auth=auth)
22+
assert not result.has_dns_error()
23+
assert not result.has_cert_verify_error()
24+
assert result.status_code == 200

testsuite/tests/singlecluster/gateway/test_dns.py

-24
This file was deleted.

testsuite/tests/singlecluster/limitador/test_basic_limit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@pytest.fixture(
1313
scope="module",
1414
params=[
15-
pytest.param(Limit(2, "15s"), id="2 requests every 15 sec"),
15+
pytest.param(Limit(2, "15s"), id="2 requests every 15 sec", marks=[pytest.mark.smoke]),
1616
pytest.param(Limit(5, "10s"), id="5 requests every 10 sec"),
1717
pytest.param(Limit(3, "5s"), id="3 request every 5 sec"),
1818
],

0 commit comments

Comments
 (0)