From 882ae547116c996dfc44560a4f718af5a20eb467 Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Wed, 6 Nov 2024 16:19:00 +0100 Subject: [PATCH 1/6] update endpoints for new taxonomy functionality --- .../api/api/v1/endpoints/generic_overrides.py | 95 +++++++++++++- .../api/api/v1/endpoints/router_factory.py | 1 + tests/ctl/core/test_api.py | 124 ++++++++++++++++++ 3 files changed, 217 insertions(+), 3 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index 52e9b95982..d27849596b 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union +from typing import List, Optional, Union, Dict from fastapi import APIRouter, Depends, Query, Security from fastapi_pagination import Page, Params @@ -7,7 +7,9 @@ from sqlalchemy import not_ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.sql.expression import select +from starlette import status +from fides.api.db.base_class import get_key_from_data from fides.api.db.crud import list_resource_query from fides.api.db.ctl_session import get_async_db from fides.api.models.connectionconfig import ConnectionConfig @@ -15,17 +17,20 @@ from fides.api.oauth.utils import verify_oauth_client from fides.api.schemas.filter_params import FilterParams from fides.api.util.filter_utils import apply_filters_to_query -from fides.common.api.scope_registry import DATASET_READ +from fides.common.api.scope_registry import DATASET_READ, DATA_USE_CREATE, DATA_CATEGORY_CREATE, DATA_SUBJECT_CREATE from fides.common.api.v1.urn_registry import V1_URL_PREFIX from fides.api.models.sql_models import ( # type: ignore[attr-defined] # isort: skip - Dataset as CtlDataset, + Dataset as CtlDataset, DataUse, DataCategory, DataSubject, ) # We create routers to override specific methods in those defined in generic.py # when we need more custom implementations for only some of the methods in a router. dataset_router = APIRouter(tags=["Dataset"], prefix=V1_URL_PREFIX) +data_use_router = APIRouter(tags=["DataUse"], prefix=V1_URL_PREFIX) +data_category_router = APIRouter(tags=["DataCategory"], prefix=V1_URL_PREFIX) +data_subject_router = APIRouter(tags=["DataSubject"], prefix=V1_URL_PREFIX) @dataset_router.get( @@ -85,5 +90,89 @@ async def list_dataset_paginated( return await async_paginate(db, filtered_query, pagination_params) +async def create_with_key(data, model, db): + """ + helper to create taxonomy resource when not given a fides_key + """ + # If data with same name exists but is disabled, re-enable it + disabled_resource_with_name = db.query(model).filter( + model.key == data.name, + model.active == False, + ) + if disabled_resource_with_name: + return model.update(db=db, data=disabled_resource_with_name, active=True) + data.fides_key = get_key_from_data({"key": data.fides_key, "name": data.name}, model.__name__) + return model.create(db=db, data=data.model_dump(mode="json")) + + +@data_use_router.post( +"/data_use", + dependencies=[Security(verify_oauth_client, scopes=[DATA_USE_CREATE])], + response_model=DataUse, + status_code=status.HTTP_201_CREATED, + name="Create", +) +async def create_data_use( + data_use: DataUse, + db: AsyncSession = Depends(get_async_db), +) -> Dict: + """ + Create a data use. Updates existing data use if data use with key already exists and is disabled. + """ + if data_use.fides_key is None: + await create_with_key(data_use, DataUse, db) + + # add test that this fails if key already exists + return await DataUse.create(db=db, data=data_use.model_dump(mode="json")) + + +@data_category_router.post( + "/data_category", + dependencies=[Security(verify_oauth_client, scopes=[DATA_CATEGORY_CREATE])], + response_model=DataCategory, + status_code=status.HTTP_201_CREATED, + name="Create", +) +async def create_data_category( + data_category: DataCategory, + db: AsyncSession = Depends(get_async_db), +) -> Dict: + """ + Create a data category + """ + + if data_category.fides_key is None: + await create_with_key(data_category, DataCategory, db) + + # add test that this fails if key already exists + return await DataCategory.create(db=db, data=data_category.model_dump(mode="json")) + + +@data_subject_router.post( + "/data_subject", + dependencies=[Security(verify_oauth_client, scopes=[DATA_SUBJECT_CREATE])], + response_model=DataSubject, + status_code=status.HTTP_201_CREATED, + name="Create", +) +async def create_data_subject( + data_subject: DataSubject, + db: AsyncSession = Depends(get_async_db), +) -> Dict: + """ + Create a data subject + """ + + if data_subject.fides_key is None: + await create_with_key(data_subject, DataSubject, db) + + # add test that this fails if key already exists + return await DataSubject.create(db=db, data=data_subject.model_dump(mode="json")) + + + GENERIC_OVERRIDES_ROUTER = APIRouter() GENERIC_OVERRIDES_ROUTER.include_router(dataset_router) +GENERIC_OVERRIDES_ROUTER.include_router(data_use_router) +GENERIC_OVERRIDES_ROUTER.include_router(data_category_router) +GENERIC_OVERRIDES_ROUTER.include_router(data_subject_router) diff --git a/src/fides/api/api/v1/endpoints/router_factory.py b/src/fides/api/api/v1/endpoints/router_factory.py index 1a5e34ce29..e9025eaa01 100644 --- a/src/fides/api/api/v1/endpoints/router_factory.py +++ b/src/fides/api/api/v1/endpoints/router_factory.py @@ -149,6 +149,7 @@ async def create( raise errors.ForbiddenIsDefaultTaxonomyError( model_type, resource.fides_key, action="create" ) + return await create_resource(sql_model, resource.model_dump(mode="json"), db) return router diff --git a/tests/ctl/core/test_api.py b/tests/ctl/core/test_api.py index 36801ddac2..1cac6fe5c0 100644 --- a/tests/ctl/core/test_api.py +++ b/tests/ctl/core/test_api.py @@ -2925,6 +2925,130 @@ def test_system_manager_gets_403_if_system_not_found( ) assert result.status_code == HTTP_403_FORBIDDEN +@pytest.mark.integration +class TestDefaultTaxonomyCrudOverrides: + @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) + def test_api_cannot_create_if_generated_fides_key_conflicts_with_existing( + self, + test_config: FidesConfig, + endpoint: str, + ) -> None: + """Ensure we can create taxonomy elements without specifying a fides_key""" + # get a default taxonomy element as a sample resource + resource = getattr(DEFAULT_TAXONOMY, endpoint)[0] + resource = TAXONOMY_EXTENSIONS[endpoint]( + **resource.model_dump(mode="json") + ) # cast resource to extended model + # This name will conflict with existing resource + resource.name = resource.fides_key + resource.fides_key = None + json_resource = resource.json(exclude_none=True) + token_scopes: List[str] = [f"{CLI_SCOPE_PREFIX_MAPPING[endpoint]}:{CREATE}"] + auth_header = generate_auth_header(scopes=token_scopes) + result = _api.create( + url=test_config.cli.server_url, + headers=auth_header, + resource_type=endpoint, + json_resource=json_resource, + ) + assert result.status_code == HTTP_409_CONFLICT + + @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) + def test_api_can_create_without_explicit_fides_key( + self, + test_config: FidesConfig, + endpoint: str, + ) -> None: + """Ensure we can create taxonomy elements without specifying a fides_key""" + # get a default taxonomy element as a sample resource + resource = getattr(DEFAULT_TAXONOMY, endpoint)[0] + resource = TAXONOMY_EXTENSIONS[endpoint]( + **resource.model_dump(mode="json") + ) # cast resource to extended model + # Build unique name based on sample name + resource.name = resource.name + "my new resource" + resource.fides_key = None + json_resource = resource.json(exclude_none=True) + token_scopes: List[str] = [f"{CLI_SCOPE_PREFIX_MAPPING[endpoint]}:{CREATE}"] + auth_header = generate_auth_header(scopes=token_scopes) + result = _api.create( + url=test_config.cli.server_url, + headers=auth_header, + resource_type=endpoint, + json_resource=json_resource, + ) + assert result.status_code == 201 + assert result.json()["active"] is True + new_key = result.json()["fides_key"] + assert "my_new_resource" in new_key + + result = _api.get( + url=test_config.cli.server_url, + headers=test_config.user.auth_header, + resource_type=endpoint, + resource_id=new_key, + ) + assert result.json()["active"] is True + + @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) + def test_api_can_update_active_when_creating_with_same_name( + self, + test_config: FidesConfig, + endpoint: str, + ) -> None: + """ + If we attempt to create a new resource with the same name as an existing inactive resource, + but with no explicit fides_key, we should update the existing resource to be active + """ + resource = getattr(DEFAULT_TAXONOMY, endpoint)[0] + resource = TAXONOMY_EXTENSIONS[endpoint]( + **resource.model_dump(mode="json") + ) # cast resource to extended model + resource.active = False + json_resource = resource.json(exclude_none=True) + # First, update the existing resource as inactive so we can use it to test + result = _api.update( + url=test_config.cli.server_url, + headers=test_config.user.auth_header, + resource_type=endpoint, + json_resource=json_resource, + ) + assert result.status_code == 200 + assert result.json()["active"] is False + + # Confirm it was updated to inactive + result = _api.get( + url=test_config.cli.server_url, + headers=test_config.user.auth_header, + resource_type=endpoint, + resource_id=resource.fides_key, + ) + assert result.json()["active"] is False + + # Now attempt to create another resource with a name that will generate the same fides_key + # as the inactive resource + + resource.name = resource.name # explicitly using the same name + resource.fides_key = None + json_resource = resource.json(exclude_none=True) + result = _api.create( + url=test_config.cli.server_url, + headers=test_config.user.auth_header, + resource_type=endpoint, + json_resource=json_resource, + ) + assert result.status_code == 200 + assert result.json()["active"] is True + + # Confirm the existing resource was updated to active + result = _api.get( + url=test_config.cli.server_url, + headers=test_config.user.auth_header, + resource_type=endpoint, + resource_id=resource.fides_key, + ) + assert result.json()["active"] is True + @pytest.mark.integration class TestDefaultTaxonomyCrud: From 465a28dab2d1957186871d513c40738b47e381e2 Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Wed, 6 Nov 2024 16:33:25 +0100 Subject: [PATCH 2/6] formatting, lint --- .../api/api/v1/endpoints/generic_overrides.py | 51 +++++++++++-------- tests/ctl/core/test_api.py | 21 ++++---- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index d27849596b..4b18247bb9 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union, Dict +from typing import List, Optional, Union, Dict, Type from fastapi import APIRouter, Depends, Query, Security from fastapi_pagination import Page, Params @@ -17,11 +17,19 @@ from fides.api.oauth.utils import verify_oauth_client from fides.api.schemas.filter_params import FilterParams from fides.api.util.filter_utils import apply_filters_to_query -from fides.common.api.scope_registry import DATASET_READ, DATA_USE_CREATE, DATA_CATEGORY_CREATE, DATA_SUBJECT_CREATE +from fides.common.api.scope_registry import ( + DATASET_READ, + DATA_USE_CREATE, + DATA_CATEGORY_CREATE, + DATA_SUBJECT_CREATE, +) from fides.common.api.v1.urn_registry import V1_URL_PREFIX from fides.api.models.sql_models import ( # type: ignore[attr-defined] # isort: skip - Dataset as CtlDataset, DataUse, DataCategory, DataSubject, + Dataset as CtlDataset, + DataUse, + DataCategory, + DataSubject, ) # We create routers to override specific methods in those defined in generic.py @@ -90,39 +98,45 @@ async def list_dataset_paginated( return await async_paginate(db, filtered_query, pagination_params) -async def create_with_key(data, model, db): +async def create_with_key( + data: Union[DataUse, DataCategory, DataSubject], + model: Type[Union[DataUse, DataCategory, DataSubject]], + db: AsyncSession, +) -> Dict: """ - helper to create taxonomy resource when not given a fides_key + Helper to create taxonomy resource when not given a fides_key. + Automatically re-enables disabled resources with the same name. """ # If data with same name exists but is disabled, re-enable it disabled_resource_with_name = db.query(model).filter( model.key == data.name, - model.active == False, - ) + model.active is False, + ) if disabled_resource_with_name: return model.update(db=db, data=disabled_resource_with_name, active=True) - data.fides_key = get_key_from_data({"key": data.fides_key, "name": data.name}, model.__name__) + data.fides_key = get_key_from_data( + {"key": data.fides_key, "name": data.name}, model.__name__ + ) return model.create(db=db, data=data.model_dump(mode="json")) @data_use_router.post( -"/data_use", + "/data_use", dependencies=[Security(verify_oauth_client, scopes=[DATA_USE_CREATE])], response_model=DataUse, status_code=status.HTTP_201_CREATED, name="Create", ) async def create_data_use( - data_use: DataUse, - db: AsyncSession = Depends(get_async_db), + data_use: DataUse, + db: AsyncSession = Depends(get_async_db), ) -> Dict: """ - Create a data use. Updates existing data use if data use with key already exists and is disabled. + Create a data use. Updates existing data use if data use with name already exists and is disabled. """ if data_use.fides_key is None: await create_with_key(data_use, DataUse, db) - # add test that this fails if key already exists return await DataUse.create(db=db, data=data_use.model_dump(mode="json")) @@ -134,8 +148,8 @@ async def create_data_use( name="Create", ) async def create_data_category( - data_category: DataCategory, - db: AsyncSession = Depends(get_async_db), + data_category: DataCategory, + db: AsyncSession = Depends(get_async_db), ) -> Dict: """ Create a data category @@ -144,7 +158,6 @@ async def create_data_category( if data_category.fides_key is None: await create_with_key(data_category, DataCategory, db) - # add test that this fails if key already exists return await DataCategory.create(db=db, data=data_category.model_dump(mode="json")) @@ -156,8 +169,8 @@ async def create_data_category( name="Create", ) async def create_data_subject( - data_subject: DataSubject, - db: AsyncSession = Depends(get_async_db), + data_subject: DataSubject, + db: AsyncSession = Depends(get_async_db), ) -> Dict: """ Create a data subject @@ -166,11 +179,9 @@ async def create_data_subject( if data_subject.fides_key is None: await create_with_key(data_subject, DataSubject, db) - # add test that this fails if key already exists return await DataSubject.create(db=db, data=data_subject.model_dump(mode="json")) - GENERIC_OVERRIDES_ROUTER = APIRouter() GENERIC_OVERRIDES_ROUTER.include_router(dataset_router) GENERIC_OVERRIDES_ROUTER.include_router(data_use_router) diff --git a/tests/ctl/core/test_api.py b/tests/ctl/core/test_api.py index 1cac6fe5c0..f5353aec73 100644 --- a/tests/ctl/core/test_api.py +++ b/tests/ctl/core/test_api.py @@ -2925,13 +2925,14 @@ def test_system_manager_gets_403_if_system_not_found( ) assert result.status_code == HTTP_403_FORBIDDEN + @pytest.mark.integration class TestDefaultTaxonomyCrudOverrides: @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) def test_api_cannot_create_if_generated_fides_key_conflicts_with_existing( - self, - test_config: FidesConfig, - endpoint: str, + self, + test_config: FidesConfig, + endpoint: str, ) -> None: """Ensure we can create taxonomy elements without specifying a fides_key""" # get a default taxonomy element as a sample resource @@ -2955,9 +2956,9 @@ def test_api_cannot_create_if_generated_fides_key_conflicts_with_existing( @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) def test_api_can_create_without_explicit_fides_key( - self, - test_config: FidesConfig, - endpoint: str, + self, + test_config: FidesConfig, + endpoint: str, ) -> None: """Ensure we can create taxonomy elements without specifying a fides_key""" # get a default taxonomy element as a sample resource @@ -2992,9 +2993,9 @@ def test_api_can_create_without_explicit_fides_key( @pytest.mark.parametrize("endpoint", TAXONOMY_ENDPOINTS) def test_api_can_update_active_when_creating_with_same_name( - self, - test_config: FidesConfig, - endpoint: str, + self, + test_config: FidesConfig, + endpoint: str, ) -> None: """ If we attempt to create a new resource with the same name as an existing inactive resource, @@ -3028,7 +3029,7 @@ def test_api_can_update_active_when_creating_with_same_name( # Now attempt to create another resource with a name that will generate the same fides_key # as the inactive resource - resource.name = resource.name # explicitly using the same name + resource.name = resource.name # explicitly using the same name resource.fides_key = None json_resource = resource.json(exclude_none=True) result = _api.create( From eafc40a72a34236d309f211bab7d8dd470b4c675 Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Wed, 6 Nov 2024 16:38:40 +0100 Subject: [PATCH 3/6] add changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2cdb0cf6..2e8cd035d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ The types of changes are: - Added DataHub integration config [#5401](https://github.com/ethyca/fides/pull/5401) - Added keepalive settings to the Redshift integration [#5433](https://github.com/ethyca/fides/pull/5433) +### Changed +- Updated POST taxonomy endpoints to handle creating resources without specifying fides_key [#5468](https://github.com/ethyca/fides/pull/5468) + ### Developer Experience - Added Carbon Icons to FidesUI [#5416](https://github.com/ethyca/fides/pull/5416) From 2925266ad60d59b0d4bbf86dba5ee23b591828bb Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Wed, 6 Nov 2024 16:41:12 +0100 Subject: [PATCH 4/6] isort --- src/fides/api/api/v1/endpoints/generic_overrides.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index 4b18247bb9..28e2bfc573 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union, Dict, Type +from typing import Dict, List, Optional, Type, Union from fastapi import APIRouter, Depends, Query, Security from fastapi_pagination import Page, Params @@ -18,10 +18,10 @@ from fides.api.schemas.filter_params import FilterParams from fides.api.util.filter_utils import apply_filters_to_query from fides.common.api.scope_registry import ( - DATASET_READ, - DATA_USE_CREATE, DATA_CATEGORY_CREATE, DATA_SUBJECT_CREATE, + DATA_USE_CREATE, + DATASET_READ, ) from fides.common.api.v1.urn_registry import V1_URL_PREFIX From cc3ea23a4588648c65df1936261723995a1441e6 Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Wed, 6 Nov 2024 16:52:59 +0100 Subject: [PATCH 5/6] format --- .../api/api/v1/endpoints/generic_overrides.py | 16 +++++++--------- tests/fixtures/saas/zendesk_fixtures.py | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index 28e2bfc573..03e97c8126 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -16,6 +16,7 @@ from fides.api.models.datasetconfig import DatasetConfig from fides.api.oauth.utils import verify_oauth_client from fides.api.schemas.filter_params import FilterParams +from fides.api.schemas.taxonomy_extensions import DataCategory, DataSubject, DataUse from fides.api.util.filter_utils import apply_filters_to_query from fides.common.api.scope_registry import ( DATA_CATEGORY_CREATE, @@ -27,9 +28,6 @@ from fides.api.models.sql_models import ( # type: ignore[attr-defined] # isort: skip Dataset as CtlDataset, - DataUse, - DataCategory, - DataSubject, ) # We create routers to override specific methods in those defined in generic.py @@ -109,15 +107,15 @@ async def create_with_key( """ # If data with same name exists but is disabled, re-enable it disabled_resource_with_name = db.query(model).filter( - model.key == data.name, + model.key == data.name, # type: ignore[union-attr] model.active is False, ) if disabled_resource_with_name: - return model.update(db=db, data=disabled_resource_with_name, active=True) + return model.update(db=db, data=disabled_resource_with_name, active=True) # type: ignore[union-attr] data.fides_key = get_key_from_data( {"key": data.fides_key, "name": data.name}, model.__name__ ) - return model.create(db=db, data=data.model_dump(mode="json")) + return model.create(db=db, data=data.model_dump(mode="json")) # type: ignore[union-attr] @data_use_router.post( @@ -137,7 +135,7 @@ async def create_data_use( if data_use.fides_key is None: await create_with_key(data_use, DataUse, db) - return await DataUse.create(db=db, data=data_use.model_dump(mode="json")) + return await DataUse.create(db=db, data=data_use.model_dump(mode="json")) # type: ignore[attr-defined] @data_category_router.post( @@ -158,7 +156,7 @@ async def create_data_category( if data_category.fides_key is None: await create_with_key(data_category, DataCategory, db) - return await DataCategory.create(db=db, data=data_category.model_dump(mode="json")) + return await DataCategory.create(db=db, data=data_category.model_dump(mode="json")) # type: ignore[attr-defined] @data_subject_router.post( @@ -179,7 +177,7 @@ async def create_data_subject( if data_subject.fides_key is None: await create_with_key(data_subject, DataSubject, db) - return await DataSubject.create(db=db, data=data_subject.model_dump(mode="json")) + return await DataSubject.create(db=db, data=data_subject.model_dump(mode="json")) # type: ignore[attr-defined] GENERIC_OVERRIDES_ROUTER = APIRouter() diff --git a/tests/fixtures/saas/zendesk_fixtures.py b/tests/fixtures/saas/zendesk_fixtures.py index 0c17d9d413..bb623353b5 100644 --- a/tests/fixtures/saas/zendesk_fixtures.py +++ b/tests/fixtures/saas/zendesk_fixtures.py @@ -40,7 +40,7 @@ def zendesk_erasure_identity_email() -> str: class ZendeskClient: def __init__(self, secrets: Dict[str, Any]): self.base_url = f"https://{secrets['domain']}" - self.auth = secrets["username"] , secrets["api_key"] + self.auth = secrets["username"], secrets["api_key"] def create_user(self, email): return requests.post( From 477c17ebcb7e9878a75bd5dd0a02c0f5665690ce Mon Sep 17 00:00:00 2001 From: eastandwestwind Date: Tue, 19 Nov 2024 16:26:45 +0100 Subject: [PATCH 6/6] CR changes --- src/fides/api/api/v1/endpoints/generic_overrides.py | 2 +- tests/ctl/core/test_api.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fides/api/api/v1/endpoints/generic_overrides.py b/src/fides/api/api/v1/endpoints/generic_overrides.py index 03e97c8126..9fbde4b3e9 100644 --- a/src/fides/api/api/v1/endpoints/generic_overrides.py +++ b/src/fides/api/api/v1/endpoints/generic_overrides.py @@ -111,7 +111,7 @@ async def create_with_key( model.active is False, ) if disabled_resource_with_name: - return model.update(db=db, data=disabled_resource_with_name, active=True) # type: ignore[union-attr] + return model.update(db=db, data=data, active=True) # type: ignore[union-attr] data.fides_key = get_key_from_data( {"key": data.fides_key, "name": data.name}, model.__name__ ) diff --git a/tests/ctl/core/test_api.py b/tests/ctl/core/test_api.py index bc285a0fe7..f63c9d037f 100644 --- a/tests/ctl/core/test_api.py +++ b/tests/ctl/core/test_api.py @@ -3028,9 +3028,10 @@ class TestDefaultTaxonomyCrudOverrides: def test_api_cannot_create_if_generated_fides_key_conflicts_with_existing( self, test_config: FidesConfig, + generate_auth_header, endpoint: str, ) -> None: - """Ensure we can create taxonomy elements without specifying a fides_key""" + """Ensure we cannot create taxonomy elements if fides key conflicts with existing key""" # get a default taxonomy element as a sample resource resource = getattr(DEFAULT_TAXONOMY, endpoint)[0] resource = TAXONOMY_EXTENSIONS[endpoint]( @@ -3054,6 +3055,7 @@ def test_api_cannot_create_if_generated_fides_key_conflicts_with_existing( def test_api_can_create_without_explicit_fides_key( self, test_config: FidesConfig, + generate_auth_header, endpoint: str, ) -> None: """Ensure we can create taxonomy elements without specifying a fides_key"""