diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e6403ca..43fae8b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ The types of changes are: * Update request status endpoint to return both audit and execution logs [#1068] (https://github.com/ethyca/fidesops/pull/1068/) * Update backend routing to handle dynamic frontend routes [#1033](https://github.com/ethyca/fidesops/pull/1033) +* Make connection type search case-insensitive [#1133](https://github.com/ethyca/fidesops/pull/1133) ### Docs diff --git a/src/fidesops/ops/api/v1/endpoints/connection_type_endpoints.py b/src/fidesops/ops/api/v1/endpoints/connection_type_endpoints.py index b3239c7b2..9e88504a2 100644 --- a/src/fidesops/ops/api/v1/endpoints/connection_type_endpoints.py +++ b/src/fidesops/ops/api/v1/endpoints/connection_type_endpoints.py @@ -36,7 +36,7 @@ def get_connection_types( ) -> List[ConnectionSystemTypeMap]: def is_match(elem: str) -> bool: """If a search query param was included, is it a substring of an available connector type?""" - return search in elem if search else True + return search.lower() in elem.lower() if search else True connection_system_types: List[ConnectionSystemTypeMap] = [] if system_type == SystemType.database or system_type is None: diff --git a/tests/ops/api/v1/endpoints/test_connection_template_endpoints.py b/tests/ops/api/v1/endpoints/test_connection_template_endpoints.py index c582e8aac..a42851373 100644 --- a/tests/ops/api/v1/endpoints/test_connection_template_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_connection_template_endpoints.py @@ -1,4 +1,3 @@ -from typing import List from unittest import mock import pytest @@ -96,6 +95,40 @@ def test_search_connection_types(self, api_client, generate_auth_header, url): {"identifier": SaaSType.outreach.value, "type": SystemType.saas.value}, ] + def test_search_connection_types_case_insensitive( + self, api_client, generate_auth_header, url + ): + auth_header = generate_auth_header(scopes=[CONNECTION_TYPE_READ]) + + resp = api_client.get(url + "?search=St", headers=auth_header) + assert resp.status_code == 200 + data = resp.json()["items"] + assert len(data) == 2 + assert data[0] == { + "identifier": ConnectionType.postgres.value, + "type": SystemType.database.value, + } + assert data[1] == { + "identifier": SaaSType.stripe.value, + "type": SystemType.saas.value, + } + + resp = api_client.get(url + "?search=Re", headers=auth_header) + assert resp.status_code == 200 + data = resp.json()["items"] + assert len(data) == 3 + assert data == [ + { + "identifier": ConnectionType.postgres.value, + "type": SystemType.database.value, + }, + { + "identifier": ConnectionType.redshift.value, + "type": SystemType.database.value, + }, + {"identifier": SaaSType.outreach.value, "type": SystemType.saas.value}, + ] + def test_search_system_type(self, api_client, generate_auth_header, url): auth_header = generate_auth_header(scopes=[CONNECTION_TYPE_READ])