Skip to content

Commit

Permalink
[MISC] Fix secret keys (#148)
Browse files Browse the repository at this point in the history
* Fix secret keys

* Update secrets loop
  • Loading branch information
dragomirp authored Feb 8, 2024
1 parent c608b55 commit 3d3630a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def __init__(self, *args):
self,
relation_name=PEER_RELATION_NAME,
additional_secret_fields=[
AUTH_FILE_DATABAG_KEY,
CFG_FILE_DATABAG_KEY,
MONITORING_PASSWORD_KEY,
self._translate_field_to_secret_key(AUTH_FILE_DATABAG_KEY),
self._translate_field_to_secret_key(CFG_FILE_DATABAG_KEY),
self._translate_field_to_secret_key(MONITORING_PASSWORD_KEY),
],
secret_field_name=SECRET_INTERNAL_LABEL,
deleted_label=SECRET_DELETED_LABEL,
Expand Down
1 change: 0 additions & 1 deletion src/relations/peers.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def _on_changed(self, event: RelationChangedEvent):
event.defer()
return

self.update_cfg(cfg)
self.app_databag[LEADER_ADDRESS_KEY] = self.charm.unit_ip
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from juju.errors import JujuAPIError
from pytest_operator.plugin import OpsTest

from constants import BACKEND_RELATION_NAME
from constants import BACKEND_RELATION_NAME, PEER_RELATION_NAME
from tests.integration.helpers.helpers import (
CLIENT_APP_NAME,
FIRST_DATABASE_RELATION_NAME,
Expand Down Expand Up @@ -81,7 +81,7 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest, pgb_cha
# Check that on juju 3 we have secrets and no username and password in the rel databag
if hasattr(ops_test.model, "list_secrets"):
logger.info("checking for secrets")
secret_uri, password = await asyncio.gather(
secret_uri, password, auth_file = await asyncio.gather(
get_application_relation_data(
ops_test,
CLIENT_APP_NAME,
Expand All @@ -94,9 +94,16 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest, pgb_cha
FIRST_DATABASE_RELATION_NAME,
"password",
),
get_application_relation_data(
ops_test,
PGB,
PEER_RELATION_NAME,
"auth_file",
),
)
assert secret_uri is not None
assert password is None
assert auth_file is None


@pytest.mark.group(1)
Expand Down

0 comments on commit 3d3630a

Please sign in to comment.