Skip to content

Commit 820e963

Browse files
Apply (#2134) to async code
1 parent ad59a14 commit 820e963

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/snowflake/connector/aio/auth/_keypair.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class AuthByKeyPair(AuthByPluginAsync, AuthByKeyPairSync):
1919
def __init__(
2020
self,
21-
private_key: bytes | RSAPrivateKey,
21+
private_key: bytes | str | RSAPrivateKey,
2222
lifetime_in_seconds: int = AuthByKeyPairSync.LIFETIME,
2323
**kwargs,
2424
) -> None:

test/integ/aio/test_key_pair_authentication_async.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import asyncio
9+
import base64
910
import uuid
1011

1112
import pytest
@@ -81,6 +82,11 @@ def fin():
8182
async with snowflake.connector.aio.SnowflakeConnection(**db_config) as _:
8283
pass
8384

85+
# Ensure the base64-encoded version also works
86+
db_config["private_key"] = base64.b64encode(private_key_der)
87+
async with snowflake.connector.aio.SnowflakeConnection(**db_config) as _:
88+
pass
89+
8490

8591
@pytest.mark.skipolddriver
8692
async def test_multiple_key_pair(is_public_test, request, conn_cnx, db_parameters):

test/unit/aio/test_auth_keypair_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def test_auth_keypair_bad_type():
101101
class Bad:
102102
pass
103103

104-
for bad_private_key in ("abcd", 1234, Bad()):
104+
for bad_private_key in (1234, Bad()):
105105
auth_instance = AuthByKeyPair(private_key=bad_private_key)
106106
with raises(TypeError) as ex:
107107
await auth_instance.prepare(account=account, user=user)

0 commit comments

Comments
 (0)