diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3abc5a6e..330e1173e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/fides/api/schemas/privacy_center_config.py b/src/fides/api/schemas/privacy_center_config.py index 962df307f0..0777e59c62 100644 --- a/src/fides/api/schemas/privacy_center_config.py +++ b/src/fides/api/schemas/privacy_center_config.py @@ -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 diff --git a/tests/ops/schemas/test_privacy_center_config.py b/tests/ops/schemas/test_privacy_center_config.py index c23e4b37af..b36c59b488 100644 --- a/tests/ops/schemas/test_privacy_center_config.py +++ b/tests/ops/schemas/test_privacy_center_config.py @@ -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):