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

Add additional error handling for fides_string override options #4325

Merged
merged 2 commits into from
Oct 23, 2023
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
3 changes: 2 additions & 1 deletion clients/fides-js/src/lib/tcf/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const transformFidesStringToCookieKeys = (
debug: boolean
): TcfCookieConsent => {
// Defer: to fully support AC string, we need to split out TC from AC string https://github.com/ethyca/fides/issues/4263
const tcModel: TCModel = TCString.decode(fidesString || "");
const tcString = (fidesString || "").split(",")[0];
const tcModel: TCModel = TCString.decode(tcString);

const cookieKeys: TcfCookieConsent = {};

Expand Down
14 changes: 7 additions & 7 deletions clients/privacy-center/cypress/e2e/consent-banner-tcf.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ describe("Fides-js TCF", () => {
it("prefers preferences from fides_string option when fides_string, experience, and cookie exist", () => {
setFidesCookie();
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
cy.fixture("consent/experience_tcf.json").then((experience) => {
stubConfig({
Expand Down Expand Up @@ -1534,7 +1534,7 @@ describe("Fides-js TCF", () => {
*/
it("prefers preferences from fides_string option when both fides_string and experience is provided and cookie does not exist", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
cy.fixture("consent/experience_tcf.json").then((experience) => {
stubConfig({
Expand Down Expand Up @@ -1625,7 +1625,7 @@ describe("Fides-js TCF", () => {
*/
it("does nothing when fides_string option when both fides_string option and cookie exist but no experience exists (neither prefetch nor API)", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
setFidesCookie();
stubConfig(
{
Expand Down Expand Up @@ -1656,7 +1656,7 @@ describe("Fides-js TCF", () => {
*/
it("prefers preferences from fides_string option when both fides_string option and cookie exist and experience is fetched from API", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
setFidesCookie();
cy.fixture("consent/experience_tcf.json").then((experience) => {
Expand Down Expand Up @@ -1749,7 +1749,7 @@ describe("Fides-js TCF", () => {
describe("fides_string override options", () => {
it("uses fides_string when set via cookie", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
cy.getCookie("fides_string").should("not.exist");
cy.setCookie("fides_string", fidesStringOverride);
Expand Down Expand Up @@ -1793,7 +1793,7 @@ describe("Fides-js TCF", () => {

it("uses fides_string when set via query param", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
cy.getCookie("fides_string").should("not.exist");
cy.fixture("consent/experience_tcf.json").then((experience) => {
Expand Down Expand Up @@ -1841,7 +1841,7 @@ describe("Fides-js TCF", () => {

it("uses fides_string when set via window obj", () => {
const fidesStringOverride =
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE";
"CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA.IABE,1~";
const expectedTCString = "CPzevcAPzevcAGXABBENATEIAAIAAAAAAAAAAAAAAAAA"; // without disclosed vendors
cy.getCookie("fides_string").should("not.exist");
cy.fixture("consent/experience_tcf.json").then((experience) => {
Expand Down
Loading