|
14 | 14 | conf.read(root_path + "/config.ini") |
15 | 15 |
|
16 | 16 |
|
17 | | -NON_BROWSER_IDP: typing.List[str] = ["okta_idp", "azure_idp"] |
| 17 | +NON_BROWSER_IDP: typing.List[str] = ["okta_idp", "azure_idp", "adfs_idp"] |
18 | 18 | ALL_IDP: typing.List[str] = ["okta_browser_idp", "azure_browser_idp"] + NON_BROWSER_IDP |
19 | 19 |
|
20 | 20 |
|
@@ -51,7 +51,10 @@ def testIdpPassword(idp_arg): |
51 | 51 | idp_arg = idp_arg |
52 | 52 | idp_arg["password"] = "wrong_password" |
53 | 53 |
|
54 | | - with pytest.raises(redshift_connector.InterfaceError, match=r"(Unauthorized)|(400 Client Error: Bad Request)"): |
| 54 | + with pytest.raises( |
| 55 | + redshift_connector.InterfaceError, |
| 56 | + match=r"(Unauthorized)|(400 Client Error: Bad Request)|(Failed to find Adfs access_token)", |
| 57 | + ): |
55 | 58 | redshift_connector.connect(**idp_arg) |
56 | 59 |
|
57 | 60 |
|
@@ -91,14 +94,17 @@ def test_preferred_role_invalid_should_fail(idp_arg): |
91 | 94 |
|
92 | 95 | @pytest.mark.parametrize("idp_arg", NON_BROWSER_IDP, indirect=True) |
93 | 96 | def test_invalid_db_group(idp_arg): |
| 97 | + import botocore.exceptions |
| 98 | + |
94 | 99 | idp_arg["db_groups"] = ["girl_dont_do_it"] |
95 | 100 | with pytest.raises( |
96 | | - redshift_connector.ProgrammingError, match='Group "{}" does not exist'.format(idp_arg["db_groups"][0]) |
| 101 | + expected_exception=(redshift_connector.ProgrammingError, botocore.exceptions.ClientError), |
| 102 | + match="{}".format(idp_arg["db_groups"][0]), |
97 | 103 | ): |
98 | 104 | redshift_connector.connect(**idp_arg) |
99 | 105 |
|
100 | 106 |
|
101 | | -@pytest.mark.parametrize("idp_arg", NON_BROWSER_IDP, indirect=True) |
| 107 | +@pytest.mark.parametrize("idp_arg", ["okta_idp", "azure_idp"], indirect=True) |
102 | 108 | @pytest.mark.parametrize("ssl_insecure_val", [True, False]) |
103 | 109 | def test_ssl_insecure_is_used(idp_arg, ssl_insecure_val): |
104 | 110 | idp_arg["ssl_insecure"] = ssl_insecure_val |
@@ -162,21 +168,17 @@ def use_cached_temporary_credentials(idp_arg): |
162 | 168 | assert first_cred_cache_entry == redshift_connector.IamHelper.credentials_cache.popitem() |
163 | 169 |
|
164 | 170 |
|
165 | | -@pytest.mark.skip |
166 | | -# TODO: https://docs.aws.amazon.com/redshift/latest/dg/r_STL_CONNECTION_LOG.html plugin_name column character limit |
167 | | -# TODO: causes field value cut-off |
168 | 171 | @pytest.mark.parametrize("idp_arg", NON_BROWSER_IDP, indirect=True) |
169 | 172 | def test_stl_connection_log_contains_plugin_name(idp_arg, db_kwargs): |
170 | 173 | idp_arg["auto_create"] = True |
171 | 174 | with redshift_connector.connect(**idp_arg) as conn: |
172 | | - pass |
173 | | - with redshift_connector.connect(**db_kwargs) as conn: |
174 | 175 | with conn.cursor() as cursor: |
175 | | - # verify stl_connection_log contains driver version as expected |
176 | 176 | cursor.execute( |
177 | | - "select top 1 1 from stl_connection_log where driver_version = '{}' and plugin_name = 'redshift_connector.plugin.{}'".format( |
178 | | - DriverInfo.driver_full_name(), idp_arg["credentials_provider"] |
179 | | - ) |
| 177 | + "select top 1 1 from stl_connection_log where driver_version = %s and plugin_name like %s", |
| 178 | + ( |
| 179 | + DriverInfo.driver_full_name(), |
| 180 | + "redshift_connector.plugin.{}".format(idp_arg["credentials_provider"])[:32], |
| 181 | + ), |
180 | 182 | ) |
181 | 183 | res = cursor.fetchone() |
182 | 184 | assert res is not None |
|
0 commit comments