From 52d9410f4331636c42d71b03b26268972c51c76e Mon Sep 17 00:00:00 2001 From: Smail KOURTA Date: Mon, 30 Sep 2024 07:21:48 +0000 Subject: [PATCH] incremented libpatch and added unit test for get_secret_id --- .../v0/opensearch_relation_peer_cluster.py | 2 +- tests/unit/lib/test_opensearch_secrets.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py b/lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py index f32e4acb3..b6426e214 100644 --- a/lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py +++ b/lib/charms/opensearch/v0/opensearch_relation_peer_cluster.py @@ -65,7 +65,7 @@ # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 1 +LIBPATCH = 2 class OpenSearchPeerClusterRelation(Object): diff --git a/tests/unit/lib/test_opensearch_secrets.py b/tests/unit/lib/test_opensearch_secrets.py index d84b559df..402686f0e 100644 --- a/tests/unit/lib/test_opensearch_secrets.py +++ b/tests/unit/lib/test_opensearch_secrets.py @@ -185,3 +185,15 @@ def test_bad_label(self): @parameterized.expand([Scope.APP, Scope.UNIT]) def test_put_and_get_complex_obj(self, scope): return + + def test_get_secret_id(self): + # add a secret to the store + content = {"secret": "value"} + self.store.put(Scope.APP, "super-secret-key", content) + # get the secret id + secret_id = self.store.get_secret_id(Scope.APP, "super-secret-key") + self.assertIsNotNone(secret_id) + # check the secret content + secret = self.charm.model.get_secret(id=secret_id) + secret_content = secret.get_content() + self.assertDictEqual(secret_content, {"super-secret-key": str(content)})