Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding query param key to Privacy Center config #4939

Merged
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 @@ -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
Loading