1- from trino .auth import JWTAuthentication , OAuth2Authentication
1+ from pydantic import SecretStr
2+ from trino .auth import BasicAuthentication , JWTAuthentication , OAuth2Authentication
23
3- from feast .infra .offline_stores .contrib .trino_offline_store .trino import AuthConfig
4+ from feast .infra .offline_stores .contrib .trino_offline_store .trino import (
5+ CLASSES_BY_AUTH_TYPE ,
6+ AuthConfig ,
7+ FeastConfigBaseModel ,
8+ )
49
510
611def test_jwt_auth_produces_plain_str_token ():
@@ -19,3 +24,42 @@ def test_oauth2_auth_unchanged():
1924 trino_auth = auth .to_trino_auth ()
2025
2126 assert isinstance (trino_auth , OAuth2Authentication )
27+
28+
29+ def test_basic_auth_with_plain_fields_unaffected ():
30+ auth = AuthConfig (type = "basic" , config = {"username" : "alice" , "password" : "hunter2" })
31+
32+ trino_auth = auth .to_trino_auth ()
33+
34+ assert isinstance (trino_auth , BasicAuthentication )
35+ assert trino_auth ._username == "alice"
36+ assert trino_auth ._password == "hunter2"
37+
38+
39+ class _MixedAuthModel (FeastConfigBaseModel ):
40+ username : str
41+ token : SecretStr
42+
43+
44+ class _MixedAuth :
45+ def __init__ (self , username : str , token : str ):
46+ self .username = username
47+ self .token = token
48+
49+
50+ def test_to_trino_auth_unwraps_only_secret_fields_in_mixed_model (monkeypatch ):
51+ monkeypatch .setitem (
52+ CLASSES_BY_AUTH_TYPE ,
53+ "jwt" ,
54+ {"auth_model" : _MixedAuthModel , "trino_auth" : _MixedAuth },
55+ )
56+ auth = AuthConfig (
57+ type = "jwt" , config = {"username" : "alice" , "token" : "my-secret-token" }
58+ )
59+
60+ trino_auth = auth .to_trino_auth ()
61+
62+ assert trino_auth .username == "alice"
63+ assert trino_auth .token == "my-secret-token"
64+ assert isinstance (trino_auth .username , str )
65+ assert isinstance (trino_auth .token , str )
0 commit comments