From 820e963f80b6699382ae4503204e591ffd95c1ce Mon Sep 17 00:00:00 2001 From: Patryk Czajka Date: Mon, 14 Jul 2025 14:57:33 +0200 Subject: [PATCH 1/2] Apply (#2134) to async code --- src/snowflake/connector/aio/auth/_keypair.py | 2 +- test/integ/aio/test_key_pair_authentication_async.py | 6 ++++++ test/unit/aio/test_auth_keypair_async.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/snowflake/connector/aio/auth/_keypair.py b/src/snowflake/connector/aio/auth/_keypair.py index 641f387d1..aff2f207f 100644 --- a/src/snowflake/connector/aio/auth/_keypair.py +++ b/src/snowflake/connector/aio/auth/_keypair.py @@ -18,7 +18,7 @@ class AuthByKeyPair(AuthByPluginAsync, AuthByKeyPairSync): def __init__( self, - private_key: bytes | RSAPrivateKey, + private_key: bytes | str | RSAPrivateKey, lifetime_in_seconds: int = AuthByKeyPairSync.LIFETIME, **kwargs, ) -> None: diff --git a/test/integ/aio/test_key_pair_authentication_async.py b/test/integ/aio/test_key_pair_authentication_async.py index e138978a9..7abd4b4e3 100644 --- a/test/integ/aio/test_key_pair_authentication_async.py +++ b/test/integ/aio/test_key_pair_authentication_async.py @@ -6,6 +6,7 @@ from __future__ import annotations import asyncio +import base64 import uuid import pytest @@ -81,6 +82,11 @@ def fin(): async with snowflake.connector.aio.SnowflakeConnection(**db_config) as _: pass + # Ensure the base64-encoded version also works + db_config["private_key"] = base64.b64encode(private_key_der) + async with snowflake.connector.aio.SnowflakeConnection(**db_config) as _: + pass + @pytest.mark.skipolddriver async def test_multiple_key_pair(is_public_test, request, conn_cnx, db_parameters): diff --git a/test/unit/aio/test_auth_keypair_async.py b/test/unit/aio/test_auth_keypair_async.py index 9c4037ed0..2b7cd6df6 100644 --- a/test/unit/aio/test_auth_keypair_async.py +++ b/test/unit/aio/test_auth_keypair_async.py @@ -101,7 +101,7 @@ async def test_auth_keypair_bad_type(): class Bad: pass - for bad_private_key in ("abcd", 1234, Bad()): + for bad_private_key in (1234, Bad()): auth_instance = AuthByKeyPair(private_key=bad_private_key) with raises(TypeError) as ex: await auth_instance.prepare(account=account, user=user) From 86053abb3ee0a87fb2b172bfbed86db01b6ecd36 Mon Sep 17 00:00:00 2001 From: Patryk Czajka Date: Mon, 7 Jul 2025 14:25:38 +0200 Subject: [PATCH 2/2] DEBUG - add workflow to filter tests --- .github/workflows/run_single_test.yml | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/run_single_test.yml diff --git a/.github/workflows/run_single_test.yml b/.github/workflows/run_single_test.yml new file mode 100644 index 000000000..3567d45fa --- /dev/null +++ b/.github/workflows/run_single_test.yml @@ -0,0 +1,35 @@ +name: Run custom pytest + +on: + push: + +jobs: + run-pytest: + runs-on: ubuntu-latest + strategy: + matrix: + cloud-provider: [aws, azure, gcp] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Setup parameters file + shell: bash + env: + PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }} + run: | + gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \ + .github/workflows/parameters/public/parameters_${{ matrix.cloud-provider }}.py.gpg > test/parameters.py + + - name: Install dependencies + run: | + python -m pip install ".[development,aio,secure-local-storage]" + + - name: Run pytest + run: | + pytest -vvv -k "test_different_key_length" .