Skip to content

Commit 86c6cc4

Browse files
committed
test(auth): sha256 password
1 parent a8cb85b commit 86c6cc4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/integration/test_connection.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,30 @@ def test_md5(db_kwargs):
9696
redshift_connector.connect(**db_kwargs)
9797

9898

99+
@pytest.mark.parametrize("algorithm", ("sha256",))
100+
def test_auth_req_digest(db_kwargs, algorithm):
101+
test_user: str = "{}_dbuser".format(algorithm)
102+
test_password: str = "My_{}_PaSsWoRdŽ".format(algorithm)
103+
with redshift_connector.connect(**db_kwargs) as conn:
104+
with conn.cursor() as cursor:
105+
cursor.execute("drop user if exists {}".format(test_user))
106+
cursor.execute(
107+
"create user {} with password '{}'".format(test_user, "{}|{}".format(algorithm, test_password))
108+
)
109+
conn.commit()
110+
try:
111+
with redshift_connector.connect(**{**db_kwargs, **{"user": test_user, "password": test_password}}) as conn:
112+
with conn.cursor() as cursor:
113+
cursor.execute("select 1")
114+
except:
115+
raise
116+
finally:
117+
with redshift_connector.connect(**db_kwargs) as conn:
118+
with conn.cursor() as cursor:
119+
cursor.execute("drop user if exists {}".format(test_user))
120+
conn.commit()
121+
122+
99123
@pytest.mark.usefixtures("trust_all_certificates")
100124
def test_ssl(db_kwargs):
101125
db_kwargs["ssl"] = True

0 commit comments

Comments
 (0)