Skip to content

Commit

Permalink
Fix user-journey tests for running against non-default targets (#1050)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
soapy1 and pre-commit-ci[bot] authored Jan 23, 2025
1 parent a7a6390 commit 1ce3e6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
28 changes: 15 additions & 13 deletions conda-store-server/tests/user_journeys/test_user_journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def verify_ssl() -> bool:
If CONDA_STORE_TEST_VERIFY_SSL is 0, ssl verification is disabled. For all
other inputs, ssl verification is enabled.
"""
return bool(os.environ.get("CONDA_STORE_TEST_VERIFY_SSL", True))
verify = os.environ.get("CONDA_STORE_TEST_VERIFY_SSL", "true")
return verify.lower() not in ("0", "false")


@pytest.mark.user_journey
Expand Down Expand Up @@ -59,10 +60,10 @@ def test_admin_user_can_create_environment(
],
)
def test_admin_login_and_delete_shared_environment(
base_url: str, specification_path: str, verify_ssl: bool
base_url: str, token: str, specification_path: str, verify_ssl: bool
) -> None:
"""Test that an admin can login and create/delete an env in a shared namespace."""
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)

# Create a shared namespace; default permissions for namepace/environment
# */* is admin
Expand All @@ -84,17 +85,18 @@ def test_admin_login_and_delete_shared_environment(
],
)
def test_user_login_and_create_shared_environment(
base_url: str, specification_path: str, verify_ssl: bool
base_url: str, token: str, specification_path: str, verify_ssl: bool
) -> None:
"""Test that a user can login and create an environment in a shared namespace."""
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)

# Create a shared namespace; default permissions for namepace/environment
# */* is admin
namespace = api.create_namespace().json()["data"]["name"]

dev_api = utils.API(
base_url=base_url,
verify_ssl=verify_ssl,
token=api.create_token(
namespace,
"developer",
Expand All @@ -111,13 +113,13 @@ def test_user_login_and_create_shared_environment(


@pytest.mark.user_journey
def test_admin_set_active_build(base_url: str, verify_ssl: bool):
def test_admin_set_active_build(base_url: str, token: str, verify_ssl: bool):
"""Test that an admin can delete environments."""
specs = [
"tests/user_journeys/test_data/simple_environment.yaml",
"tests/user_journeys/test_data/simple_environment2.yaml",
]
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)
namespace = api.create_namespace().json()["data"]["name"]
envs = set()
for spec in specs:
Expand Down Expand Up @@ -159,9 +161,9 @@ def test_admin_set_active_build(base_url: str, verify_ssl: bool):


@pytest.mark.user_journey
def test_failed_build_logs(base_url: str, verify_ssl: bool):
def test_failed_build_logs(base_url: str, token: str, verify_ssl: bool):
"""Test that a user can access logs for a failed build."""
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)
namespace = "default"
build_request = api.create_environment(
namespace,
Expand All @@ -181,9 +183,9 @@ def test_failed_build_logs(base_url: str, verify_ssl: bool):


@pytest.mark.user_journey
def test_cancel_build(base_url: str, verify_ssl: bool):
def test_cancel_build(base_url: str, token: str, verify_ssl: bool):
"""Test that a user cancel a build in progress."""
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)
namespace = "default"
build_id = api.create_environment(
namespace,
Expand Down Expand Up @@ -213,9 +215,9 @@ def check_status():


@pytest.mark.user_journey
def test_get_lockfile(base_url: str, verify_ssl: bool):
def test_get_lockfile(base_url: str, token: str, verify_ssl: bool):
"""Test that an admin can access a valid lockfile for a build."""
api = utils.API(base_url=base_url, verify_ssl=verify_ssl)
api = utils.API(base_url=base_url, token=token, verify_ssl=verify_ssl)
namespace = "default"
build_request = api.create_environment(
namespace,
Expand Down
3 changes: 0 additions & 3 deletions conda-store-server/tests/user_journeys/utils/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

import requests

import utils.time_utils as time_utils

TIMEOUT = 10


Expand Down Expand Up @@ -136,7 +134,6 @@ def create_token(
"""Create a token with a specified role in a specified namespace."""
json_data = {
"primary_namespace": default_namespace,
"expiration": time_utils.get_iso8601_time(1),
"role_bindings": {f"{namespace}/*": [role]},
}
return self._make_request("api/v1/token", method="POST", json_data=json_data)
Expand Down

0 comments on commit 1ce3e6a

Please sign in to comment.