Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Support case-insensitive connection type search [Unticketed] #1133

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 34 additions & 1 deletion tests/ops/api/v1/endpoints/test_connection_template_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import List
from unittest import mock

import pytest
Expand Down Expand Up @@ -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])

Expand Down