Skip to content

Commit b60890c

Browse files
authored
Merge pull request #391 from BorisYourich/master
BasicAuth for PulsarTesRunner
2 parents 92283e9 + f6627c6 commit b60890c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pulsar/managers/util/tes.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
from typing import (
23
Any,
34
cast,
@@ -40,11 +41,21 @@ def ensure_tes_client() -> None:
4041

4142

4243
def tes_client_from_dict(destination_params: Dict[str, Any]) -> TesClient:
43-
# TODO: implement funnel's basic auth in pydantic-tes and expose it here.
44-
tes_url = destination_params["tes_url"]
45-
return TesClient(
46-
url=tes_url,
47-
)
44+
tes_url = destination_params.get("tes_url")
45+
auth_type = destination_params.get("authorization", "none") # Default to "none"
46+
47+
headers = {}
48+
49+
if auth_type == "basic":
50+
basic_auth = destination_params.get("basic_auth", {})
51+
username = basic_auth.get("username")
52+
password = basic_auth.get("password")
53+
if username and password:
54+
auth_string = f"{username}:{password}"
55+
auth_base64 = base64.b64encode(auth_string.encode()).decode()
56+
headers["Authorization"] = f"Basic {auth_base64}"
57+
58+
return TesClient(url=tes_url, headers=headers)
4859

4960

5061
def tes_resources(destination_params: Dict[str, Any]) -> TesResources:

0 commit comments

Comments
 (0)