From ffb80995d4342a1084858796446c2bdcabf91cf4 Mon Sep 17 00:00:00 2001 From: Kian Parvin Date: Mon, 3 Jul 2023 14:41:26 +0200 Subject: [PATCH] Minor tweaks --- charms/jimm-k8s/config.yaml | 6 - charms/jimm-k8s/src/charm.py | 3 - .../jimm-k8s/tests/integration/test_charm.py | 3 - .../tests/integration/test_upgrade.py | 228 +++++++++--------- charms/jimm-k8s/tests/unit/test_charm.py | 16 -- charms/jimm-k8s/tox.ini | 2 +- charms/jimm/config.yaml | 6 - charms/jimm/requirements-dev.txt | 2 +- charms/jimm/requirements.txt | 2 +- charms/jimm/src/charm.py | 8 +- charms/jimm/templates/jimm-leader.env | 1 - charms/jimm/templates/jimm.env | 6 - charms/jimm/tests/test_charm.py | 48 +--- charms/jimm/tox.ini | 3 +- 14 files changed, 122 insertions(+), 212 deletions(-) diff --git a/charms/jimm-k8s/config.yaml b/charms/jimm-k8s/config.yaml index b718056a1..d1e098730 100644 --- a/charms/jimm-k8s/config.yaml +++ b/charms/jimm-k8s/config.yaml @@ -54,12 +54,6 @@ options: type: string default: https://jaas.ai/models description: URL of the Juju Dashboard for this controller. - public-key: - type: string - description: The public part of JIMM's macaroon bakery keypair. - private-key: - type: string - description: The private part of JIMM's macaroon bakery keypair. dns-name: type: string description: DNS hostname that JIMM is being served from. diff --git a/charms/jimm-k8s/src/charm.py b/charms/jimm-k8s/src/charm.py index 7cc26bcdf..add01d2b1 100755 --- a/charms/jimm-k8s/src/charm.py +++ b/charms/jimm-k8s/src/charm.py @@ -230,8 +230,6 @@ def _update_workload(self, event): "JIMM_UUID": self.config.get("uuid", ""), "JIMM_DASHBOARD_LOCATION": self.config.get("juju-dashboard-location", "https://jaas.ai/models"), "JIMM_LISTEN_ADDR": ":8080", - "PRIVATE_KEY": self.config.get("private-key", ""), - "PUBLIC_KEY": self.config.get("public-key", ""), } if self._state.dsn: config_values["JIMM_DSN"] = self._state.dsn @@ -247,7 +245,6 @@ def _update_workload(self, event): if self.model.unit.is_leader(): config_values["JIMM_WATCH_CONTROLLERS"] = "1" - config_values["JIMM_ENABLE_JWKS_ROTATOR"] = "1" if container.exists(self._dashboard_path): config_values["JIMM_DASHBOARD_LOCATION"] = self._dashboard_path diff --git a/charms/jimm-k8s/tests/integration/test_charm.py b/charms/jimm-k8s/tests/integration/test_charm.py index 73fd89bcc..2760200f2 100644 --- a/charms/jimm-k8s/tests/integration/test_charm.py +++ b/charms/jimm-k8s/tests/integration/test_charm.py @@ -40,9 +40,6 @@ async def test_build_and_deploy(ops_test: OpsTest, local_charm): config={ "uuid": "f4dec11e-e2b6-40bb-871a-cc38e958af49", "candid-url": "https://api.jujucharms.com/identity", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - "dns-name": "jimm.test.canonical.com", }, ) await ops_test.model.deploy( diff --git a/charms/jimm-k8s/tests/integration/test_upgrade.py b/charms/jimm-k8s/tests/integration/test_upgrade.py index 2fd1db726..349c5e47b 100644 --- a/charms/jimm-k8s/tests/integration/test_upgrade.py +++ b/charms/jimm-k8s/tests/integration/test_upgrade.py @@ -1,117 +1,111 @@ -# NOTE (alesstimec) This test is commented out until we have -# released juju-jimm-k8s to v1/edge -# #!/usr/bin/env python3 -# # Copyright 2022 Canonical Ltd -# # See LICENSE file for licensing details. - -# import asyncio -# import logging -# import time -# from pathlib import Path - -# import pytest -# import utils -# import yaml -# from juju.action import Action -# from pytest_operator.plugin import OpsTest - -# logger = logging.getLogger(__name__) - -# METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) -# APP_NAME = "juju-jimm-k8s" - - -# @pytest.mark.abort_on_fail -# async def test_upgrade_running_application(ops_test: OpsTest, local_charm): -# """Deploy latest published charm and upgrade it with charm-under-test. - -# Assert on the application status and health check endpoint after upgrade/refresh took place. -# """ - -# # Deploy the charm and wait for active/idle status -# logger.debug("deploying charms") -# await ops_test.model.deploy( -# METADATA["name"], -# channel="edge", -# application_name=APP_NAME, -# series="focal", -# config={ -# "uuid": "f4dec11e-e2b6-40bb-871a-cc38e958af49", -# "candid-url": "https://api.jujucharms.com/identity", -# "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", -# "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", -# }, -# ) -# await ops_test.model.deploy( -# "traefik-k8s", -# application_name="traefik", -# config={ -# "external_hostname": "traefik.test.canonical.com", -# }, -# ) -# await asyncio.gather( -# ops_test.model.deploy("postgresql-k8s", application_name="postgresql", channel="14/stable", trust=True), -# ) - -# logger.info("waiting for postgresql and traefik") -# await ops_test.model.wait_for_idle( -# apps=["postgresql", "traefik"], -# status="active", -# raise_on_blocked=True, -# timeout=40000, -# ) - -# logger.info("adding traefik relation") -# await ops_test.model.relate("{}:ingress".format(APP_NAME), "traefik") - -# logger.info("adding postgresql relation") -# await ops_test.model.relate(APP_NAME, "postgresql:database") - -# logger.info("waiting for jimm") -# await ops_test.model.wait_for_idle( -# apps=[APP_NAME], -# status="active", -# # raise_on_blocked=True, -# timeout=40000, -# ) - -# assert ops_test.model.applications[APP_NAME].status == "active" - -# # Starting upgrade/refresh -# logger.info("starting upgrade test") - -# # Build and deploy charm from local source folder -# logger.info("building local charm") - -# # (Optionally build) and deploy charm from local source folder -# if local_charm: -# charm = Path(utils.get_local_charm()).resolve() -# else: -# charm = await ops_test.build_charm(".") -# resources = {"jimm-image": "localhost:32000/jimm:latest"} - -# # Deploy the charm and wait for active/idle status -# logger.info("refreshing running application with the new local charm") - -# await ops_test.model.applications[APP_NAME].refresh( -# path=charm, -# resources=resources, -# ) - -# logger.info("waiting for the upgraded unit to be ready") -# async with ops_test.fast_forward(): -# await ops_test.model.wait_for_idle( -# apps=[APP_NAME], -# status="active", -# timeout=60, -# ) - -# assert ops_test.model.applications[APP_NAME].status == "active" - -# logger.info("checking status of the running unit") -# upgraded_jimm_unit = await utils.get_unit_by_name(APP_NAME, "0", ops_test.model.units) - -# health = await upgraded_jimm_unit.run("curl -i http://localhost:8080/debug/status") -# await health.wait() -# assert health.results.get("return-code") == 0 -# assert health.results.get("stdout").strip().splitlines()[0].endswith("200 OK") +#!/usr/bin/env python3 +# Copyright 2022 Canonical Ltd +# See LICENSE file for licensing details. + +import asyncio +import logging +from pathlib import Path + +import pytest +import utils +import yaml +from pytest_operator.plugin import OpsTest + +logger = logging.getLogger(__name__) + +METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) +APP_NAME = "juju-jimm-k8s" + + +@pytest.mark.abort_on_fail +async def test_upgrade_running_application(ops_test: OpsTest, local_charm): + """Deploy latest published charm and upgrade it with charm-under-test. + + Assert on the application status and health check endpoint after upgrade/refresh took place. + """ + + # Deploy the charm and wait for active/idle status + logger.debug("deploying charms") + await ops_test.model.deploy( + METADATA["name"], + channel="edge", + application_name=APP_NAME, + series="focal", + config={ + "uuid": "f4dec11e-e2b6-40bb-871a-cc38e958af49", + "candid-url": "https://api.jujucharms.com/identity", + }, + ) + await ops_test.model.deploy( + "traefik-k8s", + application_name="traefik", + config={ + "external_hostname": "traefik.test.canonical.com", + }, + ) + await asyncio.gather( + ops_test.model.deploy("postgresql-k8s", application_name="postgresql", channel="14/stable", trust=True), + ) + + logger.info("waiting for postgresql and traefik") + await ops_test.model.wait_for_idle( + apps=["postgresql", "traefik"], + status="active", + raise_on_blocked=True, + timeout=40000, + ) + + logger.info("adding traefik relation") + await ops_test.model.relate("{}:ingress".format(APP_NAME), "traefik") + + logger.info("adding postgresql relation") + await ops_test.model.relate(APP_NAME, "postgresql:database") + + logger.info("waiting for jimm") + await ops_test.model.wait_for_idle( + apps=[APP_NAME], + status="active", + # raise_on_blocked=True, + timeout=40000, + ) + + assert ops_test.model.applications[APP_NAME].status == "active" + + # Starting upgrade/refresh + logger.info("starting upgrade test") + + # Build and deploy charm from local source folder + logger.info("building local charm") + + # (Optionally build) and deploy charm from local source folder + if local_charm: + charm = Path(utils.get_local_charm()).resolve() + else: + charm = await ops_test.build_charm(".") + resources = {"jimm-image": "localhost:32000/jimm:latest"} + + # Deploy the charm and wait for active/idle status + logger.info("refreshing running application with the new local charm") + + await ops_test.model.applications[APP_NAME].refresh( + path=charm, + resources=resources, + ) + + logger.info("waiting for the upgraded unit to be ready") + async with ops_test.fast_forward(): + await ops_test.model.wait_for_idle( + apps=[APP_NAME], + status="active", + timeout=60, + ) + + assert ops_test.model.applications[APP_NAME].status == "active" + + logger.info("checking status of the running unit") + upgraded_jimm_unit = await utils.get_unit_by_name(APP_NAME, "0", ops_test.model.units) + + health = await upgraded_jimm_unit.run("curl -i http://localhost:8080/debug/status") + await health.wait() + assert health.results.get("return-code") == 0 + assert health.results.get("stdout").strip().splitlines()[0].endswith("200 OK") diff --git a/charms/jimm-k8s/tests/unit/test_charm.py b/charms/jimm-k8s/tests/unit/test_charm.py index 44950da1e..c5312aab5 100644 --- a/charms/jimm-k8s/tests/unit/test_charm.py +++ b/charms/jimm-k8s/tests/unit/test_charm.py @@ -19,8 +19,6 @@ MINIMAL_CONFIG = { "uuid": "1234567890", "candid-url": "test-candid-url", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } @@ -73,13 +71,10 @@ def test_on_pebble_ready(self): "CANDID_URL": "test-candid-url", "JIMM_DASHBOARD_LOCATION": "https://jaas.ai/models", "JIMM_DNS_NAME": "juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local", - "JIMM_ENABLE_JWKS_ROTATOR": "1", "JIMM_LISTEN_ADDR": ":8080", "JIMM_LOG_LEVEL": "info", "JIMM_UUID": "1234567890", "JIMM_WATCH_CONTROLLERS": "1", - "PRIVATE_KEY": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - "PUBLIC_KEY": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", }, } } @@ -111,13 +106,10 @@ def test_on_config_changed(self): "CANDID_URL": "test-candid-url", "JIMM_DASHBOARD_LOCATION": "https://jaas.ai/models", "JIMM_DNS_NAME": "juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local", - "JIMM_ENABLE_JWKS_ROTATOR": "1", "JIMM_LISTEN_ADDR": ":8080", "JIMM_LOG_LEVEL": "info", "JIMM_UUID": "1234567890", "JIMM_WATCH_CONTROLLERS": "1", - "PRIVATE_KEY": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - "PUBLIC_KEY": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", }, } } @@ -135,8 +127,6 @@ def test_bakery_configuration(self): "candid-agent-username": "test-username", "candid-agent-public-key": "test-public-key", "candid-agent-private-key": "test-private-key", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) @@ -159,13 +149,10 @@ def test_bakery_configuration(self): "CANDID_URL": "test-candid-url", "JIMM_DASHBOARD_LOCATION": "https://jaas.ai/models", "JIMM_DNS_NAME": "juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local", - "JIMM_ENABLE_JWKS_ROTATOR": "1", "JIMM_LISTEN_ADDR": ":8080", "JIMM_LOG_LEVEL": "info", "JIMM_UUID": "1234567890", "JIMM_WATCH_CONTROLLERS": "1", - "PRIVATE_KEY": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - "PUBLIC_KEY": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", }, } } @@ -210,12 +197,9 @@ def test_install_dashboard(self, exec): "JIMM_LISTEN_ADDR": ":8080", "JIMM_DASHBOARD_LOCATION": "/root/dashboard", "JIMM_DNS_NAME": "juju-jimm-k8s-0.juju-jimm-k8s-endpoints.None.svc.cluster.local", - "JIMM_ENABLE_JWKS_ROTATOR": "1", "JIMM_LOG_LEVEL": "info", "JIMM_UUID": "1234567890", "JIMM_WATCH_CONTROLLERS": "1", - "PRIVATE_KEY": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - "PUBLIC_KEY": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", }, } } diff --git a/charms/jimm-k8s/tox.ini b/charms/jimm-k8s/tox.ini index c273f9130..6da1feda6 100644 --- a/charms/jimm-k8s/tox.ini +++ b/charms/jimm-k8s/tox.ini @@ -61,7 +61,7 @@ commands = [testenv:integration] description = Run integration tests deps = - juju~=3.2 + juju~=2.9 pytest pytest-operator -r{toxinidir}/requirements.txt diff --git a/charms/jimm/config.yaml b/charms/jimm/config.yaml index 7830e230e..96fd29ee0 100644 --- a/charms/jimm/config.yaml +++ b/charms/jimm/config.yaml @@ -54,9 +54,3 @@ options: type: string default: https://jaas.ai/models description: URL of the Juju Dashboard for this controller. - public-key: - type: string - description: The public part of JIMM's macaroon bakery keypair. - private-key: - type: string - description: The private part of JIMM's macaroon bakery keypair. diff --git a/charms/jimm/requirements-dev.txt b/charms/jimm/requirements-dev.txt index 9d03b1b37..4f2a3f5bc 100644 --- a/charms/jimm/requirements-dev.txt +++ b/charms/jimm/requirements-dev.txt @@ -1,3 +1,3 @@ -r requirements.txt coverage -flake8 \ No newline at end of file +flake8 diff --git a/charms/jimm/requirements.txt b/charms/jimm/requirements.txt index 7a3aaa94e..b7e096739 100644 --- a/charms/jimm/requirements.txt +++ b/charms/jimm/requirements.txt @@ -3,5 +3,5 @@ Jinja2 >= 2.11.3 ops >= 1.4.0 charmhelpers >= 0.20.22 hvac >= 0.11.0 -pydantic == 1.10 +pydantic == 1.10.10 cosl diff --git a/charms/jimm/src/charm.py b/charms/jimm/src/charm.py index 27ad27dd5..2241bd0f9 100755 --- a/charms/jimm/src/charm.py +++ b/charms/jimm/src/charm.py @@ -126,15 +126,12 @@ def _on_config_changed(self, _): "log_level": self.config.get("log-level"), "uuid": self.config.get("uuid"), "dashboard_location": self.config.get("juju-dashboard-location"), - "public_key": self.config.get("public-key"), - "private_key": self.config.get("private-key"), } if os.path.exists(self._dashboard_path): args["dashboard_location"] = self._dashboard_path with open(self._env_filename(), "wt") as f: f.write(self._render_template("jimm.env", **args)) - if self._ready(): self.restart() self._on_update_status(None) @@ -143,7 +140,7 @@ def _on_config_changed(self, _): if dashboard_relation: dashboard_relation.data[self.app].update( { - "controller-url": "wss://{}".format(self.config["dns-name"]), + "controller-url": self.config["dns-name"], "identity-provider-url": self.config["candid-url"], "is-juju": str(False), } @@ -156,7 +153,6 @@ def _on_leader_elected(self, _): args = {"jimm_watch_controllers": ""} if self.model.unit.is_leader(): args["jimm_watch_controllers"] = "1" - args["jimm_enable_jwks_rotator"] = "1" with open(self._env_filename("leader"), "wt") as f: f.write(self._render_template("jimm-leader.env", **args)) if self._ready(): @@ -390,7 +386,7 @@ def _snap(self, *args): def _on_dashboard_relation_joined(self, event): event.relation.data[self.app].update( { - "controller-url": "wss://{}".format(self.config["dns-name"]), + "controller-url": self.config["dns-name"], "identity-provider-url": self.config["candid-url"], "is-juju": str(False), } diff --git a/charms/jimm/templates/jimm-leader.env b/charms/jimm/templates/jimm-leader.env index 5877e3758..f15c27c8c 100644 --- a/charms/jimm/templates/jimm-leader.env +++ b/charms/jimm/templates/jimm-leader.env @@ -1,2 +1 @@ JIMM_WATCH_CONTROLLERS={{jimm_watch_controllers}} -JIMM_ENABLE_JWKS_ROTATOR={{jimm_enable_jwks_rotator}} diff --git a/charms/jimm/templates/jimm.env b/charms/jimm/templates/jimm.env index 21570c6ab..015d2da6b 100644 --- a/charms/jimm/templates/jimm.env +++ b/charms/jimm/templates/jimm.env @@ -9,9 +9,3 @@ JIMM_DNS_NAME={{dns_name}} {% endif %} JIMM_LOG_LEVEL={{log_level}} JIMM_UUID={{uuid}} -{% if private_key %} -PRIVATE_KEY={{private_key}} -{% endif %} -{% if public_key %} -PUBLIC_KEY={{public_key}} -{% endif %} \ No newline at end of file diff --git a/charms/jimm/tests/test_charm.py b/charms/jimm/tests/test_charm.py index 2dd31bc67..49a3dd896 100644 --- a/charms/jimm/tests/test_charm.py +++ b/charms/jimm/tests/test_charm.py @@ -138,15 +138,13 @@ def test_config_changed(self): "dns-name": "jimm.example.com", "log-level": "debug", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) self.assertTrue(os.path.exists(config_file)) with open(config_file) as f: lines = f.readlines() os.unlink(config_file) - self.assertEqual(len(lines), 16) + self.assertEqual(len(lines), 11) self.assertEqual(lines[0].strip(), "BAKERY_AGENT_FILE=") self.assertEqual(lines[1].strip(), "CANDID_URL=https://candid.example.com") self.assertEqual(lines[2].strip(), "JIMM_ADMINS=user1 user2 group1") @@ -157,14 +155,6 @@ def test_config_changed(self): self.assertEqual(lines[7].strip(), "JIMM_DNS_NAME=" + "jimm.example.com") self.assertEqual(lines[9].strip(), "JIMM_LOG_LEVEL=debug") self.assertEqual(lines[10].strip(), "JIMM_UUID=caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa") - self.assertEqual( - lines[12].strip(), - "PRIVATE_KEY=ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - ) - self.assertEqual( - lines[15].strip(), - "PUBLIC_KEY=izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - ) def test_config_changed_redirect_to_dashboard(self): config_file = os.path.join(self.harness.charm.charm_dir, "juju-jimm.env") @@ -176,15 +166,13 @@ def test_config_changed_redirect_to_dashboard(self): "log-level": "debug", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", "juju-dashboard-location": "https://test.jaas.ai/models", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) self.assertTrue(os.path.exists(config_file)) with open(config_file) as f: lines = f.readlines() os.unlink(config_file) - self.assertEqual(len(lines), 16) + self.assertEqual(len(lines), 11) self.assertEqual(lines[0].strip(), "BAKERY_AGENT_FILE=") self.assertEqual(lines[1].strip(), "CANDID_URL=https://candid.example.com") self.assertEqual(lines[2].strip(), "JIMM_ADMINS=user1 user2 group1") @@ -195,14 +183,6 @@ def test_config_changed_redirect_to_dashboard(self): self.assertEqual(lines[7].strip(), "JIMM_DNS_NAME=" + "jimm.example.com") self.assertEqual(lines[9].strip(), "JIMM_LOG_LEVEL=debug") self.assertEqual(lines[10].strip(), "JIMM_UUID=caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa") - self.assertEqual( - lines[12].strip(), - "PRIVATE_KEY=ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - ) - self.assertEqual( - lines[15].strip(), - "PUBLIC_KEY=izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - ) def test_config_changed_ready(self): config_file = os.path.join(self.harness.charm.charm_dir, "juju-jimm.env") @@ -214,15 +194,13 @@ def test_config_changed_ready(self): "candid-url": "https://candid.example.com", "controller-admins": "user1 user2 group1", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) self.assertTrue(os.path.exists(config_file)) with open(config_file) as f: lines = f.readlines() os.unlink(config_file) - self.assertEqual(len(lines), 14) + self.assertEqual(len(lines), 9) self.assertEqual(lines[0].strip(), "BAKERY_AGENT_FILE=") self.assertEqual(lines[1].strip(), "CANDID_URL=https://candid.example.com") self.assertEqual(lines[2].strip(), "JIMM_ADMINS=user1 user2 group1") @@ -232,14 +210,6 @@ def test_config_changed_ready(self): ) self.assertEqual(lines[7].strip(), "JIMM_LOG_LEVEL=info") self.assertEqual(lines[8].strip(), "JIMM_UUID=caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa") - self.assertEqual( - lines[10].strip(), - "PRIVATE_KEY=ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", - ) - self.assertEqual( - lines[13].strip(), - "PUBLIC_KEY=izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - ) def test_config_changed_with_agent(self): config_file = os.path.join(self.harness.charm.charm_dir, "juju-jimm.env") @@ -252,8 +222,6 @@ def test_config_changed_with_agent(self): "candid-url": "https://candid.example.com", "controller-admins": "user1 user2 group1", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) self.assertTrue(os.path.exists(self.harness.charm._agent_filename)) @@ -266,7 +234,7 @@ def test_config_changed_with_agent(self): with open(config_file) as f: lines = f.readlines() - self.assertEqual(len(lines), 14) + self.assertEqual(len(lines), 9) self.assertEqual( lines[0].strip(), "BAKERY_AGENT_FILE=" + self.harness.charm._agent_filename, @@ -286,13 +254,11 @@ def test_config_changed_with_agent(self): "candid-url": "https://candid.example.com", "controller-admins": "user1 user2 group1", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) with open(config_file) as f: lines = f.readlines() - self.assertEqual(len(lines), 14) + self.assertEqual(len(lines), 9) self.assertEqual(lines[0].strip(), "BAKERY_AGENT_FILE=") self.assertEqual(lines[1].strip(), "CANDID_URL=https://candid.example.com") self.assertEqual(lines[2].strip(), "JIMM_ADMINS=user1 user2 group1") @@ -306,12 +272,10 @@ def test_leader_elected(self): with open(leader_file) as f: lines = f.readlines() self.assertEqual(lines[0].strip(), "JIMM_WATCH_CONTROLLERS=") - self.assertEqual(lines[1].strip(), "JIMM_ENABLE_JWKS_ROTATOR=") self.harness.set_leader(True) with open(leader_file) as f: lines = f.readlines() self.assertEqual(lines[0].strip(), "JIMM_WATCH_CONTROLLERS=1") - self.assertEqual(lines[1].strip(), "JIMM_ENABLE_JWKS_ROTATOR=1") def test_leader_elected_ready(self): leader_file = os.path.join(self.harness.charm.charm_dir, "juju-jimm-leader.env") @@ -517,8 +481,6 @@ def test_dashboard_relation_joined(self): "candid-url": "https://candid.example.com", "controller-admins": "user1 user2 group1", "uuid": "caaa4ba4-e2b5-40dd-9bf3-2bd26d6e17aa", - "public-key": "izcYsQy3TePp6bLjqOo3IRPFvkQd2IKtyODGqC6SdFk=", - "private-key": "ly/dzsI9Nt/4JxUILQeAX79qZ4mygDiuYGqc2ZEiDEc=", } ) diff --git a/charms/jimm/tox.ini b/charms/jimm/tox.ini index eb08ed4aa..990e26519 100644 --- a/charms/jimm/tox.ini +++ b/charms/jimm/tox.ini @@ -9,7 +9,6 @@ envlist = lint, unit [vars] src_path = {toxinidir}/src/ tst_path = {toxinidir}/tests/ -;lib_path = {toxinidir}/lib/charms/operator_name_with_underscores all_path = {[vars]src_path} {[vars]tst_path} [testenv] @@ -62,7 +61,7 @@ commands = description = Run integration tests deps = pytest - juju~=3.2 + juju pytest-operator -r{toxinidir}/requirements.txt commands =