Skip to content
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

Fix tls secret deletion #247

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion testsuite/openshift/objects/gateway_api/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_instance(

def get_tls_cert(self) -> Certificate:
"""Returns TLS certificate used by the gateway"""
tls_cert_secret_name = self.model.spec.listeners[0].tls.certificateRefs[0].name
tls_cert_secret_name = self.cert_secret_name
tls_cert_secret = self.openshift.get_secret(tls_cert_secret_name)
tls_cert = Certificate(
key=tls_cert_secret["tls.key"],
Expand All @@ -122,6 +122,11 @@ def get_tls_cert(self) -> Certificate:
)
return tls_cert

def delete_tls_secret(self):
"""Deletes secret with TLS certificate used by the gateway"""
tls_secret = self.openshift.get_secret(self.cert_secret_name)
tls_secret.delete(ignore_not_found=True)

def get_spoke_gateway(self, spokes: dict[str, OpenShiftClient]) -> "MGCGateway":
"""
Returns spoke gateway on an arbitrary, and sometimes, random spoke cluster.
Expand Down Expand Up @@ -156,6 +161,11 @@ def delete(self, ignore_not_found=True, cmd_args=None):
with timeout(90):
super().delete(ignore_not_found, cmd_args)

@property
def cert_secret_name(self):
"""Returns name of the secret with generated TLS certificate"""
return self.model.spec.listeners[0].tls.certificateRefs[0].name


class GatewayProxy(Proxy):
"""Wrapper for Gateway object to make it a Proxy implementation e.g. exposing hostnames outside of the cluster"""
Expand Down
1 change: 1 addition & 0 deletions testsuite/tests/mgc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def upstream_gateway(request, openshift, blame, hostname, module_label):
placement="http-gateway",
labels={"app": module_label},
)
request.addfinalizer(upstream_gateway.delete_tls_secret) # pylint: disable=no-member
request.addfinalizer(upstream_gateway.delete)
upstream_gateway.commit()
# we cannot wait here because of referencing not yet existent tls secret which would be provided later by tlspolicy
Expand Down