Skip to content

Commit

Permalink
Add additional error handling for fides_string override options (#4325
Browse files Browse the repository at this point in the history
)
  • Loading branch information
NevilleS authored Oct 23, 2023
1 parent 38f823b commit 486d2fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
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

0 comments on commit 486d2fd

Please sign in to comment.