Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-seijas committed Mar 19, 2024
1 parent 455ba10 commit 42ee333
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
20 changes: 20 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,23 @@ async def app(
await ops_test.model.wait_for_idle(status="active", raise_on_error=False)

yield application


@pytest_asyncio.fixture(scope="module", name="saml_integrator")
async def saml_integrator_fixture(ops_test: OpsTest):
"""SAML integrator charm used for integration testing.
Builds the charm and deploys it.
"""
assert ops_test.model
saml_config = {
"metadata_url": "https://login.staging.ubuntu.com/saml/metadata",
"entity_id": "https://login.staging.ubuntu.com",
}
saml_integrator = await ops_test.model.deploy(
"saml-integrator", channel="latest/stable", config=saml_config, trust=True
)
await ops_test.model.wait_for_idle(
apps=[saml_integrator.name], status="active", raise_on_error=False
)
yield saml_integrator
17 changes: 6 additions & 11 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,22 @@ async def test_anonymize_user_fail(app: Application):

@pytest.mark.asyncio
@pytest.mark.abort_on_fail
async def test_saml_auth(
async def test_saml_auth( # pylint: disable=too-many-arguments
ops_test: OpsTest,
app: Application,
saml_email: str,
saml_password: str,
requests_timeout: float,
saml_integrator: Application,
):
"""
arrange: given charm in its initial state
act: configure a SAML target url and fire SAML authentication
act: configure and integrate the SAML integrator fire SAML authentication
assert: The SAML authentication process is executed successfully.
"""
# The linter does not recognize set_config as a method, so this errors must be ignored.
await app.set_config( # type: ignore[attr-defined] # pylint: disable=W0106
{
"site_url": "https://events.staging.canonical.com",
}
)
# The linter does not recognize wait_for_idle as a method,
# since ops_test has a model as Optional, so this error must be ignored.
await ops_test.model.wait_for_idle(status="active") # type: ignore[union-attr]
assert ops_test.model
ops_test.model.add_relation(app.name, saml_integrator.name)
await ops_test.model.wait_for_idle(status="active")
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

host = "events.staging.canonical.com"
Expand Down

0 comments on commit 42ee333

Please sign in to comment.