Skip to content

Commit

Permalink
Merge branch 'main' into aking/4165/vendors-disclosed
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking committed Oct 13, 2023
2 parents 65713f2 + 8d47825 commit e84dfa6
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The types of changes are:
- Styling improvements for the fides.js consent banners and modals [#4222](https://github.com/ethyca/fides/pull/4222)
- Changed vendor form on configuring consent page to use two-part selection for consent uses [#4251](https://github.com/ethyca/fides/pull/4251)
- Vendors disclosed string is now narrowed to only the vendors shown in the UI, not the whole GVL [#4250](https://github.com/ethyca/fides/pull/4250)
- Changed naming convention "fides_string" instead of "tc_string" for developer friendly consent API's [#4267](https://github.com/ethyca/fides/pull/4267)

### Fixed
- TCF overlay can initialize its consent preferences from a cookie [#4124](https://github.com/ethyca/fides/pull/4124)
Expand Down
18 changes: 9 additions & 9 deletions src/fides/api/api/v1/endpoints/privacy_preference_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def save_privacy_preferences_with_verified_identity(
Creates historical records for these preferences for record keeping, and also updates current preferences.
Creates a privacy request to propagate preferences to third party systems where applicable.
"""
tc_string: Optional[str] = data.tc_string
fides_string: Optional[str] = data.fides_string
data = update_request_with_decoded_tc_string_fields(data, db)

verify_privacy_notice_and_historical_records(
Expand Down Expand Up @@ -372,8 +372,8 @@ def save_privacy_preferences_with_verified_identity(
original_request_data=data,
)
)
saved_preferences_response.tc_mobile_data = convert_tc_string_to_mobile_data(
tc_string
saved_preferences_response.fides_mobile_data = convert_tc_string_to_mobile_data(
fides_string
)

return saved_preferences_response
Expand Down Expand Up @@ -704,19 +704,19 @@ def update_request_with_decoded_tc_string_fields(
request_body: PrivacyPreferencesRequest, db: Session
) -> PrivacyPreferencesRequest:
"""Update the request body with the decoded values of the TC string if applicable"""
if request_body.tc_string:
if request_body.fides_string:
tcf_contents: TCFExperienceContents = get_tcf_contents(
db
) # TODO cache this so we're not building each time privacy preference is saved
try:
decoded_preference_request_body: TCStringFidesPreferences = (
decode_tc_string_to_preferences(request_body.tc_string, tcf_contents)
decode_tc_string_to_preferences(request_body.fides_string, tcf_contents)
)
except DecodeTCStringError as exc:
raise HTTPException(status_code=HTTP_400_BAD_REQUEST, detail=exc.args[0])

# Remove the TC string from the request body now that we've decoded it
request_body.tc_string = None
request_body.fides_string = None
# Add the individual sections from the TC string to the request body
for decoded_tcf_section in decoded_preference_request_body.__fields__:
setattr(
Expand Down Expand Up @@ -746,7 +746,7 @@ def save_privacy_preferences(
Creates historical records for these preferences for record keeping, and also updates current preferences.
Creates a privacy request to propagate preferences to third party systems if applicable.
"""
tc_string: Optional[str] = data.tc_string
fides_string: Optional[str] = data.fides_string
data = update_request_with_decoded_tc_string_fields(data, db)

verify_privacy_notice_and_historical_records(
Expand Down Expand Up @@ -778,8 +778,8 @@ def save_privacy_preferences(
original_request_data=data,
)
)
saved_preferences_response.tc_mobile_data = convert_tc_string_to_mobile_data(
tc_string
saved_preferences_response.fides_mobile_data = convert_tc_string_to_mobile_data(
fides_string
)

return saved_preferences_response
Expand Down
12 changes: 6 additions & 6 deletions src/fides/api/schemas/privacy_experience.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ class ExperienceMeta(FidesSchema):
description="A hashed value that can be compared to previously-fetched "
"hash values to determine if the Experience has meaningfully changed"
)
accept_all_tc_string: Optional[str] = Field(
description="The TC string corresponding to a user opting in to all "
accept_all_fides_string: Optional[str] = Field(
description="The fides string (TC String + AC String) corresponding to a user opting in to all "
"available options"
)
accept_all_tc_mobile_data: Optional[TCMobileData] = None
reject_all_tc_string: Optional[str] = Field(
description="The TC string corresponding to a user opting out of all "
accept_all_fides_mobile_data: Optional[TCMobileData] = None
reject_all_fides_string: Optional[str] = Field(
description="The fides string (TC String + AC String) corresponding to a user opting out of all "
"available options"
)
reject_all_tc_mobile_data: Optional[TCMobileData] = None
reject_all_fides_mobile_data: Optional[TCMobileData] = None


class PrivacyExperienceResponse(TCFExperienceContents, PrivacyExperienceWithId):
Expand Down
10 changes: 5 additions & 5 deletions src/fides/api/schemas/privacy_preference.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class PrivacyPreferencesRequest(TCStringFidesPreferences):

browser_identity: Identity
code: Optional[SafeStr]
tc_string: Optional[str] = Field(
description="If supplied, TC string is decoded and preferences saved for purpose_consent, "
fides_string: Optional[str] = Field(
description="If supplied, TC strings and AC strings are decoded and preferences saved for purpose_consent, "
"purpose_legitimate_interests, vendor_consent, vendor_legitimate_interests, and special_features"
)
preferences: conlist(ConsentOptionCreate, max_items=200) = [] # type: ignore
Expand Down Expand Up @@ -151,11 +151,11 @@ def tcf_duplicates_detected(preference_list: List) -> bool:
f"Duplicate preferences saved against TCF component: '{field_name}'"
)

if values.get("tc_string"):
if values.get("fides_string"):
for field in TCStringFidesPreferences.__fields__:
if values.get(field):
raise ValueError(
f"Cannot supply value for '{field}' and 'tc_string' simultaneously when saving privacy preferences."
f"Cannot supply value for '{field}' and 'fides_string' simultaneously when saving privacy preferences."
)

return values
Expand Down Expand Up @@ -334,7 +334,7 @@ class SavePrivacyPreferencesResponse(FidesSchema):
special_feature_preferences: List[CurrentPrivacyPreferenceSchema] = []
system_consent_preferences: List[CurrentPrivacyPreferenceSchema] = []
system_legitimate_interests_preferences: List[CurrentPrivacyPreferenceSchema] = []
tc_mobile_data: Optional[TCMobileData] = None
fides_mobile_data: Optional[TCMobileData] = None


class CurrentPrivacyPreferenceReportingSchema(TCFAttributes):
Expand Down
8 changes: 4 additions & 4 deletions src/fides/api/util/tcf/experience_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def build_experience_tcf_meta(tcf_contents: TCFExperienceContents) -> Dict:

return ExperienceMeta(
version_hash=build_tcf_version_hash(tcf_contents),
accept_all_tc_string=accept_all_mobile_data.IABTCF_TCString,
reject_all_tc_string=reject_all_mobile_data.IABTCF_TCString,
accept_all_tc_mobile_data=accept_all_mobile_data,
reject_all_tc_mobile_data=reject_all_mobile_data,
accept_all_fides_string=accept_all_mobile_data.IABTCF_TCString,
reject_all_fides_string=reject_all_mobile_data.IABTCF_TCString,
accept_all_fides_mobile_data=accept_all_mobile_data,
reject_all_fides_mobile_data=reject_all_mobile_data,
).dict()
32 changes: 16 additions & 16 deletions tests/ops/api/v1/endpoints/test_privacy_experience_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ def test_get_privacy_experiences_nonexistent_fides_user_device_id_filter(
assert resp["privacy_notices"][0]["outdated_served"] is None
meta = resp["meta"]
assert not meta["version_hash"]
assert not meta["accept_all_tc_string"]
assert not meta["accept_all_tc_mobile_data"]
assert not meta["reject_all_tc_string"]
assert not meta["reject_all_tc_mobile_data"]
assert not meta["accept_all_fides_string"]
assert not meta["accept_all_fides_mobile_data"]
assert not meta["reject_all_fides_string"]
assert not meta["reject_all_fides_mobile_data"]

@pytest.mark.usefixtures(
"privacy_notice_us_ca_provide",
Expand Down Expand Up @@ -690,10 +690,10 @@ def test_tcf_not_enabled(
assert resp.json()["items"][0]["tcf_system_consents"] == []
meta = resp.json()["items"][0]["meta"]
assert not meta["version_hash"]
assert not meta["accept_all_tc_string"]
assert not meta["accept_all_tc_mobile_data"]
assert not meta["reject_all_tc_string"]
assert not meta["reject_all_tc_mobile_data"]
assert not meta["accept_all_fides_string"]
assert not meta["accept_all_fides_mobile_data"]
assert not meta["reject_all_fides_string"]
assert not meta["reject_all_fides_mobile_data"]

@pytest.mark.usefixtures(
"privacy_experience_france_overlay",
Expand Down Expand Up @@ -723,10 +723,10 @@ def test_tcf_enabled_but_no_relevant_systems(
assert resp.json()["items"][0]["gvl"] == {}
meta = resp.json()["items"][0]["meta"]
assert not meta["version_hash"]
assert not meta["accept_all_tc_string"]
assert not meta["accept_all_tc_mobile_data"]
assert not meta["reject_all_tc_string"]
assert not meta["reject_all_tc_mobile_data"]
assert not meta["accept_all_fides_string"]
assert not meta["accept_all_fides_mobile_data"]
assert not meta["reject_all_fides_string"]
assert not meta["reject_all_fides_mobile_data"]

# Has notices = True flag will keep this experience from appearing altogether
resp = api_client.get(
Expand Down Expand Up @@ -824,10 +824,10 @@ def test_tcf_enabled_with_overlapping_vendors(
assert resp.json()["items"][0]["gvl"]["gvlSpecificationVersion"] == 3
meta = resp.json()["items"][0]["meta"]
assert meta["version_hash"] == "75fb2dafef58"
assert meta["accept_all_tc_string"]
assert meta["accept_all_tc_mobile_data"]
assert meta["reject_all_tc_string"]
assert meta["reject_all_tc_mobile_data"]
assert meta["accept_all_fides_string"]
assert meta["accept_all_fides_mobile_data"]
assert meta["reject_all_fides_string"]
assert meta["reject_all_fides_mobile_data"]

@pytest.mark.usefixtures(
"privacy_experience_france_overlay",
Expand Down
30 changes: 15 additions & 15 deletions tests/ops/api/v1/endpoints/test_privacy_preference_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_verify_then_set_privacy_preferences(
)
assert response.status_code == 200
assert len(response.json()["preferences"]) == 1
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

response_json = response.json()["preferences"][0]
created_privacy_preference_history_id = response_json[
Expand Down Expand Up @@ -294,7 +294,7 @@ def test_verify_then_set_privacy_preferences_but_no_privacy_request_created(
)
assert response.status_code == 200
assert len(response.json()["preferences"]) == 1
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

response_json = response.json()["preferences"][0]
created_privacy_preference_history_id = response_json[
Expand Down Expand Up @@ -367,7 +367,7 @@ def test_set_privacy_preferences_privacy_center_fides_user_device_id_only(
)
assert response.status_code == 200
assert len(response.json()["preferences"]) == 1
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

response_json = response.json()["preferences"][0]
created_privacy_preference_history_id = response_json[
Expand Down Expand Up @@ -659,7 +659,7 @@ def test_set_privacy_preferences(

assert response.status_code == 200
assert len(response.json()["preferences"]) == 2
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

response_json = response.json()["preferences"]

Expand Down Expand Up @@ -781,7 +781,7 @@ def test_set_privacy_preferences_tcf(
)

assert response.status_code == 200
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None
assert len(response.json()["preferences"]) == 0
assert len(response.json()["feature_preferences"]) == 1

Expand Down Expand Up @@ -994,7 +994,7 @@ def test_verify_then_set_privacy_preferences_with_additional_fides_user_device_i
)
assert response.status_code == 200
assert len(response.json()["preferences"]) == 1
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

response_json = response.json()["preferences"][0]
created_privacy_preference_history_id = response_json[
Expand Down Expand Up @@ -1439,7 +1439,7 @@ def test_save_privacy_preferences_with_respect_to_fides_user_device_id(
url, json=request_body, headers={"Origin": "http://localhost:8080"}
)
assert response.status_code == 200
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None
response_json = response.json()["preferences"][0]
assert response_json["preference"] == "opt_out"
assert (
Expand Down Expand Up @@ -1713,7 +1713,7 @@ def test_save_tcf_privacy_preferences(
assert len(response.json()["special_feature_preferences"]) == 1
assert len(response.json()["system_consent_preferences"]) == 0
assert len(response.json()["system_legitimate_interests_preferences"]) == 1
assert response.json()["tc_mobile_data"] is None
assert response.json()["fides_mobile_data"] is None

purpose_response = response.json()["purpose_consent_preferences"][0]
assert purpose_response["preference"] == "opt_out"
Expand Down Expand Up @@ -2509,7 +2509,7 @@ def test_save_privacy_preferences_tc_string_section_overlaps_request_body_sectio
"browser_identity": {
"fides_user_device_id": fides_user_device_id,
},
"tc_string": tc_string,
"fides_string": tc_string,
"purpose_consent_preferences": [{"id": 1, "preference": "opt_out"}],
}
response = api_client.patch(
Expand All @@ -2518,7 +2518,7 @@ def test_save_privacy_preferences_tc_string_section_overlaps_request_body_sectio
assert response.status_code == 422
assert (
response.json()["detail"][0]["msg"]
== "Cannot supply value for 'purpose_consent_preferences' and 'tc_string' simultaneously when saving privacy preferences."
== "Cannot supply value for 'purpose_consent_preferences' and 'fides_string' simultaneously when saving privacy preferences."
)

def test_save_privacy_preferences_bad_tc_string(self, api_client, url):
Expand All @@ -2529,7 +2529,7 @@ def test_save_privacy_preferences_bad_tc_string(self, api_client, url):
"browser_identity": {
"fides_user_device_id": fides_user_device_id,
},
"tc_string": tc_string,
"fides_string": tc_string,
}
response = api_client.patch(
url, json=minimal_request_body, headers={"Origin": "http://localhost:8080"}
Expand All @@ -2548,7 +2548,7 @@ def test_save_privacy_preferences_with_tc_string_when_datamap_empty(
"browser_identity": {
"fides_user_device_id": fides_user_device_id,
},
"tc_string": tc_string,
"fides_string": tc_string,
}
response = api_client.patch(
url, json=minimal_request_body, headers={"Origin": "http://localhost:8080"}
Expand All @@ -2567,7 +2567,7 @@ def test_save_privacy_preferences_when_tcf_disabled(self, api_client, url):
"browser_identity": {
"fides_user_device_id": fides_user_device_id,
},
"tc_string": tc_string,
"fides_string": tc_string,
}
response = api_client.patch(
url, json=minimal_request_body, headers={"Origin": "http://localhost:8080"}
Expand All @@ -2589,7 +2589,7 @@ def test_save_privacy_preferences_with_tc_string(self, api_client, url, db):
"browser_identity": {
"fides_user_device_id": fides_user_device_id,
},
"tc_string": tc_string,
"fides_string": tc_string,
}
response = api_client.patch(
url, json=minimal_request_body, headers={"Origin": "http://localhost:8080"}
Expand Down Expand Up @@ -2648,7 +2648,7 @@ def test_save_privacy_preferences_with_tc_string(self, api_client, url, db):
is None
)

mobile_data = response.json()["tc_mobile_data"]
mobile_data = response.json()["fides_mobile_data"]
assert mobile_data == {
"IABTCF_CmpSdkID": 12,
"IABTCF_CmpSdkVersion": 1,
Expand Down

0 comments on commit e84dfa6

Please sign in to comment.