@@ -80,6 +80,37 @@ def test_snowflake_jwt_auth_options(self):
8080 assert call_kwargs .get ("private_key_file" ) == "/path/to/key.p8"
8181 assert call_kwargs .get ("private_key_file_pwd" ) == "secret"
8282
83+ def test_snowflake_pat_auth_options (self ):
84+ """Test Snowflake PAT authentication options are passed."""
85+ from sqlit .domains .connections .domain .config import ConnectionConfig , TcpEndpoint
86+ from sqlit .domains .connections .providers .snowflake .adapter import SnowflakeAdapter
87+
88+ mock_sf = MagicMock ()
89+ mock_conn = MagicMock ()
90+ mock_sf .connect .return_value = mock_conn
91+
92+ with patch .dict ("sys.modules" , {"snowflake.connector" : mock_sf }):
93+ adapter = SnowflakeAdapter ()
94+ config = ConnectionConfig (
95+ name = "test_sf_pat" ,
96+ db_type = "snowflake" ,
97+ endpoint = TcpEndpoint (
98+ host = "account.snowflakecomputing.com" ,
99+ username = "user" ,
100+ database = "db" ,
101+ ),
102+ options = {
103+ "authenticator" : "PROGRAMMATIC_ACCESS_TOKEN" ,
104+ "pat_token" : "test_pat_token" ,
105+ },
106+ )
107+
108+ adapter .connect (config )
109+
110+ call_kwargs = mock_sf .connect .call_args [1 ]
111+ assert call_kwargs .get ("authenticator" ) == "PROGRAMMATIC_ACCESS_TOKEN"
112+ assert call_kwargs .get ("token" ) == "test_pat_token"
113+
83114 def test_postgresql_passes_extra_options (self ):
84115 """Test PostgreSQL adapter passes extra_options to driver."""
85116 from sqlit .domains .connections .domain .config import ConnectionConfig , TcpEndpoint
@@ -162,12 +193,13 @@ def test_snowflake_schema_has_auth_dropdown(self):
162193 break
163194
164195 assert auth_field is not None , "Snowflake schema should have authenticator field"
165- assert len (auth_field .options ) == 4
196+ assert len (auth_field .options ) == 5
166197 auth_values = [opt .value for opt in auth_field .options ]
167198 assert "default" in auth_values
168199 assert "externalbrowser" in auth_values
169200 assert "snowflake_jwt" in auth_values
170201 assert "oauth" in auth_values
202+ assert "PROGRAMMATIC_ACCESS_TOKEN" in auth_values
171203
172204 def test_snowflake_schema_has_private_key_fields (self ):
173205 """Test Snowflake schema includes private key fields for JWT auth."""
0 commit comments