Skip to content

Commit 65cffd9

Browse files
Merge branch 'main' into mkeller/SNOW-1825621/oauth-code-flow-support
2 parents 702607f + aa8d662 commit 65cffd9

File tree

6 files changed

+8
-52
lines changed

6 files changed

+8
-52
lines changed

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ timestamps {
4040
stage('Test') {
4141
try {
4242
def commit_hash = "main" // default which we want to override
43-
def bptp_tag = "bptp-built"
43+
def bptp_tag = "bptp-stable"
4444
def response = authenticatedGithubCall("https://api.github.com/repos/snowflakedb/snowflake/git/ref/tags/${bptp_tag}")
4545
commit_hash = response.object.sha
46-
// Append the bptp-built commit sha to params
46+
// Append the bptp-stable commit sha to params
4747
params += [string(name: 'svn_revision', value: commit_hash)]
4848
} catch(Exception e) {
4949
println("Exception computing commit hash from: ${response}")

src/snowflake/connector/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,8 +1276,6 @@ def __open_connection(self):
12761276
backoff_generator=self._backoff_generator,
12771277
)
12781278
elif self._authenticator == PROGRAMMATIC_ACCESS_TOKEN:
1279-
if not self._token and self._password:
1280-
self._token = self._password
12811279
self.auth_class = AuthByPAT(self._token)
12821280
elif self._authenticator == WORKLOAD_IDENTITY_AUTHENTICATOR:
12831281
self._check_experimental_authentication_flag()
@@ -1432,6 +1430,7 @@ def __config(self, **kwargs):
14321430
OAUTH_AUTHENTICATOR,
14331431
NO_AUTH_AUTHENTICATOR,
14341432
WORKLOAD_IDENTITY_AUTHENTICATOR,
1433+
PROGRAMMATIC_ACCESS_TOKEN,
14351434
}
14361435

14371436
if not (self._master_token and self._session_token):

test/data/wiremock/mappings/auth/pat/invalid_token.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
{
1212
"equalToJson" : {
1313
"data": {
14-
"LOGIN_NAME": "testUser",
1514
"AUTHENTICATOR": "PROGRAMMATIC_ACCESS_TOKEN",
1615
"TOKEN": "some PAT"
1716
}

test/data/wiremock/mappings/auth/pat/successful_flow.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
{
1212
"equalToJson" : {
1313
"data": {
14-
"LOGIN_NAME": "testUser",
1514
"AUTHENTICATOR": "PROGRAMMATIC_ACCESS_TOKEN",
1615
"TOKEN": "some PAT"
1716
}

test/integ/test_cursor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from datetime import date, datetime, timezone
1212
from typing import TYPE_CHECKING, NamedTuple
1313
from unittest import mock
14-
from unittest.mock import MagicMock
1514

1615
import pytest
1716
import pytz
@@ -843,10 +842,11 @@ def test_timeout_query(conn_cnx):
843842
# we can not precisely control the timing to send cancel query request right after server
844843
# executes the query but before returning the results back to client
845844
# it depends on python scheduling and server processing speed, so we mock here
846-
with mock.patch.object(
847-
c, "_timebomb", new_callable=MagicMock
848-
) as mock_timerbomb:
849-
mock_timerbomb.executed = True
845+
with mock.patch(
846+
"snowflake.connector.cursor._TrackedQueryCancellationTimer",
847+
autospec=True,
848+
) as mock_timebomb:
849+
mock_timebomb.return_value.executed = True
850850
c.execute(
851851
"select 123'",
852852
timeout=0.1,

test/unit/test_programmatic_access_token.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def test_valid_pat(wiremock_client: WiremockClient) -> None:
4343
)
4444

4545
cnx = snowflake.connector.connect(
46-
user="testUser",
4746
authenticator=PROGRAMMATIC_ACCESS_TOKEN,
4847
token="some PAT",
4948
account="testAccount",
@@ -70,7 +69,6 @@ def test_invalid_pat(wiremock_client: WiremockClient) -> None:
7069

7170
with pytest.raises(snowflake.connector.errors.DatabaseError) as execinfo:
7271
snowflake.connector.connect(
73-
user="testUser",
7472
authenticator=PROGRAMMATIC_ACCESS_TOKEN,
7573
token="some PAT",
7674
account="testAccount",
@@ -80,42 +78,3 @@ def test_invalid_pat(wiremock_client: WiremockClient) -> None:
8078
)
8179

8280
assert str(execinfo.value).endswith("Programmatic access token is invalid.")
83-
84-
85-
@pytest.mark.skipolddriver
86-
def test_pat_as_password(wiremock_client: WiremockClient) -> None:
87-
wiremock_data_dir = (
88-
pathlib.Path(__file__).parent.parent
89-
/ "data"
90-
/ "wiremock"
91-
/ "mappings"
92-
/ "auth"
93-
/ "pat"
94-
)
95-
96-
wiremock_generic_data_dir = (
97-
pathlib.Path(__file__).parent.parent
98-
/ "data"
99-
/ "wiremock"
100-
/ "mappings"
101-
/ "generic"
102-
)
103-
104-
wiremock_client.import_mapping(wiremock_data_dir / "successful_flow.json")
105-
wiremock_client.add_mapping(
106-
wiremock_generic_data_dir / "snowflake_disconnect_successful.json"
107-
)
108-
109-
cnx = snowflake.connector.connect(
110-
user="testUser",
111-
authenticator=PROGRAMMATIC_ACCESS_TOKEN,
112-
token=None,
113-
password="some PAT",
114-
account="testAccount",
115-
protocol="http",
116-
host=wiremock_client.wiremock_host,
117-
port=wiremock_client.wiremock_http_port,
118-
)
119-
120-
assert cnx, "invalid cnx"
121-
cnx.close()

0 commit comments

Comments
 (0)