From 33fceee36922d0358b4c07878233438a8cfe5e7b Mon Sep 17 00:00:00 2001 From: javierdelapuente Date: Thu, 16 Jan 2025 12:54:54 +0100 Subject: [PATCH] Use new security mechanism based on environment variables (#435) * Use new security mechanism based on environment variables --- tests/integration/conftest.py | 6 ++++-- tox.ini | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 672d5d79..86a896a5 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -3,6 +3,7 @@ """Fixtures for github runner charm integration tests.""" import logging +import os import random import secrets import string @@ -131,7 +132,7 @@ def path(pytestconfig: pytest.Config) -> str: @pytest.fixture(scope="module") def token(pytestconfig: pytest.Config) -> str: """Configured token setting.""" - token = pytestconfig.getoption("--token") + token = pytestconfig.getoption("--token") or os.environ.get("INTEGRATION_TOKEN") assert token, "Please specify the --token command line option" tokens = {token.strip() for token in token.split(",")} random_token = random.choice(list(tokens)) @@ -141,7 +142,7 @@ def token(pytestconfig: pytest.Config) -> str: @pytest.fixture(scope="module") def token_alt(pytestconfig: pytest.Config, token: str) -> str: """Configured token_alt setting.""" - token_alt = pytestconfig.getoption("--token-alt") + token_alt = pytestconfig.getoption("--token-alt") or os.environ.get("INTEGRATION_TOKEN_ALT") assert token_alt, ( "Please specify the --token-alt command line option with GitHub Personal " "Access Token value." @@ -203,6 +204,7 @@ def private_endpoint_config_fixture(pytestconfig: pytest.Config) -> PrivateEndpo """The private endpoint configuration values.""" auth_url = pytestconfig.getoption("--openstack-auth-url-amd64") password = pytestconfig.getoption("--openstack-password-amd64") + password = password or os.environ.get("INTEGRATION_OPENSTACK_PASSWORD_AMD64") project_domain_name = pytestconfig.getoption("--openstack-project-domain-name-amd64") project_name = pytestconfig.getoption("--openstack-project-name-amd64") user_domain_name = pytestconfig.getoption("--openstack-user-domain-name-amd64") diff --git a/tox.ini b/tox.ini index 85ecfa29..9b0f48ed 100644 --- a/tox.ini +++ b/tox.ini @@ -110,6 +110,9 @@ commands = description = Run integration tests pass_env = PYTEST_ADDOPTS + INTEGRATION_OPENSTACK_PASSWORD_AMD64 + INTEGRATION_TOKEN + INTEGRATION_TOKEN_ALT deps = juju3.1: juju==3.1.* juju3.6: juju==3.6.*