Skip to content

Commit

Permalink
Feat: Add test case for base64 encoded private key
Browse files Browse the repository at this point in the history
  • Loading branch information
Skynet committed Sep 14, 2023
1 parent b40215d commit 5f8f03b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/common/cases/secrets/encrypted-private-key-base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LS0tLS1CRUdJTiBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQpNSUlGTFRCWEJna3Foa2lHOXcwQkJRMHdTakFwQmdrcWhraUc5dzBCQlF3d0hBUUlsL0ErZlkrSVFMVUNBZ2dBCk1Bd0dDQ3FHU0liM0RRSUpCUUF3SFFZSllJWklBV1VEQkFFcUJCQ2krUnBJVmpEN1hBYURHLzNoa3F5dEJJSUUKMEtnODJvbnhqZnp5VFpFVVFtU3ZsVkw4cncwY0hTWk92RS96TkFmTFhwRjcva213OVVWWkxMLy9jbHcybWlpNgo2ZnNSRlVLd1RTNVJYYWtRcDh2ZWllTHpDT3g2bzFLd0lrMGFvOUE3c0ptd1BMejBsTXZoWEsvdHlGanM5dUhVCm4yWWNTSEo0WGdzUGRnL2xKc1RjbjRwNFFMNTJLREFFSUUvY2pSVktiZEljbGFYN3pQZHBWSzhXQ2NQVWNSK2cKOWxJbTNIQnl4ZDd3NklDRXh0WXFabGFCbE56S3NTeVdZNmNOR0J5bG91WHR2YktidHFpNEhnaThpaDdlc2ZFTgpqZU0zYmhudVpQSmViQVBHYWFxQ2cyMHlKNDQyOGpEWlpVSUlKbEx1cnZhZ2JwME11S0tTRy83YURlQzVNaUlMCktMRHY2UjJZKzNoK3ZhQy8xOWlwVHFtZXlUZ3NDQXFpSVdhWUtpTzVYRnE2UWwyZXNkSVhZUjFPQ0h3MUxNOXQKMHh2VnZyZmVaNHllWXA5SGo4MTFJQTJZV3ZUckVMMjA0VUwyUHIwcDByV1B4a1QrakhPdTFjNHlZSDI3MXNPVwpIQzdqZ2VwRUM4ckNVejZ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nNsUFBDYytkWlRSN0VIdHVZZXlGTXBtK2VZQkoxClhXbTBGMFo4RERRSkExYkZqbTUyeDNhR3hnVWFHYkVyZHNFb0ZpcHFoVURaWXhjeVhucythRFhuMURkZFJnbDMKZjFzQ09FSkFyNlpQVStlNkszMDE1NEFLcHZQMlJYTTZFNjVjR2lxUU1NKzdSV3czOGdrRlZPL1NqdEZmcGtuVQp0dmZjZFBYcTltVkQ4SXFNU0lkQVNka3Y5bmN1L25pTXNZS1crMG40djF0ZzJQeC9WaUVEOVhkSEtTUDNEbjExCkpvWnR0bkhUenFKQWl5emtUd0pNYjhVTHlIb2JsN2pEZFBmaTJkam1ZcnVnTEZDaDBOemRaTnBXNFdoeE5LejAKellqTTVuTnAzWXFOajVpQnAxTDVCUnBiSHdwbGhvenFTZGo5Y2Z1MWJRdWFBRnZya3NCMDhXa2puSkdSWFdSbApPUHMrRStyNGU0SFY3ZUxET2Y3MTFxRWhOVTJzNVVCODVpY3Fzc3AxWU52TgotLS0tLUVORCBFTkNSWVBURUQgUFJJVkFURSBLRVktLS0tLQo=
27 changes: 26 additions & 1 deletion tests/load/snowflake/test_snowflake_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def test_connection_string_with_all_params() -> None:
url = "snowflake://user1:pass1@host1/db1?warehouse=warehouse1&role=role1&private_key=pk&private_key_passphrase=paphr"
url = "snowflake://user1:pass1@host1/db1?warehouse=warehouse1&role=role1&private_key=cGsK&private_key_passphrase=paphr"

creds = SnowflakeCredentials()
creds.parse_native_representation(url)
Expand Down Expand Up @@ -60,6 +60,31 @@ def test_to_connector_params() -> None:
warehouse='warehouse1',
role='role1',
)

pkey_str = Path('./tests/common/cases/secrets/encrypted-private-key-base64').read_text('utf8')

creds = SnowflakeCredentials()
creds.private_key = pkey_str # type: ignore[assignment]
creds.private_key_passphrase = '12345' # type: ignore[assignment]
creds.username = 'user1'
creds.database = 'db1'
creds.host = 'host1'
creds.warehouse = 'warehouse1'
creds.role = 'role1'

params = creds.to_connector_params()

assert isinstance(params['private_key'], bytes)
params.pop('private_key')

assert params == dict(
user='user1',
database='db1',
account='host1',
password=None,
warehouse='warehouse1',
role='role1',
)


def test_snowflake_credentials_native_value(environment) -> None:
Expand Down

0 comments on commit 5f8f03b

Please sign in to comment.