Skip to content

Commit

Permalink
Adding query param key to Privacy Center config (#4939)
Browse files Browse the repository at this point in the history
  • Loading branch information
galvana authored May 31, 2024
1 parent c805702 commit d50f5b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The types of changes are:
- Added erasure support to the Recurly integration [#4891](https://github.com/ethyca/fides/pull/4891)
- Added UI for configuring integrations for detection/discovery [#4922](https://github.com/ethyca/fides/pull/4922)
- Request overrides for opt-in and opt-out consent requests [#4920](https://github.com/ethyca/fides/pull/4920)
- Added query_param_key to Privacy Center schema [#4939](https://github.com/ethyca/fides/pull/4939)

### Changed
- Set default ports for local development of client projects (:3001 for privacy center and :3000 for admin-ui) [#4912](https://github.com/ethyca/fides/pull/4912)
Expand Down
11 changes: 9 additions & 2 deletions src/fides/api/schemas/privacy_center_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,18 @@ class CustomPrivacyRequestField(FidesSchema):
required: Optional[bool] = True
default_value: Optional[str] = None
hidden: Optional[bool] = False
query_param_key: Optional[str] = None

@root_validator
def validate_default_value(cls, values: Dict[str, Any]) -> Dict[str, Any]:
if values.get("hidden") and values.get("default_value") is None:
raise ValueError("default_value is required when hidden is True")
if (
values.get("hidden")
and values.get("default_value") is None
and values.get("query_param_key") is None
):
raise ValueError(
"default_value or query_param_key are required when hidden is True"
)
return values


Expand Down
10 changes: 9 additions & 1 deletion tests/ops/schemas/test_privacy_center_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ def privacy_center_config(self) -> PrivacyCenterConfig:
def test_valid_custom_privacy_request_field(self):
CustomPrivacyRequestField(label="Tenant ID", default_value="123", hidden=True)

def test_valid_custom_privacy_request_field_with_query_param(self):
CustomPrivacyRequestField(
label="Tenant ID", query_param_key="site_id", hidden=True
)

def test_custom_privacy_request_field_with_missing_default_value(self):
with pytest.raises(ValidationError) as exc:
CustomPrivacyRequestField(label="Tenant ID", hidden=True)
assert "default_value is required when hidden is True" in str(exc.value)
assert (
"default_value or query_param_key are required when hidden is True"
in str(exc.value)
)

def test_custom_privacy_request_fields_with_missing_values(self):
with pytest.raises(ValidationError):
Expand Down

0 comments on commit d50f5b3

Please sign in to comment.