File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,13 @@ def request(
190190 if length is not None :
191191 headers ["Content-Length" ] = str (length )
192192
193+ # Sanity checks.
194+ if jwt_token is not None and username is not None :
195+ raise ValueError (
196+ "Either JWT tokens are accepted, "
197+ "or user credentials, but not both"
198+ )
199+
193200 # Authentication token
194201 if jwt_token is not None and "Authorization" not in headers :
195202 headers ["Authorization" ] = "Bearer %s" % jwt_token
Original file line number Diff line number Diff line change @@ -725,3 +725,15 @@ def test_credentials(serve_http):
725725 assert conn .client .jwt_token == jwt_token
726726 conn .client .sql ("select 3;" )
727727 assert server .SHARED ["jwt_token" ] == jwt_token
728+
729+
730+ def test_credentials_and_token (serve_http ):
731+ """
732+ Verify exception when user provides both credentials and token.
733+ """
734+ with serve_http (SharedStateRequestHandler ) as (server , url ):
735+ with pytest .raises (ProgrammingError ) as excinfo :
736+ connect (url , username = "foo" , jwt_token = "bar" )
737+ assert excinfo .match (
738+ "Either JWT tokens are accepted, or user credentials, but not both"
739+ )
You can’t perform that action at this time.
0 commit comments