Skip to content

Commit 6d31fd8

Browse files
test(e2e): enable unconfigured model deny-by-default test (#728)
## Summary - Uncomments the `test_unconfigured_model_denied_by_gateway_auth` test in `test/e2e/tests/test_subscription.py` - Verifies that models with no MaaSAuthPolicy or MaaSSubscription are denied (403) by the `gateway-default-auth` AuthPolicy - The test fixture (`test/e2e/fixtures/unconfigured/`) already exists and deploys a MaaSModelRef with no auth policy or subscription <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Re-enabled end-to-end coverage for gateway access control: confirms deny-by-default behavior and that models without required subscription/auth configuration are denied (403) when accessed with the default API key. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 99bcd1b commit 6d31fd8

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

test/e2e/tests/test_subscription.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,13 +1477,43 @@ def test_delete_last_subscription_denies_access(self):
14771477
_apply_cr(original)
14781478
_wait_reconcile()
14791479

1480-
# TODO: Uncomment this test once we validated unconfigured models
1481-
# def test_unconfigured_model_denied_by_gateway_auth(self):
1482-
# """New model with no MaaSAuthPolicy/MaaSSubscription -> gateway default auth denies (403)."""
1483-
# api_key = _get_default_api_key()
1484-
# r = _inference(api_key, path=UNCONFIGURED_MODEL_PATH)
1485-
# log.info(f"Unconfigured model (no auth policy) -> {r.status_code}")
1486-
# assert r.status_code == 403, f"Expected 403 (gateway default deny), got {r.status_code}"
1480+
def test_unconfigured_model_denied_by_gateway_auth(self):
1481+
"""New model with no MaaSAuthPolicy/MaaSSubscription -> gateway default auth denies (403)."""
1482+
# Precondition: unconfigured model fixture is deployed
1483+
model = _get_cr("maasmodelref", UNCONFIGURED_MODEL_REF, namespace=MODEL_NAMESPACE)
1484+
assert model is not None, (
1485+
f"MaaSModelRef {UNCONFIGURED_MODEL_REF} must exist in {MODEL_NAMESPACE} "
1486+
f"(deploy test/e2e/fixtures/unconfigured first)"
1487+
)
1488+
1489+
# Precondition: no per-route auth policy exists for this model
1490+
assert not _cr_exists("maasauthpolicy", UNCONFIGURED_MODEL_REF, namespace=MODEL_NAMESPACE), (
1491+
f"MaaSAuthPolicy for {UNCONFIGURED_MODEL_REF} must NOT exist — "
1492+
f"this test validates gateway-level deny-by-default"
1493+
)
1494+
1495+
# Precondition: no subscription exists for this model
1496+
assert not _cr_exists("maassubscription", UNCONFIGURED_MODEL_REF, namespace=MODEL_NAMESPACE), (
1497+
f"MaaSSubscription for {UNCONFIGURED_MODEL_REF} must NOT exist — "
1498+
f"this test validates gateway-level deny-by-default"
1499+
)
1500+
1501+
# Precondition: gateway-default-auth is in place and accepted
1502+
gw_auth = _get_cr("authpolicy", "gateway-default-auth", namespace="openshift-ingress")
1503+
assert gw_auth is not None, (
1504+
"gateway-default-auth AuthPolicy must exist in openshift-ingress"
1505+
)
1506+
conditions = gw_auth.get("status", {}).get("conditions", [])
1507+
accepted = [c for c in conditions if c.get("type") == "Accepted"]
1508+
assert accepted and accepted[0].get("status") == "True", (
1509+
f"gateway-default-auth must be Accepted, got: {accepted}"
1510+
)
1511+
1512+
# Verify deny-by-default: inference to unconfigured model should be denied
1513+
api_key = _get_default_api_key()
1514+
r = _inference(api_key, path=UNCONFIGURED_MODEL_PATH)
1515+
log.info(f"Unconfigured model (no auth policy) -> {r.status_code}")
1516+
assert r.status_code == 403, f"Expected 403 (gateway default deny), got {r.status_code}"
14871517

14881518

14891519
class TestOrderingEdgeCases:

0 commit comments

Comments
 (0)