forked from Kuadrant/testsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kuadrant#325 from martinhesko/letsencrypt-test
extend MGC tests to Let's Encrypt certificates
- Loading branch information
Showing
5 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFmDCCA4CgAwIBAgIQU9C87nMpOIFKYpfvOHFHFDANBgkqhkiG9w0BAQsFADBm | ||
MQswCQYDVQQGEwJVUzEzMDEGA1UEChMqKFNUQUdJTkcpIEludGVybmV0IFNlY3Vy | ||
aXR5IFJlc2VhcmNoIEdyb3VwMSIwIAYDVQQDExkoU1RBR0lORykgUHJldGVuZCBQ | ||
ZWFyIFgxMB4XDTE1MDYwNDExMDQzOFoXDTM1MDYwNDExMDQzOFowZjELMAkGA1UE | ||
BhMCVVMxMzAxBgNVBAoTKihTVEFHSU5HKSBJbnRlcm5ldCBTZWN1cml0eSBSZXNl | ||
YXJjaCBHcm91cDEiMCAGA1UEAxMZKFNUQUdJTkcpIFByZXRlbmQgUGVhciBYMTCC | ||
AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALbagEdDTa1QgGBWSYkyMhsc | ||
ZXENOBaVRTMX1hceJENgsL0Ma49D3MilI4KS38mtkmdF6cPWnL++fgehT0FbRHZg | ||
jOEr8UAN4jH6omjrbTD++VZneTsMVaGamQmDdFl5g1gYaigkkm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LzDul//rUF10gEMWaXVZV51KpS9DY/ | ||
5CunuvCXmEQJHo7kGcViT7sETn6Jz9KOhvYcXkJ7po6d93A/jy4GKPIPnsKKNEmR | ||
xUuXY4xRdh45tMJnLTUDdC9FIU0flTeO9/vNpVA8OPU1i14vCz+MU8KX1bV3GXm/ | ||
fxlB7VBBjX9v5oUep0o/j68R/iDlCOM4VVfRa8gX6T2FU7fNdatvGro7uQzIvWof | ||
gN9WUwCbEMBy/YhBSrXycKA8crgGg3x1mIsopn88JKwmMBa68oS7EHM9w7C4y71M | ||
7DiA+/9Qdp9RBWJpTS9i/mDnJg1xvo8Xz49mrrgfmcAXTCJqXi24NatI3Oc= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
""" | ||
This module contains the most basic happy path test for both DNSPolicy and TLSPolicy | ||
for a cluster with Let's Encrypt ClusterIssuer | ||
Prerequisites: | ||
* multi-cluster-gateways ns is created and set as openshift["project"] | ||
* managedclustersetbinding is created in openshift["project"] | ||
* gateway class "kuadrant-multi-cluster-gateway-instance-per-cluster" is created | ||
* cert-manager Operator installed | ||
* Let's Encrypt ClusterIssuer object configured on the cluster matching the template: | ||
apiVersion: cert-manager.io/v1 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-staging | ||
spec: | ||
acme: | ||
email: <email_address> | ||
preferredChain: ISRG Root X1 | ||
privateKeySecretRef: | ||
name: letsencrypt-private-key | ||
server: 'https://acme-staging-v02.api.letsencrypt.org/directory' | ||
solvers: | ||
- dns01: | ||
route53: | ||
accessKeyID: <aws_key_id> | ||
hostedZoneID: <hosted_zone_id> | ||
region: <region_name> | ||
secretAccessKeySecretRef: | ||
key: awsSecretAccessKey | ||
name: aws-secret | ||
""" | ||
|
||
import dataclasses | ||
from importlib import resources | ||
|
||
import pytest | ||
from openshift_client import selector | ||
from openshift_client.model import OpenShiftPythonException | ||
|
||
from testsuite.gateway import Exposer, CustomReference | ||
from testsuite.gateway.gateway_api.hostname import DNSPolicyExposer | ||
|
||
pytestmark = [pytest.mark.mgc] | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def cluster_issuer(hub_openshift): | ||
"""Reference to cluster Let's Encrypt certificate issuer""" | ||
try: | ||
selector("clusterissuer/letsencrypt-staging", static_context=hub_openshift.context).object() | ||
except OpenShiftPythonException as exc: | ||
pytest.skip(f"letsencrypt-staging ClusterIssuer is not present on the cluster: {exc}") | ||
return CustomReference( | ||
group="cert-manager.io", | ||
kind="ClusterIssuer", | ||
name="letsencrypt-staging", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def exposer(base_domain, hub_gateway) -> Exposer: | ||
"""DNSPolicyExposer setup with expected TLS certificate""" | ||
root_cert = resources.files("testsuite.resources").joinpath("letsencrypt-stg-root-x1.pem").read_text() | ||
old_cert = hub_gateway.get_tls_cert() | ||
return DNSPolicyExposer(base_domain, tls_cert=dataclasses.replace(old_cert, chain=old_cert.certificate + root_cert)) | ||
|
||
|
||
# Reduce scope of the base_domain fixture so the test only runs on aws-mz ManagedZone | ||
@pytest.mark.parametrize("base_domain", ["aws-mz"], indirect=True) | ||
def test_smoke_letsencrypt(client): | ||
""" | ||
Tests whether the backend, exposed using the HTTPRoute and Gateway, was exposed correctly, | ||
having a tls secured endpoint with a hostname managed by MGC | ||
""" | ||
|
||
result = client.get("/get") | ||
assert not result.has_dns_error() | ||
assert not result.has_cert_verify_error() | ||
assert result.status_code == 200 |