Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix the integration test due to the juju secret id breaking changes #72

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.

import functools
import re
from contextlib import contextmanager
from pathlib import Path
from typing import Callable, Optional
Expand All @@ -24,6 +25,7 @@
GLAUTH_APP = METADATA["name"]
GLAUTH_IMAGE = METADATA["resources"]["oci-image"]["upstream-source"]
GLAUTH_CLIENT_APP = "any-charm"
JUJU_SECRET_ID_REGEX = re.compile(r"secret:(?://[a-f0-9-]+/)?(?P<secret_id>[a-zA-Z0-9]+)")


@contextmanager
Expand Down Expand Up @@ -129,8 +131,10 @@ async def ldap_configurations(
bind_dn = ldap_integration_data["bind_dn"]
bind_password_secret: str = ldap_integration_data["bind_password_secret"]

prefix, _, secret_id = bind_password_secret.partition(":")
bind_password = await get_secret(ops_test, secret_id or prefix)
matched = JUJU_SECRET_ID_REGEX.match(bind_password_secret)
assert matched is not None, "bind password secret id should be valid"

bind_password = await get_secret(ops_test, matched.group("secret_id"))

return base_dn, bind_dn, bind_password["content"]["password"]

Expand Down