-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add TLS Requirer to integration tests
- Loading branch information
Showing
3 changed files
with
71 additions
and
44 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
|
||
import logging | ||
from pathlib import Path | ||
|
||
import pytest | ||
import yaml | ||
from pytest_operator.plugin import OpsTest | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text()) | ||
APP_NAME = METADATA["name"] | ||
|
||
TLS_REQUIRER_CHARM_NAME = "tls-certificates-requirer" | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
@pytest.mark.abort_on_fail | ||
async def build_and_deploy(ops_test: OpsTest): | ||
"""Build the charm-under-test and deploy it.""" | ||
charm = await ops_test.build_charm(".") | ||
resources = {"lego-image": METADATA["resources"]["lego-image"]["upstream-source"]} | ||
assert ops_test.model | ||
await ops_test.model.deploy( | ||
charm, | ||
resources=resources, | ||
application_name=APP_NAME, | ||
series="jammy", | ||
config={ | ||
"email": "example@email.com", | ||
"httpreq_endpoint": "http://dummy.url.com", | ||
}, | ||
) | ||
await ops_test.model.deploy( | ||
TLS_REQUIRER_CHARM_NAME, | ||
application_name=TLS_REQUIRER_CHARM_NAME, | ||
channel="edge", | ||
) | ||
|
||
|
||
@pytest.mark.abort_on_fail | ||
async def test_given_charm_is_built_when_deployed_then_status_is_active( | ||
ops_test: OpsTest, | ||
build_and_deploy, | ||
): | ||
assert ops_test.model | ||
await ops_test.model.wait_for_idle( | ||
apps=[APP_NAME], | ||
status="active", | ||
timeout=1000, | ||
) | ||
|
||
|
||
async def test_given_tls_requirer_is_deployed_and_related_then_status_is_active( | ||
ops_test: OpsTest, | ||
build_and_deploy, | ||
): | ||
assert ops_test.model | ||
await ops_test.model.add_relation( | ||
relation1=f"{APP_NAME}:certificates", relation2=f"{TLS_REQUIRER_CHARM_NAME}" | ||
) | ||
await ops_test.model.wait_for_idle( | ||
apps=[TLS_REQUIRER_CHARM_NAME], | ||
status="active", | ||
timeout=1000, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters