Skip to content

Commit

Permalink
fix bug with censor_config
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsachs committed Feb 22, 2023
1 parent b053049 commit 48f0394
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fides/core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def censor_config(config: Union[FidesConfig, Dict[str, Any]]) -> Dict[str, Any]:
data = as_dict[key]
filtered[key] = {}
for field in value:
filtered[key][field] = data[field]
if field in data:
filtered[key][field] = data[field]

return filtered

Expand Down
43 changes: 43 additions & 0 deletions tests/ops/api/v1/endpoints/test_config_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ def url(self) -> str:
def payload(self):
return {"storage": {"active_default_storage_type": StorageType.s3.value}}

@pytest.fixture(scope="function")
def payload_single_notification_property(self):
return {"notifications": {"notification_service_type": "twilio_email"}}

def test_get_application_config_unauthenticated(self, api_client: TestClient, url):
response = api_client.get(url, headers={})
assert 401 == response.status_code
Expand Down Expand Up @@ -309,6 +313,7 @@ def test_get_application_config(
url,
db: Session,
payload,
payload_single_notification_property,
):
# first we PATCH in some settings
auth_header = generate_auth_header([scopes.CONFIG_UPDATE])
Expand All @@ -325,6 +330,44 @@ def test_get_application_config(
url,
headers=auth_header,
params={"api_set": True},
)
assert response.status_code == 200
response_settings = response.json()
assert (
response_settings["storage"]["active_default_storage_type"]
== payload["storage"]["active_default_storage_type"]
)

# now PATCH in a single notification property
auth_header = generate_auth_header([scopes.CONFIG_UPDATE])
response = api_client.patch(
url,
headers=auth_header,
json=payload_single_notification_property,
)
assert response.status_code == 200

# then we test that we can GET it
auth_header = generate_auth_header([scopes.CONFIG_READ])
response = api_client.get(
url,
headers=auth_header,
params={"api_set": True},
)
assert response.status_code == 200
response_settings = response.json()
assert (
response_settings["storage"]["active_default_storage_type"]
== payload["storage"]["active_default_storage_type"]
)
assert (
response_settings["notifications"]["notification_service_type"]
== payload_single_notification_property["notifications"][
"notification_service_type"
].upper()
)


class TestDeleteApplicationConfig:
@pytest.fixture(scope="function")
def url(self) -> str:
Expand Down

0 comments on commit 48f0394

Please sign in to comment.