Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saltiyazan committed Feb 10, 2025
1 parent 633f3a2 commit 7b77bc1
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 1,332 deletions.
4 changes: 3 additions & 1 deletion lib/charms/opensearch/v0/opensearch_base_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,9 @@ def on_new_ca_added(self):
)
self._restart_opensearch_event.emit()

def on_tls_conf_set(self, event: CertificateAvailableEvent, scope: Scope, cert_type: CertType, renewal: bool):
def on_tls_conf_set(
self, event: CertificateAvailableEvent, scope: Scope, cert_type: CertType, renewal: bool
):
"""Called after certificate ready and stored on the corresponding scope databag."""
if scope == Scope.UNIT:
admin_secrets = self.secrets.get_object(Scope.APP, CertType.APP_ADMIN.val) or {}
Expand Down
17 changes: 4 additions & 13 deletions lib/charms/opensearch/v0/opensearch_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from charms.opensearch.v0.constants_charm import PeerRelationName
from charms.opensearch.v0.constants_tls import (
TLS_RELATION,
TLS_RELATION_ADMIN,
TLS_RELATION_CLIENT,
TLS_RELATION_PEER,
Expand All @@ -46,7 +45,6 @@
CertificateAvailableEvent,
CertificateRequestAttributes,
Mode,
PrivateKey,
TLSCertificatesRequiresV4,
)
from ops.charm import ActionEvent, RelationBrokenEvent, RelationCreatedEvent
Expand Down Expand Up @@ -103,12 +101,6 @@ def __init__(
self.charm.on.set_tls_private_key_action, self._on_set_tls_private_key
)

self.framework.observe(
self.charm.on[TLS_RELATION].relation_created, self._on_tls_relation_created
)
self.framework.observe(
self.charm.on[TLS_RELATION].relation_broken, self._on_tls_relation_broken
)
for cert_interface in [self.certs_admin, self.certs_peer, self.certs_client]:
self.framework.observe(
cert_interface.on.certificate_available, self._on_certificate_available
Expand Down Expand Up @@ -319,10 +311,9 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
if self.charm.unit.is_leader() and self.charm.opensearch_peer_cm.is_provider(typ="main"):
self.charm.peer_cluster_provider.refresh_relation_data(event, can_defer=False)

renewal = (
current_secret_obj.get("cert") is not None
and current_secret_obj.get("cert") != str(event.certificate)
)
renewal = current_secret_obj.get("cert") is not None and current_secret_obj.get(
"cert"
) != str(event.certificate)

try:
self.charm.on_tls_conf_set(event, scope, cert_type, renewal)
Expand Down Expand Up @@ -511,7 +502,7 @@ def store_new_ca(self, secrets: Dict[str, Any]) -> bool:
)
run_cmd(f"sudo chmod +r {store_path}")
logger.info(f"Added CA {alias} to truststore")

self.charm.on_new_ca_added()
return True

Expand Down
Loading

0 comments on commit 7b77bc1

Please sign in to comment.