Ejemplo n.º 1
0
        private void TestGetUserStatus(StringBuilder logs, bool tcfEnabled)
        {
            AddLogLine(logs, "GetUserStatus processing...");

            // Tested vendor: Adssets AB
            string vendorId  = "205";
            string purposeId = "select_personalized_ads";

            Didomi didomi = Didomi.GetInstance();

            bool success = true;

            didomi.SetUserStatus(
                purposesConsentStatus: true,
                purposesLIStatus: true,
                vendorsConsentStatus: true,
                vendorsLIStatus: true
                );

            UserStatus userStatus = didomi.GetUserStatus();

            if (tcfEnabled)
            {
                success &= AssertNotEmpty(logs, userStatus.GetConsentString(), "No consent string");
            }
            success &= AssertNotEmpty(logs, userStatus.GetUserId(), "No user id");
            success &= AssertNotEmpty(logs, userStatus.GetCreated(), "No created date");
            success &= AssertNotEmpty(logs, userStatus.GetUpdated(), "No updated date");

            success &= AssertContains(logs, userStatus.GetVendors().GetGlobal().GetEnabled(), vendorId, "Vendor should be in global.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobal().GetDisabled(), vendorId, "Vendor should not be in global.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalConsent().GetEnabled(), vendorId, "Vendor should be in globalConsent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalConsent().GetDisabled(), vendorId, "Vendor should not be in globalConsent.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetEnabled(), vendorId, "Vendor should be in globalLegitimateInterest.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetDisabled(), vendorId, "Vendor should not be in globalLegitimateInterest.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetConsent().GetEnabled(), vendorId, "Vendor should be in consent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetConsent().GetDisabled(), vendorId, "Vendor should not be in consent.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetLegitimateInterest().GetEnabled(), vendorId, "Vendor should be in LegitimateInterest.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetLegitimateInterest().GetDisabled(), vendorId, "Vendor should not be in legitimateInterest.disabled");

            success &= AssertContains(logs, userStatus.GetPurposes().GetGlobal().GetEnabled(), purposeId, "Purpose should be in global.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetGlobal().GetDisabled(), purposeId, "Purpose should not be in global.disabled");

            success &= AssertContains(logs, userStatus.GetPurposes().GetConsent().GetEnabled(), purposeId, "Purpose should be in consent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetConsent().GetDisabled(), purposeId, "Purpose should not be in consent.disabled");

            success &= AssertContains(logs, userStatus.GetPurposes().GetLegitimateInterest().GetEnabled(), purposeId, "Purpose should be in legitimateInterest.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetLegitimateInterest().GetDisabled(), purposeId, "Purpose should not be in legitimateInterest.disabled");

            didomi.SetUserStatus(
                purposesConsentStatus: false,
                purposesLIStatus: false,
                vendorsConsentStatus: true,
                vendorsLIStatus: true
                );

            userStatus = didomi.GetUserStatus();

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobal().GetEnabled(), vendorId, "Vendor should not be in global.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetGlobal().GetDisabled(), vendorId, "Vendor should be in global.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalConsent().GetEnabled(), vendorId, "Vendor should not be in globalConsent.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalConsent().GetDisabled(), vendorId, "Vendor should be in globalConsent.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetEnabled(), vendorId, "Vendor should not be in globalLegitimateInterest.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetDisabled(), vendorId, "Vendor should be in globalLegitimateInterest.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetConsent().GetEnabled(), vendorId, "Vendor should be in consent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetConsent().GetDisabled(), vendorId, "Vendor should not be in consent.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetLegitimateInterest().GetEnabled(), vendorId, "Vendor should be in LegitimateInterest.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetLegitimateInterest().GetDisabled(), vendorId, "Vendor should not be in legitimateInterest.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetGlobal().GetEnabled(), purposeId, "Purpose should not be in global.enabled");
            success &= AssertContains(logs, userStatus.GetPurposes().GetGlobal().GetDisabled(), purposeId, "Purpose should be in global.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetConsent().GetEnabled(), purposeId, "Purpose should not be in consent.enabled");
            success &= AssertContains(logs, userStatus.GetPurposes().GetConsent().GetDisabled(), purposeId, "Purpose should be in consent.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetLegitimateInterest().GetEnabled(), purposeId, "Purpose should not be in legitimateInterest.enabled");
            success &= AssertContains(logs, userStatus.GetPurposes().GetLegitimateInterest().GetDisabled(), purposeId, "Purpose should be in legitimateInterest.disabled");

            didomi.SetUserStatus(
                purposesConsentStatus: true,
                purposesLIStatus: false,
                vendorsConsentStatus: true,
                vendorsLIStatus: false
                );

            userStatus = didomi.GetUserStatus();

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobal().GetEnabled(), vendorId, "Vendor should not be in global.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetGlobal().GetDisabled(), vendorId, "Vendor should be in global.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalConsent().GetEnabled(), vendorId, "Vendor should be in globalConsent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalConsent().GetDisabled(), vendorId, "Vendor should not be in globalConsent.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetEnabled(), vendorId, "Vendor should not be in globalLegitimateInterest.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetGlobalLegitimateInterest().GetDisabled(), vendorId, "Vendor should be in globalLegitimateInterest.disabled");

            success &= AssertContains(logs, userStatus.GetVendors().GetConsent().GetEnabled(), vendorId, "Vendor should not be in consent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetConsent().GetDisabled(), vendorId, "Vendor should be in consent.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetVendors().GetLegitimateInterest().GetEnabled(), vendorId, "Vendor should not be in LegitimateInterest.enabled");
            success &= AssertContains(logs, userStatus.GetVendors().GetLegitimateInterest().GetDisabled(), vendorId, "Vendor should be in legitimateInterest.disabled");

            success &= AssertContains(logs, userStatus.GetPurposes().GetGlobal().GetEnabled(), purposeId, "Purpose should be in global.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetGlobal().GetDisabled(), purposeId, "Purpose should not be in global.disabled");

            success &= AssertContains(logs, userStatus.GetPurposes().GetConsent().GetEnabled(), purposeId, "Purpose should be in consent.enabled");
            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetConsent().GetDisabled(), purposeId, "Purpose should not be in consent.disabled");

            success &= AssertDoesNotContain(logs, userStatus.GetPurposes().GetLegitimateInterest().GetEnabled(), purposeId, "Purpose should not be in legitimateInterest.enabled");
            success &= AssertContains(logs, userStatus.GetPurposes().GetLegitimateInterest().GetDisabled(), purposeId, "Purpose should be in legitimateInterest.disabled");

            if (success)
            {
                TestSucceeded(logs);
            }
        }