-
Notifications
You must be signed in to change notification settings - Fork 24
feat(x509): add test for standalone Authorino x509.source.expression #939
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """Tests on mTLS authentication with multiple attributes""" | ||
| """Tests on x509 identity authentication with multiple attributes""" | ||
|
|
||
| import pytest | ||
|
|
||
|
|
@@ -16,15 +16,15 @@ def authorization(authorization, blame, cert_attributes): | |
| return authorization | ||
|
|
||
|
|
||
| def test_mtls_multiple_attributes_success(envoy_authority, valid_cert, hostname): | ||
| """Test successful mtls authentication with two matching attributes""" | ||
| def test_x509_multiple_attributes_success(envoy_authority, valid_cert, hostname): | ||
| """Test successful x509 authentication with two matching attributes""" | ||
| with hostname.client(verify=envoy_authority, cert=valid_cert) as client: | ||
| response = client.get("/get") | ||
| assert response.status_code == 200 | ||
|
|
||
|
|
||
| def test_mtls_multiple_attributes_fail(envoy_authority, custom_cert, hostname): | ||
| """Test mtls authentication with one matched and one unmatched attributes""" | ||
| def test_x509_multiple_attributes_fail(envoy_authority, custom_cert, hostname): | ||
| """Test x509 authentication with one matched and one unmatched attributes""" | ||
|
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the singular/plural mismatch in the docstring. Line 27 should use singular “attribute” after “one unmatched”. Suggested wording update- """Test x509 authentication with one matched and one unmatched attributes"""
+ """Test x509 authentication with one matched and one unmatched attribute"""🤖 Prompt for AI Agents |
||
| with hostname.client(verify=envoy_authority, cert=custom_cert) as client: | ||
| response = client.get("/get") | ||
| assert response.status_code == 403 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| """Test x509 client certificate authentication with CEL expression on AuthConfig""" | ||
|
|
||
| import pytest | ||
|
|
||
| from testsuite.kuadrant.policy.authorization import X509Source | ||
|
|
||
| pytestmark = [pytest.mark.authorino, pytest.mark.standalone_only] | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
| def authorization(authorization, blame, selector): | ||
| """AuthConfig with x509 identity using CEL expression for certificate source""" | ||
| authorization.identity.add_mtls( | ||
| blame("x509"), selector=selector, source=X509Source(expression="source.certificate") | ||
| ) | ||
| return authorization | ||
|
|
||
|
|
||
| def test_x509_success(envoy_authority, valid_cert, hostname): | ||
| """Test successful x509 authentication with CEL expression""" | ||
| with hostname.client(verify=envoy_authority, cert=valid_cert) as client: | ||
| response = client.get("/get") | ||
| assert response.status_code == 200 | ||
|
|
||
|
|
||
| def test_x509_invalid_cert(envoy_authority, invalid_cert, hostname): | ||
| """Test that a certificate signed by an untrusted CA is rejected""" | ||
| with hostname.client(verify=envoy_authority, cert=invalid_cert) as client: | ||
| result = client.get("/get") | ||
| assert result.has_unknown_ca_error() | ||
|
Comment on lines
+26
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Inspect unknown-CA assertions versus explicit Authorino 401 x509 rejection coverage.
set -euo pipefail
echo "Result.has_unknown_ca_error definition and call sites:"
rg -n -C3 '\bdef\s+has_unknown_ca_error\b|\bhas_unknown_ca_error\s*\(' --iglob '*.py'
echo
echo "Existing x509 tests that assert explicit 401 rejection:"
rg -n -C4 'intermediate_cert_unlabeled|status_code\s*==\s*401' --iglob '*.py'Repository: Kuadrant/testsuite Length of output: 50374 🏁 Script executed: #!/bin/bash
# Check the conftest.py for test_x509_cel_source.py to understand available fixtures and certificates
find . -path "*/singlecluster/authorino/operator/x509/gateway_validation/conftest.py" -type f | head -1 | xargs catRepository: Kuadrant/testsuite Length of output: 2107 Assert Authorino-side 401 for wrong-CA coverage. The test currently uses 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def test_x509_no_cert(envoy_authority, hostname): | ||
| """Test that a request without a client certificate is rejected""" | ||
| with hostname.client(verify=envoy_authority) as client: | ||
| result = client.get("/get") | ||
| assert result.has_cert_required_error() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this to string? Also you forgot to change the documenation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
expressionis not a separate key here, it is part of the authorino x509 identity specThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what documentation are you referring to?