Skip to content

Commit 2f47724

Browse files
authored
Update test to use user_token and update setup_env_user_token to use token when possible (kubeflow#1663)
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com>
1 parent c283fa8 commit 2f47724

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

clients/python/tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,10 @@ def client_attrs() -> dict[str, any]:
178178

179179

180180
@pytest.fixture(scope="module")
181-
def setup_env_user_token():
181+
def setup_env_user_token(user_token: str) -> str:
182+
token_bytes = (user_token or "Token").encode("utf-8")
182183
with tempfile.NamedTemporaryFile(delete=False) as token_file:
183-
token_file.write(b"Token")
184+
token_file.write(token_bytes)
184185
old_token_path = os.getenv("KF_PIPELINES_SA_TOKEN_PATH")
185186
os.environ["KF_PIPELINES_SA_TOKEN_PATH"] = token_file.name
186187

clients/python/tests/fuzz_api/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def generated_schema(request: pytest.FixtureRequest, pytestconfig: pytest.Config
2929
return schema
3030

3131
@pytest.fixture
32-
def auth_headers(setup_env_user_token):
32+
def auth_headers(user_token: str) -> dict[str, str]:
3333
"""Provides authorization headers for API requests."""
3434
return {
3535
"Content-Type": "application/json",
36-
"Authorization": f"Bearer {setup_env_user_token}"
36+
"Authorization": f"Bearer {user_token}",
3737
}
3838

3939
@pytest.fixture

clients/python/tests/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ def test_nested_recursive_store_in_s3(
862862

863863
@pytest.mark.e2e
864864
def test_custom_async_runner_with_ray(
865-
client_attrs: dict[str, any], client: ModelRegistry, monkeypatch
865+
client_attrs: dict[str, any], client: ModelRegistry, user_token: str, monkeypatch
866866
):
867867
"""Test Ray integration with uvloop event loop policy"""
868868
import asyncio
@@ -901,6 +901,7 @@ def test_with_ray():
901901
author=client_attrs["author"],
902902
is_secure=client_attrs["ssl"],
903903
async_runner=atr.run,
904+
user_token=user_token,
904905
)
905906
client.register_model(
906907
name="test_model",

0 commit comments

Comments
 (0)