Skip to content

Commit 4779785

Browse files
[DPE-3421] Switch to self signed certificates (#379)
* Update TLS tests to use Self Signed Certificates operator Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Update backup tests to use Self Signed Certificates operator Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Remove unused config options Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 264058f commit 4779785

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

poetry.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/test_backups.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121
scale_application,
2222
wait_for_idle_on_blocked,
2323
)
24+
from .juju_ import juju_major_version
2425

2526
ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE = "the S3 repository has backups from another cluster"
2627
FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE = (
2728
"failed to access/create the bucket, check your S3 settings"
2829
)
2930
FAILED_TO_INITIALIZE_STANZA_ERROR_MESSAGE = "failed to initialize stanza, check your S3 settings"
3031
S3_INTEGRATOR_APP_NAME = "s3-integrator"
31-
TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
32+
if juju_major_version < 3:
33+
TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
34+
TLS_CHANNEL = "legacy/stable"
35+
TLS_CONFIG = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"}
36+
else:
37+
TLS_CERTIFICATES_APP_NAME = "self-signed-certificates"
38+
TLS_CHANNEL = "latest/stable"
39+
TLS_CONFIG = {"ca-common-name": "Test CA"}
3240

3341
logger = logging.getLogger(__name__)
3442

@@ -92,8 +100,7 @@ async def test_backup_and_restore(ops_test: OpsTest, cloud_configs: Tuple[Dict,
92100
"""Build and deploy two units of PostgreSQL and then test the backup and restore actions."""
93101
# Deploy S3 Integrator and TLS Certificates Operator.
94102
await ops_test.model.deploy(S3_INTEGRATOR_APP_NAME)
95-
config = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"}
96-
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, config=config, channel="legacy/stable")
103+
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, config=TLS_CONFIG, channel=TLS_CHANNEL)
97104

98105
for cloud, config in cloud_configs[0].items():
99106
# Deploy and relate PostgreSQL to S3 integrator (one database app for each cloud for now

tests/integration/test_tls.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pytest_operator.plugin import OpsTest
99
from tenacity import Retrying, stop_after_delay, wait_fixed
1010

11-
from . import markers
1211
from .helpers import (
1312
DATABASE_APP_NAME,
1413
build_and_deploy,
@@ -24,12 +23,19 @@
2423
primary_changed,
2524
run_command_on_unit,
2625
)
26+
from .juju_ import juju_major_version
2727

2828
logger = logging.getLogger(__name__)
2929

3030
MATTERMOST_APP_NAME = "mattermost"
31-
SELF_SIGNED_CERTIFICATES_APP_NAME = "self-signed-certificates"
32-
TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
31+
if juju_major_version < 3:
32+
TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
33+
TLS_CHANNEL = "legacy/stable"
34+
TLS_CONFIG = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"}
35+
else:
36+
TLS_CERTIFICATES_APP_NAME = "self-signed-certificates"
37+
TLS_CHANNEL = "latest/stable"
38+
TLS_CONFIG = {"ca-common-name": "Test CA"}
3339
APPLICATION_UNITS = 2
3440
DATABASE_UNITS = 3
3541

@@ -72,9 +78,8 @@ async def test_mattermost_db(ops_test: OpsTest) -> None:
7278
"""
7379
async with ops_test.fast_forward():
7480
# Deploy TLS Certificates operator.
75-
config = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"}
7681
await ops_test.model.deploy(
77-
TLS_CERTIFICATES_APP_NAME, config=config, channel="legacy/stable"
82+
TLS_CERTIFICATES_APP_NAME, config=TLS_CONFIG, channel=TLS_CHANNEL
7883
)
7984
# Relate it to the PostgreSQL to enable TLS.
8085
await ops_test.model.relate(DATABASE_APP_NAME, TLS_CERTIFICATES_APP_NAME)
@@ -171,20 +176,3 @@ async def test_mattermost_db(ops_test: OpsTest) -> None:
171176
for unit in ops_test.model.applications[DATABASE_APP_NAME].units:
172177
assert await check_tls(ops_test, unit.name, enabled=False)
173178
assert await check_tls_patroni_api(ops_test, unit.name, enabled=False)
174-
175-
176-
@markers.juju3
177-
@pytest.mark.group(1)
178-
async def test_relation_with_self_signed_certificates_operator(ops_test: OpsTest) -> None:
179-
"""Test the relation with the Self Signed Certificates operator."""
180-
async with ops_test.fast_forward(fast_interval="60s"):
181-
# Deploy Self Signed Certificates operator.
182-
await ops_test.model.deploy(SELF_SIGNED_CERTIFICATES_APP_NAME)
183-
# Relate it to the PostgreSQL to enable TLS.
184-
await ops_test.model.relate(DATABASE_APP_NAME, SELF_SIGNED_CERTIFICATES_APP_NAME)
185-
await ops_test.model.wait_for_idle(status="active", timeout=1500)
186-
187-
# Wait for all units enabling TLS.
188-
for unit in ops_test.model.applications[DATABASE_APP_NAME].units:
189-
assert await check_tls(ops_test, unit.name, enabled=True)
190-
assert await check_tls_patroni_api(ops_test, unit.name, enabled=True)

0 commit comments

Comments
 (0)