Skip to content

Commit 68e763b

Browse files
committed
test(auth): add manual authentication tests
1 parent d10a998 commit 68e763b

File tree

8 files changed

+95
-0
lines changed

8 files changed

+95
-0
lines changed

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
jwt_google_idp,
99
okta_browser_idp,
1010
okta_idp,
11+
ping_browser_idp,
1112
)

test/integration/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
jwt_google_idp,
99
okta_browser_idp,
1010
okta_idp,
11+
ping_browser_idp,
1112
)

test/integration/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ def jumpcloud_browser_idp():
105105
return {**_get_default_connection_args(), **db_connect}
106106

107107

108+
@pytest.fixture(scope="class")
109+
def ping_browser_idp():
110+
db_connect = {
111+
"iam": conf.getboolean("ping-one-idp", "iam"),
112+
"credentials_provider": conf.get("ping-one-idp", "credentials_provider"),
113+
"login_url": conf.get("ping-one-idp", "login_url"),
114+
"listen_port": conf.getint("ping-one-idp", "listen_port"),
115+
"idp_response_timeout": conf.getint("ping-one-idp", "idp_response_timeout"),
116+
}
117+
return {**_get_default_connection_args(), **db_connect}
118+
119+
108120
@pytest.fixture(scope="class")
109121
def azure_idp():
110122
db_connect = {

test/manual/__init__.py

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
3+
import redshift_connector
4+
5+
aws_secret_access_key: str = ""
6+
aws_access_key: str = ""
7+
aws_session_token: str = ""
8+
9+
"""
10+
How to use:
11+
0) If necessary, create a Redshift cluster
12+
1) In the connect method below, specify the connection parameters
13+
3) Specify the AWS IAM credentials in the variables above
14+
4) Manually execute this test
15+
"""
16+
17+
18+
@pytest.mark.skip(reason="manual")
19+
def test_use_aws_credentials_default_profile():
20+
with redshift_connector.connect(
21+
iam=True,
22+
database="my_database",
23+
db_user="my_db_user",
24+
password="",
25+
user="",
26+
cluster_identifier="my_cluster_identifier",
27+
region="my_region",
28+
access_key_id=aws_access_key,
29+
secret_access_key=aws_secret_access_key,
30+
session_token=aws_session_token,
31+
) as con:
32+
with con.cursor() as cursor:
33+
cursor.execute("select 1")

test/manual/plugin/__init__.py

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import configparser
2+
import os
3+
import typing
4+
from test import (
5+
azure_browser_idp,
6+
idp_arg,
7+
jumpcloud_browser_idp,
8+
jwt_azure_v2_idp,
9+
jwt_google_idp,
10+
okta_browser_idp,
11+
ping_browser_idp,
12+
)
13+
14+
import pytest # type: ignore
15+
16+
import redshift_connector
17+
18+
conf = configparser.ConfigParser()
19+
root_path = os.path.dirname(os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))))
20+
conf.read(root_path + "/config.ini")
21+
22+
BROWSER_CREDENTIAL_PROVIDERS: typing.List[str] = [
23+
"jumpcloud_browser_idp",
24+
"okta_browser_idp",
25+
"azure_browser_idp",
26+
"jwt_azure_v2_idp",
27+
"jwt_google_idp",
28+
"ping_browser_idp",
29+
]
30+
31+
"""
32+
How to use:
33+
0) If necessary, create a Redshift cluster and configure it for use with the desired IdP
34+
1) In config.ini specify the connection parameters required by the desired IdP fixture in test/integration/conftest.py
35+
2) Ensure browser cookies have been cleared
36+
3) Manually execute the tests in this file, providing the necessary login information in the web browser
37+
"""
38+
39+
40+
@pytest.mark.skip(reason="manual")
41+
@pytest.mark.parametrize("idp_arg", BROWSER_CREDENTIAL_PROVIDERS, indirect=True)
42+
def test_browser_credentials_provider_can_auth(idp_arg):
43+
with redshift_connector.connect(**idp_arg):
44+
pass

test/unit/plugin/test_credentials_providers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
azure_browser_idp,
77
azure_idp,
88
idp_arg,
9+
jumpcloud_browser_idp,
910
jwt_azure_v2_idp,
1011
jwt_google_idp,
1112
okta_browser_idp,
1213
okta_idp,
14+
ping_browser_idp,
1315
)
1416

1517
import pytest # type: ignore
@@ -26,6 +28,8 @@
2628
ALL_IDP: typing.List[str] = [
2729
"okta_browser_idp",
2830
"azure_browser_idp",
31+
"jumpcloud_browser_idp",
32+
"ping_browser_idp",
2933
"jwt_google_idp",
3034
"jwt_azure_v2_idp",
3135
] + NON_BROWSER_IDP

0 commit comments

Comments
 (0)