From 94f11aba329ed4ab94a7b7089dcb3423d3e848ae Mon Sep 17 00:00:00 2001 From: Facundo Lopez Janza <56484504+Linker44@users.noreply.github.com> Date: Thu, 10 Oct 2024 02:06:18 -0300 Subject: [PATCH] Remove Adobe Campaign (#5364) --- CHANGELOG.md | 3 + data/saas/config/adobe_campaign_config.yml | 126 ------ data/saas/dataset/adobe_campaign_dataset.yml | 374 ------------------ data/saas/icon/adobe_campaign.svg | 4 - ..._remove_adobe_campaign_connectionconfig.py | 37 ++ .../authentication_strategy_adobe_campaign.py | 123 ------ .../fixtures/saas/adobe_campaign_fixtures.py | 145 ------- .../saas/test_adobe_campaign_task.py | 319 --------------- 8 files changed, 40 insertions(+), 1091 deletions(-) delete mode 100644 data/saas/config/adobe_campaign_config.yml delete mode 100644 data/saas/dataset/adobe_campaign_dataset.yml delete mode 100644 data/saas/icon/adobe_campaign.svg create mode 100644 src/fides/api/alembic/migrations/versions/49bdd2fff350_remove_adobe_campaign_connectionconfig.py delete mode 100644 src/fides/api/service/saas_request/override_implementations/authentication_strategy_adobe_campaign.py delete mode 100644 tests/fixtures/saas/adobe_campaign_fixtures.py delete mode 100644 tests/ops/integration_tests/saas/test_adobe_campaign_task.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d41aad35d..3046469c76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ The types of changes are: - Fix SSO Provider form saving when clicking the cancel button with a fully filled form [#5365](https://github.com/ethyca/fides/pull/5365) +### Removed +- Removing Adobe Campaign integration [#5364](https://github.com/ethyca/fides/pull/5364) + ## [2.46.2](https://github.com/ethyca/fides/compare/2.46.1...2.46.2) ### Added diff --git a/data/saas/config/adobe_campaign_config.yml b/data/saas/config/adobe_campaign_config.yml deleted file mode 100644 index c2046747c8..0000000000 --- a/data/saas/config/adobe_campaign_config.yml +++ /dev/null @@ -1,126 +0,0 @@ -saas_config: - fides_key: - name: Adobe Campaign - type: adobe_campaign - description: A schema representing the Adobe Campaign connector for Fides - user_guide: https://docs.ethyca.com/user-guides/integrations/saas-integrations/adobe-campaign - version: 0.0.4 - - connector_params: - - name: domain - default_value: mc.adobe.io - label: Domain - description: The specific URL used to access your organization's Adobe Campaign instance - - name: organization - label: Organization - description: The name of the organization used in Adobe Campaign - - name: organization_id - label: Organization ID - description: The ID of the organization used in Adobe Campaign - - name: technical_account_id - label: Technical account ID - description: The account ID that is assigned by Adobe - - name: client_id - label: Client ID - description: The Client ID used for OAuth 2.0 authentication - - name: client_secret - sensitive: True - label: Client secret - - name: private_key - label: Private key - description: The personal access key that is used to encrypt & decrypt data in transit. - sensitive: True - - name: regulation - label: Regulation - options: [GDPR, CCPA, PDPA, LGPD] - description: The regulation to apply for request processing - pick from GDPR, CCPA, PDPA, LGPD. - - name: namespace - label: Namespace - default_value: defaultNamespace1 - description: The schema or partition where the user data resides. - - client_config: - protocol: https - host: / - authentication: - strategy: adobe_campaign - configuration: - organization_id: - technical_account_id: - client_id: - client_secret: - private_key: - - test_request: - method: GET - path: /campaign/profileAndServices/profile/PKey - headers: - - name: X-Api-Key - value: - query_params: - - name: _lineCount - value: 1 - param_values: - - name: client_id - connector_param: client_id - - endpoints: - - name: profile - requests: - read: - method: GET - path: /campaign/profileAndServices/profile/byEmail - headers: - - name: X-Api-Key - value: - query_params: - - name: email - value: - param_values: - - name: client_id - connector_param: client_id - - name: email - identity: email - data_path: content - - name: marketing_history - requests: - read: - method: GET - path: /campaign/profileAndServices/history/byEmail - headers: - - name: X-Api-Key - value: - query_params: - - name: email - value: - param_values: - - name: client_id - connector_param: client_id - - name: email - identity: email - data_path: content - - data_protection_request: - method: POST - path: /campaign/privacy/privacyTool - headers: - - name: X-Api-Key - value: - param_values: - - name: client_id - connector_param: client_id - - name: regulation - connector_param: regulation - - name: namespace - connector_param: namespace - - name: reconciliation_value - identity: email - body: | - { - "name": "", - "namespaceName": "", - "reconciliationValue": "", - "regulation": "", - "label": "Erasure Request", - "type": "delete" - } diff --git a/data/saas/dataset/adobe_campaign_dataset.yml b/data/saas/dataset/adobe_campaign_dataset.yml deleted file mode 100644 index 9a7fc42b5e..0000000000 --- a/data/saas/dataset/adobe_campaign_dataset.yml +++ /dev/null @@ -1,374 +0,0 @@ -dataset: - - fides_key: - name: Adobe Campaign Dataset - description: A dataset representing the Adobe Campaign connector for Fides - collections: - - name: profile - fields: - - name: PKey - data_categories: [system.operations] - fidesops_meta: - data_type: string - primary_key: True - - name: age - data_categories: [user.demographic.age_range] - fidesops_meta: - data_type: integer - - name: birthDate - data_categories: [user.demographic.date_of_birth] - - name: blackList - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListAllLastModified - data_categories: [system.operations] - - name: blackListEmail - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListEmailLastModified - data_categories: [system.operations] - - name: blackListFax - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListFaxLastModified - data_categories: [system.operations] - - name: blackListLastModified - data_categories: [system.operations] - - name: blackListMobile - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListMobileLastModified - data_categories: [system.operations] - - name: blackListPhone - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListPhoneLastModified - data_categories: [system.operations] - - name: blackListPostalMail - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListPostalMailLastModified - data_categories: [system.operations] - - name: blackListPushnotification - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: ccpaOptOut - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: ccpaOptOutLastModified - data_categories: [system.operations] - - name: created - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: cryptedId - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: domain - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: email - data_categories: [user.contact.email] - fidesops_meta: - data_type: string - - name: emailFormat - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: externalId - data_categories: [system.operations] - - name: fax - data_categories: [user.contact] - - name: firstName - data_categories: [user.name] - fidesops_meta: - data_type: string - - name: gender - data_categories: [user.demographic.gender] - fidesops_meta: - data_type: string - - name: href - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: isExternal - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: lastModified - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: lastName - data_categories: [user.name] - fidesops_meta: - data_type: string - - name: location - fidesops_meta: - data_type: object - fields: - - name: address1 - data_categories: [user.contact.address.street] - - name: address2 - data_categories: [user.contact.address.street] - - name: address3 - data_categories: [user.contact.address.street] - - name: address4 - data_categories: [user.contact.address.street] - - name: city - data_categories: [user.contact.address.city] - - name: countryCode - data_categories: [user.contact.address.country] - - name: stateCode - data_categories: [user.contact.address.state] - - name: zipCode - data_categories: [user.contact.address.postal_code] - - name: middleName - data_categories: [user.name] - - name: mobilePhone - data_categories: [user.contact.phone_number] - - name: phone - data_categories: [user.contact.phone_number] - - name: postalAddress - fidesops_meta: - data_type: object - fields: - - name: addrDefined - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: addrErrorCount - data_categories: [system.operations] - fidesops_meta: - data_type: integer - - name: addrLastCheck - data_categories: [system.operations] - - name: addrQuality - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: line1 - data_categories: [user.contact] - fidesops_meta: - data_type: string - - name: line2 - data_categories: [user.contact] - - name: line3 - data_categories: [user.contact] - - name: line4 - data_categories: [user.contact] - - name: line5 - data_categories: [user.contact] - - name: line6 - data_categories: [user.contact] - - name: serialized - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: preferredLanguage - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: salutation - data_categories: [system.operations] - - name: subscriptions - fidesops_meta: - data_type: object - fields: - - name: href - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: thumbnail - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: timeZone - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: title - data_categories: [user.job_title] - fidesops_meta: - data_type: string - - name: marketing_history - fields: - - name: PKey - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: age - data_categories: [user.demographic.age_range] - fidesops_meta: - data_type: integer - - name: birthDate - data_categories: [user.demographic.date_of_birth] - - name: blackList - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListAllLastModified - data_categories: [system.operations] - - name: blackListEmail - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListEmailLastModified - data_categories: [system.operations] - - name: blackListFax - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListFaxLastModified - data_categories: [system.operations] - - name: blackListLastModified - data_categories: [system.operations] - - name: blackListMobile - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListMobileLastModified - data_categories: [system.operations] - - name: blackListPhone - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListPhoneLastModified - data_categories: [system.operations] - - name: blackListPostalMail - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: blackListPostalMailLastModified - data_categories: [system.operations] - - name: ccpaOptOut - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: ccpaOptOutLastModified - data_categories: [system.operations] - - name: countBroadLogEvents - data_categories: [system.operations] - fidesops_meta: - data_type: integer - - name: countSubHistoEvents - data_categories: [system.operations] - fidesops_meta: - data_type: integer - - name: countryIsoA2 - data_categories: [system.operations] - - name: created - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: email - data_categories: [user.contact.email] - fidesops_meta: - data_type: string - - name: events - fidesops_meta: - data_type: object - fields: - - name: href - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: metadata - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: externalId - data_categories: [system.operations] - - name: fax - data_categories: [user.contact] - - name: firstName - data_categories: [user.name] - fidesops_meta: - data_type: string - - name: gender - data_categories: [user.demographic.gender] - fidesops_meta: - data_type: string - - name: href - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: isExternal - data_categories: [system.operations] - fidesops_meta: - data_type: boolean - - name: kpisAndChart - fidesops_meta: - data_type: object - fields: - - name: href - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: lastModified - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: lastName - data_categories: [user.name] - fidesops_meta: - data_type: string - - name: location - fidesops_meta: - data_type: object - fields: - - name: address1 - data_categories: [user.contact.address.street] - - name: address2 - data_categories: [user.contact.address.street] - - name: address3 - data_categories: [user.contact.address.street] - - name: address4 - data_categories: [user.contact.address.street] - - name: city - data_categories: [user.contact.address.city] - - name: countryCode - data_categories: [user.contact.address.country] - - name: stateCode - data_categories: [user.contact.address.state] - - name: zipCode - data_categories: [user.contact.address.postal_code] - - name: middleName - data_categories: [user.name] - - name: minBroadLogEvents - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: minSubHistoEvents - data_categories: [system.operations] - - name: mobilePhone - data_categories: [user.contact.phone_number] - - name: phone - data_categories: [user.contact.phone_number] - - name: preferredLanguage - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: salutation - data_categories: [system.operations] - - name: thumbnail - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: timeZone - data_categories: [system.operations] - fidesops_meta: - data_type: string - - name: title - data_categories: [user.job_title] - fidesops_meta: - data_type: string diff --git a/data/saas/icon/adobe_campaign.svg b/data/saas/icon/adobe_campaign.svg deleted file mode 100644 index 5db0c45efa..0000000000 --- a/data/saas/icon/adobe_campaign.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/fides/api/alembic/migrations/versions/49bdd2fff350_remove_adobe_campaign_connectionconfig.py b/src/fides/api/alembic/migrations/versions/49bdd2fff350_remove_adobe_campaign_connectionconfig.py new file mode 100644 index 0000000000..a953206b43 --- /dev/null +++ b/src/fides/api/alembic/migrations/versions/49bdd2fff350_remove_adobe_campaign_connectionconfig.py @@ -0,0 +1,37 @@ +"""empty message + +Revision ID: 49bdd2fff350 +Revises: c9abc9bbaa49 +Create Date: 2024-10-09 16:02:06.996661 + +""" + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "49bdd2fff350" +down_revision = "c9abc9bbaa49" +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute( + """ + WITH adobe_campaign_connections AS ( + SELECT id + FROM connectionconfig + WHERE connection_type = 'saas' + AND saas_config->>'type' = 'adobe_campaign' + ) + DELETE FROM datasetconfig + WHERE connection_config_id IN (SELECT id FROM adobe_campaign_connections); + + DELETE FROM connectionconfig WHERE connection_type = 'saas' AND saas_config->>'type' = 'adobe_campaign'; + """ + ) + + +def downgrade(): + # cannot downgrade since we can't restore a deleted connectionconfig + pass diff --git a/src/fides/api/service/saas_request/override_implementations/authentication_strategy_adobe_campaign.py b/src/fides/api/service/saas_request/override_implementations/authentication_strategy_adobe_campaign.py deleted file mode 100644 index 7909dbc278..0000000000 --- a/src/fides/api/service/saas_request/override_implementations/authentication_strategy_adobe_campaign.py +++ /dev/null @@ -1,123 +0,0 @@ -import math -import time -from datetime import datetime, timedelta -from typing import Dict, Optional, cast - -from jwt import encode -from loguru import logger -from requests import PreparedRequest, post -from sqlalchemy.orm import Session - -from fides.api.common_exceptions import FidesopsException -from fides.api.models.connectionconfig import ConnectionConfig -from fides.api.schemas.saas.strategy_configuration import StrategyConfiguration -from fides.api.service.authentication.authentication_strategy import ( - AuthenticationStrategy, -) -from fides.api.util.saas_util import assign_placeholders - - -class AdobeCampaignAuthenticationConfiguration(StrategyConfiguration): - """ - Parameters to generate an Adobe JWT token - """ - - organization_id: str - technical_account_id: str - client_id: str - private_key: str - client_secret: str - - -class AdobeAuthenticationStrategy(AuthenticationStrategy): - """ - Adds an Adobe JWT as bearer auth to the request - """ - - name = "adobe_campaign" - configuration_model = AdobeCampaignAuthenticationConfiguration - - def __init__(self, configuration: AdobeCampaignAuthenticationConfiguration): - self.organization_id = configuration.organization_id - self.technical_account_id = configuration.technical_account_id - self.client_id = configuration.client_id - self.client_secret = configuration.client_secret - self.private_key = configuration.private_key - - def add_authentication( - self, request: PreparedRequest, connection_config: ConnectionConfig - ) -> PreparedRequest: - """ - Generate an Adobe JWT and add it as bearer auth - """ - - secrets = cast(Dict, connection_config.secrets) - access_token: Optional[str] = secrets.get("access_token") - expires_at: Optional[int] = secrets.get("expires_at") - - if not access_token or self.close_to_expiration(expires_at, connection_config): - # generate a JWT token and sign it with the private key - jwt_token = encode( - { - "exp": math.floor(time.time() + 60), - "iss": f"{assign_placeholders(self.organization_id, secrets)}", - "sub": f"{assign_placeholders(self.technical_account_id, secrets)}", - "https://ims-na1.adobelogin.com/s/ent_campaign_sdk": True, - "aud": f"https://ims-na1.adobelogin.com/c/{assign_placeholders(self.client_id, secrets)}", - }, - str(assign_placeholders(self.private_key, secrets)), - algorithm="RS256", - ) - - # exchange the short-lived JWT token for longer-lived access token - response = post( - url="https://ims-na1.adobelogin.com/ims/exchange/jwt", - data={ - "client_id": assign_placeholders(self.client_id, secrets), - "client_secret": assign_placeholders(self.client_secret, secrets), - "jwt_token": jwt_token, - }, - ) - - if response.ok: - json_response = response.json() - access_token = json_response.get("access_token") - # note: `expires_in` is expressed in ms - expires_in = json_response.get("expires_in") - - # merge the new values into the existing connection_config secrets - db = Session.object_session(connection_config) - updated_secrets = { - **secrets, - **{ - "access_token": access_token, - "expires_at": ( - datetime.utcnow() + timedelta(milliseconds=expires_in) - ).timestamp(), - }, - } - connection_config.update(db, data={"secrets": updated_secrets}) - logger.info( - "Successfully updated the access token for {}", - connection_config.key, - ) - else: - raise FidesopsException(f"Unable to get access token {response.json()}") - - request.headers["Authorization"] = f"Bearer {access_token}" - return request - - @staticmethod - def close_to_expiration( - expires_at: Optional[int], connection_config: ConnectionConfig - ) -> bool: - """Check if the access_token will expire in the next 10 minutes.""" - - if expires_at is None: - logger.info( - "The expires_at value is not defined for {}, skipping token refresh", - connection_config.key, - ) - return False - - return expires_at < (datetime.utcnow() + timedelta(minutes=10)).timestamp() diff --git a/tests/fixtures/saas/adobe_campaign_fixtures.py b/tests/fixtures/saas/adobe_campaign_fixtures.py deleted file mode 100644 index 8c5a237bd4..0000000000 --- a/tests/fixtures/saas/adobe_campaign_fixtures.py +++ /dev/null @@ -1,145 +0,0 @@ -from typing import Any, Dict, Generator - -import pydash -import pytest -import requests -from sqlalchemy.orm import Session - -from fides.api.cryptography import cryptographic_util -from fides.api.models.connectionconfig import ( - AccessLevel, - ConnectionConfig, - ConnectionType, -) -from fides.api.models.datasetconfig import DatasetConfig -from fides.api.models.sql_models import Dataset as CtlDataset -from fides.api.util.saas_util import ( - load_config_with_replacement, - load_dataset_with_replacement, -) -from tests.ops.test_helpers.vault_client import get_secrets - -secrets = get_secrets("adobe_campaign") - - -@pytest.fixture(scope="function") -def adobe_campaign_secrets(saas_config): - return { - "domain": pydash.get(saas_config, "adobe_campaign.domain") or secrets["domain"], - "organization": pydash.get(saas_config, "adobe_campaign.organization") - or secrets["organization"], - "organization_id": pydash.get(saas_config, "adobe_campaign.organization_id") - or secrets["organization_id"], - "client_id": pydash.get(saas_config, "adobe_campaign.client_id") - or secrets["client_id"], - "client_secret": pydash.get(saas_config, "adobe_campaign.client_secret") - or secrets["client_secret"], - "technical_account_id": pydash.get( - saas_config, "adobe_campaign.technical_account_id" - ) - or secrets["technical_account_id"], - "private_key": pydash.get(saas_config, "adobe_campaign.private_key") - or secrets["private_key"], - "namespace": pydash.get(saas_config, "adobe_campaign.namespace") - or secrets["namespace"], - "regulation": pydash.get(saas_config, "adobe_campaign.regulation") - or secrets["regulation"], - } - - -@pytest.fixture(scope="function") -def adobe_campaign_identity_email(saas_config): - return ( - pydash.get(saas_config, "adobe_campaign.identity_email") - or secrets["identity_email"] - ) - - -@pytest.fixture(scope="function") -def adobe_campaign_erasure_identity_email() -> str: - return f"{cryptographic_util.generate_secure_random_string(13)}@email.com" - - -@pytest.fixture -def adobe_campaign_config() -> Dict[str, Any]: - return load_config_with_replacement( - "data/saas/config/adobe_campaign_config.yml", - "", - "adobe_campaign_instance", - ) - - -@pytest.fixture -def adobe_campaign_dataset() -> Dict[str, Any]: - return load_dataset_with_replacement( - "data/saas/dataset/adobe_campaign_dataset.yml" "", - "adobe_campaign_instance", - )[0] - - -@pytest.fixture(scope="function") -def adobe_campaign_connection_config( - db: Session, adobe_campaign_config, adobe_campaign_secrets -) -> Generator: - fides_key = adobe_campaign_config["fides_key"] - connection_config = ConnectionConfig.create( - db=db, - data={ - "key": fides_key, - "name": fides_key, - "connection_type": ConnectionType.saas, - "access": AccessLevel.write, - "secrets": adobe_campaign_secrets, - "saas_config": adobe_campaign_config, - }, - ) - yield connection_config - connection_config.delete(db) - - -@pytest.fixture -def adobe_campaign_dataset_config( - db: Session, - adobe_campaign_connection_config: ConnectionConfig, - adobe_campaign_dataset: Dict[str, Any], -) -> Generator: - fides_key = adobe_campaign_dataset["fides_key"] - adobe_campaign_connection_config.name = fides_key - adobe_campaign_connection_config.key = fides_key - adobe_campaign_connection_config.save(db=db) - - ctl_dataset = CtlDataset.create_from_dataset_dict(db, adobe_campaign_dataset) - - dataset = DatasetConfig.create( - db=db, - data={ - "connection_config_id": adobe_campaign_connection_config.id, - "fides_key": fides_key, - "ctl_dataset_id": ctl_dataset.id, - }, - ) - yield dataset - dataset.delete(db=db) - ctl_dataset.delete(db=db) - - -@pytest.fixture(scope="function") -def adobe_campaign_erasure_data( - adobe_campaign_connection_config: ConnectionConfig, - adobe_campaign_erasure_identity_email: str, -) -> None: - secrets = adobe_campaign_connection_config.secrets - base_url = f"https://{secrets['domain']}/{secrets['organization_id']}" - headers = { - "Authorization": f"Bearer {secrets['access_token']}", - "X-Api-Key": secrets["client_id"], - } - - # Create profile - profile_data = {"email": adobe_campaign_erasure_identity_email} - profile_response = requests.post( - url=f"{base_url}/campaign/profileAndServices/profile", - headers=headers, - json=profile_data, - ) - assert profile_response.ok diff --git a/tests/ops/integration_tests/saas/test_adobe_campaign_task.py b/tests/ops/integration_tests/saas/test_adobe_campaign_task.py deleted file mode 100644 index 36bf3b64e5..0000000000 --- a/tests/ops/integration_tests/saas/test_adobe_campaign_task.py +++ /dev/null @@ -1,319 +0,0 @@ -import pytest - -from fides.api.graph.graph import DatasetGraph -from fides.api.schemas.redis_cache import Identity -from fides.api.service.connectors import get_connector -from fides.api.task.graph_task import get_cached_data_for_erasures -from fides.config import CONFIG -from tests.conftest import access_runner_tester, erasure_runner_tester -from tests.ops.graph.graph_test_util import assert_rows_match - - -@pytest.mark.skip(reason="Only staging credentials available") -@pytest.mark.integration_saas -def test_adobe_campaign_connection_test(adobe_campaign_connection_config) -> None: - get_connector(adobe_campaign_connection_config).test_connection() - - -@pytest.mark.skip(reason="Only staging credentials available") -@pytest.mark.integration_saas -@pytest.mark.asyncio -@pytest.mark.parametrize( - "dsr_version", - ["use_dsr_3_0", "use_dsr_2_0"], -) -async def test_adobe_campaign_access_request_task( - policy, - adobe_campaign_identity_email, - adobe_campaign_connection_config, - adobe_campaign_dataset_config, - dsr_version, - request, - privacy_request, - db, -) -> None: - """Full access request based on the Adobe Campaign SaaS config""" - request.getfixturevalue(dsr_version) # REQUIRED to test both DSR 3.0 and 2.0 - - identity = Identity(**{"email": adobe_campaign_identity_email}) - privacy_request.cache_identity(identity) - - dataset_name = adobe_campaign_connection_config.get_saas_config().fides_key - merged_graph = adobe_campaign_dataset_config.get_graph() - graph = DatasetGraph(merged_graph) - - v = access_runner_tester( - privacy_request, - policy, - graph, - [adobe_campaign_connection_config], - {"email": adobe_campaign_identity_email}, - db, - ) - - assert_rows_match( - v[f"{dataset_name}:profile"], - min_size=1, - keys=[ - "PKey", - "age", - "birthDate", - "blackList", - "blackListAllLastModified", - "blackListEmail", - "blackListEmailLastModified", - "blackListFax", - "blackListFaxLastModified", - "blackListLastModified", - "blackListMobile", - "blackListMobileLastModified", - "blackListPhone", - "blackListPhoneLastModified", - "blackListPostalMail", - "blackListPostalMailLastModified", - "blackListPushnotification", - "ccpaOptOut", - "ccpaOptOutLastModified", - "created", - "cryptedId", - "domain", - "email", - "emailFormat", - "externalId", - "fax", - "firstName", - "gender", - "href", - "isExternal", - "lastModified", - "lastName", - "location", - "middleName", - "mobilePhone", - "phone", - "postalAddress", - "preferredLanguage", - "salutation", - "subscriptions", - "thumbnail", - "timeZone", - "title", - ], - ) - assert_rows_match( - v[f"{dataset_name}:marketing_history"], - min_size=1, - keys=[ - "PKey", - "age", - "birthDate", - "blackList", - "blackListAllLastModified", - "blackListEmail", - "blackListEmailLastModified", - "blackListFax", - "blackListFaxLastModified", - "blackListLastModified", - "blackListMobile", - "blackListMobileLastModified", - "blackListPhone", - "blackListPhoneLastModified", - "blackListPostalMail", - "blackListPostalMailLastModified", - "ccpaOptOut", - "ccpaOptOutLastModified", - "countBroadLogEvents", - "countSubHistoEvents", - "countryIsoA2", - "created", - "email", - "events", - "externalId", - "fax", - "firstName", - "gender", - "href", - "isExternal", - "kpisAndChart", - "lastModified", - "lastName", - "location", - "middleName", - "minBroadLogEvents", - "minSubHistoEvents", - "mobilePhone", - "phone", - "preferredLanguage", - "salutation", - "thumbnail", - "timeZone", - "title", - ], - ) - - profile = v[f"{dataset_name}:profile"][0] - assert profile["email"] == adobe_campaign_identity_email - - marketing_history = v[f"{dataset_name}:marketing_history"][0] - assert marketing_history["email"] == adobe_campaign_identity_email - - -@pytest.mark.skip(reason="Only staging credentials available") -@pytest.mark.integration_saas -@pytest.mark.asyncio -@pytest.mark.parametrize( - "dsr_version", - ["use_dsr_3_0", "use_dsr_2_0"], -) -async def test_adobe_campaign_erasure_request_task( - db, - erasure_policy, - privacy_request_with_erasure_policy, - adobe_campaign_connection_config, - adobe_campaign_dataset_config, - adobe_campaign_erasure_identity_email, - adobe_campaign_erasure_data, - dsr_version, - request, -) -> None: - """Full erasure request based on the Adobe Campaign SaaS config""" - request.getfixturevalue(dsr_version) # REQUIRED to test both DSR 3.0 and 2.0 - - masking_strict = CONFIG.execution.masking_strict - CONFIG.execution.masking_strict = False # Allow GDPR Delete - - # Create user for GDPR delete - erasure_email = adobe_campaign_erasure_identity_email - identity = Identity(**{"email": erasure_email}) - privacy_request_with_erasure_policy.cache_identity(identity) - - dataset_name = adobe_campaign_connection_config.get_saas_config().fides_key - merged_graph = adobe_campaign_dataset_config.get_graph() - graph = DatasetGraph(merged_graph) - - v = access_runner_tester( - privacy_request_with_erasure_policy, - erasure_policy, - graph, - [adobe_campaign_connection_config], - {"email": erasure_email}, - db, - ) - - assert_rows_match( - v[f"{dataset_name}:profile"], - min_size=1, - keys=[ - "PKey", - "age", - "birthDate", - "blackList", - "blackListAllLastModified", - "blackListEmail", - "blackListEmailLastModified", - "blackListFax", - "blackListFaxLastModified", - "blackListLastModified", - "blackListMobile", - "blackListMobileLastModified", - "blackListPhone", - "blackListPhoneLastModified", - "blackListPostalMail", - "blackListPostalMailLastModified", - "blackListPushnotification", - "ccpaOptOut", - "ccpaOptOutLastModified", - "created", - "cryptedId", - "domain", - "email", - "emailFormat", - "externalId", - "fax", - "firstName", - "gender", - "href", - "isExternal", - "lastModified", - "lastName", - "location", - "middleName", - "mobilePhone", - "phone", - "postalAddress", - "preferredLanguage", - "salutation", - "subscriptions", - "thumbnail", - "timeZone", - "title", - ], - ) - assert_rows_match( - v[f"{dataset_name}:marketing_history"], - min_size=1, - keys=[ - "PKey", - "age", - "birthDate", - "blackList", - "blackListAllLastModified", - "blackListEmail", - "blackListEmailLastModified", - "blackListFax", - "blackListFaxLastModified", - "blackListLastModified", - "blackListMobile", - "blackListMobileLastModified", - "blackListPhone", - "blackListPhoneLastModified", - "blackListPostalMail", - "blackListPostalMailLastModified", - "ccpaOptOut", - "ccpaOptOutLastModified", - "countBroadLogEvents", - "countSubHistoEvents", - "countryIsoA2", - "created", - "email", - "events", - "externalId", - "fax", - "firstName", - "gender", - "href", - "isExternal", - "kpisAndChart", - "lastModified", - "lastName", - "location", - "middleName", - "minBroadLogEvents", - "minSubHistoEvents", - "mobilePhone", - "phone", - "preferredLanguage", - "salutation", - "thumbnail", - "timeZone", - "title", - ], - ) - - x = erasure_runner_tester( - privacy_request_with_erasure_policy, - erasure_policy, - graph, - [adobe_campaign_connection_config], - {"email": erasure_email}, - get_cached_data_for_erasures(privacy_request_with_erasure_policy.id), - db, - ) - - # Assert erasure request made to adobe_campaign_user - assert x == { - "adobe_instance:profile": 1, - "adobe_instance:marketing_history": 0, - } - - CONFIG.execution.masking_strict = masking_strict # Reset