File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ import base64
12from typing import (
23 Any ,
34 cast ,
@@ -40,12 +41,19 @@ def ensure_tes_client() -> None:
4041
4142
4243def tes_client_from_dict (destination_params : Dict [str , Any ]) -> TesClient :
43- # TODO: implement funnel's basic auth in pydantic-tes and expose it here.
4444 tes_url = destination_params .get ("tes_url" )
45- token = destination_params .get ("private_token" )
45+ auth_type = destination_params .get ("auth" , "none" ) # Default to "none"
46+
4647 headers = {}
47- if token :
48- headers ["Authorization" ] = f"Bearer { token } "
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 } "
4957
5058 return TesClient (url = tes_url , headers = headers )
5159
You can’t perform that action at this time.
0 commit comments