|
1 | 1 | import json |
| 2 | +from requests import Response |
2 | 3 | from six.moves.urllib.parse import parse_qsl, urlparse |
3 | 4 |
|
4 | 5 | import pytest |
@@ -60,6 +61,35 @@ def mock_connection(self): |
60 | 61 | ], |
61 | 62 | } |
62 | 63 |
|
| 64 | + @pytest.fixture |
| 65 | + def mock_connections(self): |
| 66 | + return { |
| 67 | + "data": [ |
| 68 | + { |
| 69 | + "object": "connection", |
| 70 | + "id": "conn_id", |
| 71 | + "status": "linked", |
| 72 | + "name": "Google OAuth 2.0", |
| 73 | + "connection_type": "GoogleOAuth", |
| 74 | + "oauth_uid": "oauth-uid.apps.googleusercontent.com", |
| 75 | + "oauth_secret": "oauth-secret", |
| 76 | + "oauth_redirect_uri": "https://auth.workos.com/sso/oauth/google/chicken/callback", |
| 77 | + "saml_entity_id": None, |
| 78 | + "saml_idp_url": None, |
| 79 | + "saml_relying_party_trust_cert": None, |
| 80 | + "saml_x509_certs": None, |
| 81 | + "domains": [ |
| 82 | + { |
| 83 | + "object": "connection_domain", |
| 84 | + "id": "domain_id", |
| 85 | + "domain": "terrace-house.com", |
| 86 | + }, |
| 87 | + ], |
| 88 | + } |
| 89 | + ], |
| 90 | + "listMetadata": {"before": None, "after": None}, |
| 91 | + } |
| 92 | + |
63 | 93 | def test_authorization_url_throws_value_error_with_missing_domain_and_provider( |
64 | 94 | self, |
65 | 95 | ): |
@@ -177,3 +207,12 @@ def test_create_connection(self, mock_request_method, mock_connection): |
177 | 207 |
|
178 | 208 | connection = self.sso.create_connection("draft_conn_id") |
179 | 209 | assert connection == response_dict |
| 210 | + |
| 211 | + def test_list_connections(self, mock_connections, mock_request_method): |
| 212 | + mock_response = Response() |
| 213 | + mock_response.status_code = 200 |
| 214 | + mock_response.response_dict = mock_connections |
| 215 | + mock_request_method("get", mock_response, 200) |
| 216 | + response = self.sso.list_connections() |
| 217 | + assert response.status_code == 200 |
| 218 | + assert response.response_dict == mock_connections |
0 commit comments