Skip to content

Commit 1e29ef8

Browse files
Merge branch 'main' into SNOW-2043816-Kerberos-Proxy-Auth-Python
# Conflicts: # src/snowflake/connector/connection.py
2 parents b30fbca + e34a73c commit 1e29ef8

24 files changed

+441
-112
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,8 @@ src/snowflake/connector/nanoarrow_cpp/ArrowIterator/nanoarrow_arrow_iterator.cpp
129129
# Prober files
130130
prober/parameters.json
131131
prober/snowflake_prober.egg-info/
132+
133+
# SSH private key for WIF tests
134+
ci/wif/parameters/rsa_wif_aws_azure
135+
ci/wif/parameters/rsa_wif_gcp
136+
ci/wif/parameters/parameters_wif.json

DESCRIPTION.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1616

1717
- v3.16.1(TBD)
1818
- Added in-band OCSP exception telemetry.
19+
- Added `APPLICATION_PATH` within `CLIENT_ENVIRONMENT` to distinguish between multiple scripts using the PythonConnector in the same environment.
20+
- Disabled token caching for OAuth Client Credentials authentication
1921
- Added in-band HTTP exception telemetry.
2022
- Fixed a bug where timezoned timestamps fetched as pandas.DataFrame or pyarrow.Table would overflow for the sake of unnecessary precision. In the case where an overflow cannot be prevented a clear error will be raised now.
23+
- Fix OAuth authenticator values.
24+
- Add `unsafe_skip_file_permissions_check` flag to skip file permissions check on cache and config.
2125

2226
- v3.16.0(July 04,2025)
2327
- Bumped numpy dependency from <2.1.0 to <=2.2.4.

Jenkinsfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ timestamps {
7171
'''.stripMargin()
7272
}
7373
}
74+
},
75+
'Test WIF': {
76+
stage('Test WIF') {
77+
withCredentials([
78+
string(credentialsId: 'sfctest0-parameters-secret', variable: 'PARAMETERS_SECRET')
79+
]) {
80+
sh '''\
81+
|#!/bin/bash -e
82+
|$WORKSPACE/ci/test_wif.sh
83+
'''.stripMargin()
84+
}
85+
}
7486
}
7587
)
7688
}

ci/container/test_authentication.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set -o pipefail
66
export WORKSPACE=${WORKSPACE:-/mnt/workspace}
77
export SOURCE_ROOT=${SOURCE_ROOT:-/mnt/host}
88

9-
MVNW_EXE=$SOURCE_ROOT/mvnw
109
AUTH_PARAMETER_FILE=./.github/workflows/parameters/private/parameters_aws_auth_tests.json
1110
eval $(jq -r '.authtestparams | to_entries | map("export \(.key)=\(.value|tostring)")|.[]' $AUTH_PARAMETER_FILE)
1211

ci/test_wif.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash -e
2+
3+
set -o pipefail
4+
5+
export THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
export RSA_KEY_PATH_AWS_AZURE="$THIS_DIR/wif/parameters/rsa_wif_aws_azure"
7+
export RSA_KEY_PATH_GCP="$THIS_DIR/wif/parameters/rsa_wif_gcp"
8+
export PARAMETERS_FILE_PATH="$THIS_DIR/wif/parameters/parameters_wif.json"
9+
10+
run_tests_and_set_result() {
11+
local provider="$1"
12+
local host="$2"
13+
local snowflake_host="$3"
14+
local rsa_key_path="$4"
15+
16+
ssh -i "$rsa_key_path" -o IdentitiesOnly=yes -p 443 "$host" env BRANCH="$BRANCH" SNOWFLAKE_TEST_WIF_HOST="$snowflake_host" SNOWFLAKE_TEST_WIF_PROVIDER="$provider" SNOWFLAKE_TEST_WIF_ACCOUNT="$SNOWFLAKE_TEST_WIF_ACCOUNT" bash << EOF
17+
set -e
18+
set -o pipefail
19+
docker run \
20+
--rm \
21+
-e BRANCH \
22+
-e SNOWFLAKE_TEST_WIF_PROVIDER \
23+
-e SNOWFLAKE_TEST_WIF_HOST \
24+
-e SNOWFLAKE_TEST_WIF_ACCOUNT \
25+
snowflakedb/client-python-test:1 \
26+
bash -c "
27+
echo 'Running tests on branch: \$BRANCH'
28+
if [[ \"\$BRANCH\" =~ ^PR-[0-9]+\$ ]]; then
29+
curl -L https://github.com/snowflakedb/snowflake-connector-python/archive/refs/pull/\$(echo \$BRANCH | cut -d- -f2)/head.tar.gz | tar -xz
30+
mv snowflake-connector-python-* snowflake-connector-python
31+
else
32+
curl -L https://github.com/snowflakedb/snowflake-connector-python/archive/refs/heads/\$BRANCH.tar.gz | tar -xz
33+
mv snowflake-connector-python-\$BRANCH snowflake-connector-python
34+
fi
35+
cd snowflake-connector-python
36+
bash ci/wif/test_wif.sh
37+
"
38+
EOF
39+
local status=$?
40+
41+
if [[ $status -ne 0 ]]; then
42+
echo "$provider tests failed with exit status: $status"
43+
EXIT_STATUS=1
44+
else
45+
echo "$provider tests passed"
46+
fi
47+
}
48+
49+
get_branch() {
50+
local branch
51+
branch=$(git rev-parse --abbrev-ref HEAD)
52+
if [[ "$branch" == "HEAD" ]]; then
53+
branch=$(git name-rev --name-only HEAD | sed 's#^remotes/origin/##;s#^origin/##')
54+
fi
55+
echo "$branch"
56+
}
57+
58+
setup_parameters() {
59+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" --output "$RSA_KEY_PATH_AWS_AZURE" "${RSA_KEY_PATH_AWS_AZURE}.gpg"
60+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" --output "$RSA_KEY_PATH_GCP" "${RSA_KEY_PATH_GCP}.gpg"
61+
chmod 600 "$RSA_KEY_PATH_AWS_AZURE"
62+
chmod 600 "$RSA_KEY_PATH_GCP"
63+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" --output "$PARAMETERS_FILE_PATH" "${PARAMETERS_FILE_PATH}.gpg"
64+
eval $(jq -r '.wif | to_entries | map("export \(.key)=\(.value|tostring)")|.[]' $PARAMETERS_FILE_PATH)
65+
}
66+
67+
BRANCH=$(get_branch)
68+
export BRANCH
69+
setup_parameters
70+
71+
# Run tests for all cloud providers
72+
EXIT_STATUS=0
73+
set +e # Don't exit on first failure
74+
run_tests_and_set_result "AZURE" "$HOST_AZURE" "$SNOWFLAKE_TEST_WIF_HOST_AZURE" "$RSA_KEY_PATH_AWS_AZURE"
75+
run_tests_and_set_result "AWS" "$HOST_AWS" "$SNOWFLAKE_TEST_WIF_HOST_AWS" "$RSA_KEY_PATH_AWS_AZURE"
76+
run_tests_and_set_result "GCP" "$HOST_GCP" "$SNOWFLAKE_TEST_WIF_HOST_GCP" "$RSA_KEY_PATH_GCP"
77+
set -e # Re-enable exit on error
78+
echo "Exit status: $EXIT_STATUS"
79+
exit $EXIT_STATUS
294 Bytes
Binary file not shown.
344 Bytes
Binary file not shown.

ci/wif/parameters/rsa_wif_gcp.gpg

356 Bytes
Binary file not shown.

ci/wif/test_wif.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -e
2+
3+
set -o pipefail
4+
5+
export SF_OCSP_TEST_MODE=true
6+
export SF_ENABLE_EXPERIMENTAL_AUTHENTICATION=true
7+
export RUN_WIF_TESTS=true
8+
9+
/opt/python/cp39-cp39/bin/python -m pip install --break-system-packages -e .
10+
/opt/python/cp39-cp39/bin/python -m pip install --break-system-packages pytest
11+
/opt/python/cp39-cp39/bin/python -m pytest test/wif/*

src/snowflake/connector/_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import string
44
from enum import Enum
5+
from inspect import stack
56
from random import choice
67
from threading import Timer
78
from uuid import UUID
@@ -86,3 +87,12 @@ def __init__(self, interval, function, args=None, kwargs=None):
8687
def run(self):
8788
super().run()
8889
self.executed = True
90+
91+
92+
def get_application_path() -> str:
93+
"""Get the path of the application script using the connector."""
94+
try:
95+
outermost_frame = stack()[-1]
96+
return outermost_frame.filename
97+
except Exception:
98+
return "unknown"

0 commit comments

Comments
 (0)