diff --git a/src/v0/destinations/pardot/networkHandler.js b/src/v0/destinations/pardot/networkHandler.js index edf713ce97..a6c3cbc8fe 100644 --- a/src/v0/destinations/pardot/networkHandler.js +++ b/src/v0/destinations/pardot/networkHandler.js @@ -46,6 +46,20 @@ const getStatus = (code) => { const pardotRespHandler = (destResponse, stageMsg) => { const { status, response } = destResponse; const respAttributes = response['@attributes']; + + // to handle errors like service unavilable, wrong url, no response + if (!respAttributes) { + throw new NetworkError( + `${JSON.stringify(response)} ${stageMsg}`, + status, + { + [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(status), + }, + response, + getAuthErrCategory(status), + ); + } + const { stat, err_code: errorCode } = respAttributes; if (isHttpStatusSuccess(status) && stat !== 'fail') { diff --git a/test/integrations/destinations/pardot/dataDelivery/business.ts b/test/integrations/destinations/pardot/dataDelivery/business.ts index 5e5602ea51..7a77deda9c 100644 --- a/test/integrations/destinations/pardot/dataDelivery/business.ts +++ b/test/integrations/destinations/pardot/dataDelivery/business.ts @@ -1,49 +1,329 @@ import { ProxyV1TestData } from '../../../testTypes'; -import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; +import { + generateMetadata, + generateProxyV0Payload, + generateProxyV1Payload, +} from '../../../testUtils'; +import { commonRequestParameters, retryStatTags } from './constant'; -const commonHeaders = { - Authorization: 'Bearer myToken', - 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', - 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', - 'User-Agent': 'RudderLabs', -}; - -const commonRequestParameters = { - headers: commonHeaders, - FORM: { - first_name: 'Roger12', - last_name: 'Federer12', - website: 'https://rudderstack.com', - score: 14, - campaign_id: 42213, +export const businessV0TestScenarios = [ + { + id: 'pardot_v0_bussiness_scenario_1', + name: 'pardot', + description: '[Proxy v0 API] :: pardot email upsert', + successCriteria: 'Proper response from destination is received', + scenario: 'Oauth', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: generateProxyV0Payload({ + ...commonRequestParameters, + endpoint: + 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/Roger_12@waltair.io', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 201, + message: 'Request Processed Successfully', + destinationResponse: { + response: { + '@attributes': { stat: 'ok', version: 1 }, + prospect: { + id: 123435, + campaign_id: 42213, + salutation: null, + first_name: 'Roger_12', + last_name: 'Federer_12', + email: 'Roger_12@waltair.io', + password: null, + company: null, + website: 'https://rudderstack.com', + job_title: null, + department: null, + country: 'AU', + address_one: null, + address_two: null, + city: null, + state: null, + territory: null, + zip: null, + phone: null, + fax: null, + source: null, + annual_revenue: null, + employees: null, + industry: null, + years_in_business: null, + comments: null, + notes: null, + score: 14, + grade: null, + last_activity_at: null, + recent_interaction: 'Never active.', + crm_lead_fid: null, + crm_contact_fid: null, + crm_owner_fid: '00G2v000004WYXaEAO', + crm_account_fid: null, + salesforce_fid: null, + crm_last_sync: null, + crm_url: null, + is_do_not_email: null, + is_do_not_call: null, + opted_out: null, + is_reviewed: 1, + is_starred: null, + created_at: '2022-01-21 18:21:46', + updated_at: '2022-01-21 18:48:41', + campaign: { id: 42113, name: 'Test', crm_fid: '7012y000000MNOCLL4' }, + assigned_to: { + user: { + id: 38443703, + email: 'test_rudderstack@testcompany.com', + first_name: 'Rudderstack', + last_name: 'User', + job_title: null, + role: 'Administrator', + account: 489853, + created_at: '2021-02-26 06:25:17', + updated_at: '2021-02-26 06:25:17', + }, + }, + Are_you_shipping_large_fragile_or_bulky_items: false, + Calendly: false, + Country_Code: 'AU', + Currency: 'AUD', + Inventory_or_Warehouse_Management_System: false, + Lead_Status: 'New', + Marketing_Stage: 'SAL', + Record_Type_ID: 'TestCompany Lead', + profile: { + id: 304, + name: 'Default', + profile_criteria: [ + { id: 1500, name: 'Shipping Volume', matches: 'Unknown' }, + { id: 1502, name: 'Industry', matches: 'Unknown' }, + { id: 1506, name: 'Job Title', matches: 'Unknown' }, + { id: 1508, name: 'Department', matches: 'Unknown' }, + ], + }, + visitors: null, + visitor_activities: null, + lists: null, + }, + }, + status: 201, + }, + }, + }, + }, + }, }, -}; + { + id: 'pardot_v0_bussiness_scenario_2', + name: 'pardot', + description: '[Proxy v0 API] :: pardot fid type upsert', + successCriteria: 'Proper response from destination is received', + scenario: 'Oauth', + feature: 'dataDelivery', + module: 'destination', + version: 'v0', + input: { + request: { + body: generateProxyV0Payload({ + ...commonRequestParameters, + endpoint: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/fid/00Q6r000002LKhTPVR', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 200, + message: 'Request Processed Successfully', + destinationResponse: { + response: { + '@attributes': { + stat: 'ok', + version: 1, + }, + prospect: { + id: 123435, + campaign_id: 42213, + salutation: null, + first_name: 'Roger_12', + last_name: 'Federer_12', + email: 'Roger_12@federer.io', + password: null, + company: null, + website: 'https://rudderstack.com', + job_title: null, + department: null, + country: 'AU', + address_one: null, + address_two: null, + city: null, + state: null, + territory: null, + zip: null, + phone: null, + fax: null, + source: null, + annual_revenue: null, + employees: null, + industry: null, + years_in_business: null, + comments: null, + notes: null, + score: 14, + grade: null, + last_activity_at: null, + recent_interaction: 'Never active.', + crm_lead_fid: '00Q6r000002LKhTPVR', + crm_contact_fid: null, + crm_owner_fid: '00G2v000004WYXaEAO', + crm_account_fid: null, + salesforce_fid: '00Q6r000002LKhTPVR', + crm_last_sync: '2022-01-21 18:47:37', + crm_url: 'https://testcompany.my.salesforce.com/00Q6r000002LKhTPVR', + is_do_not_email: null, + is_do_not_call: null, + opted_out: null, + is_reviewed: 1, + is_starred: null, + created_at: '2022-01-21 18:21:46', + updated_at: '2022-01-21 18:48:41', + campaign: { + id: 42113, + name: 'Test', + crm_fid: '7012y000000MNOCLL4', + }, + assigned_to: { + user: { + id: 38443703, + email: 'test_rudderstack@testcompany.com', + first_name: 'Rudderstack', + last_name: 'User', + job_title: null, + role: 'Administrator', + account: 489853, + created_at: '2021-02-26 06:25:17', + updated_at: '2021-02-26 06:25:17', + }, + }, + Are_you_shipping_large_fragile_or_bulky_items: false, + Calendly: false, + Country_Code: 'AU', + Currency: 'AUD', + Inventory_or_Warehouse_Management_System: false, + Lead_Status: 'New', + Marketing_Stage: 'SAL', + Record_Type_ID: 'TestCompany Lead', + profile: { + id: 304, + name: 'Default', + profile_criteria: [ + { + id: 1500, + name: 'Shipping Volume', + matches: 'Unknown', + }, + { + id: 1502, + name: 'Industry', + matches: 'Unknown', + }, + { + id: 1506, + name: 'Job Title', + matches: 'Unknown', + }, + { + id: 1508, + name: 'Department', + matches: 'Unknown', + }, + ], + }, + visitors: null, + visitor_activities: null, + lists: null, + }, + }, + status: 200, + }, + }, + }, + }, + }, + }, +]; -export const businessV1TestScenarios = [ +export const businessV1TestScenarios: ProxyV1TestData[] = [ { id: 'pardot_v1_bussiness_scenario_1', name: 'pardot', - description: '[Proxy v1 API] :: pardot oauth', + description: '[Proxy v1 API] :: pardot email type upsert', successCriteria: 'Proper response from destination is received', - scenario: 'Oauth', + scenario: 'business', feature: 'dataDelivery', module: 'destination', version: 'v1', input: { request: { - body: { + body: generateProxyV1Payload({ + ...commonRequestParameters, endpoint: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/Roger_12@waltair.io', - data: 'first_name=Roger12&last_name=Federer12&website=https%3A%2F%2Frud', - params: { destination: 'pardot' }, - headers: { - Authorization: 'Bearer myToken', - 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', - 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', - 'User-Agent': 'RudderLabs', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + status: 201, + message: 'Request Processed Successfully', + response: [ + { + statusCode: 201, + metadata: generateMetadata(1), + error: + '{"@attributes":{"stat":"ok","version":1},"prospect":{"id":123435,"campaign_id":42213,"salutation":null,"first_name":"Roger_12","last_name":"Federer_12","email":"Roger_12@waltair.io","password":null,"company":null,"website":"https://rudderstack.com","job_title":null,"department":null,"country":"AU","address_one":null,"address_two":null,"city":null,"state":null,"territory":null,"zip":null,"phone":null,"fax":null,"source":null,"annual_revenue":null,"employees":null,"industry":null,"years_in_business":null,"comments":null,"notes":null,"score":14,"grade":null,"last_activity_at":null,"recent_interaction":"Never active.","crm_lead_fid":null,"crm_contact_fid":null,"crm_owner_fid":"00G2v000004WYXaEAO","crm_account_fid":null,"salesforce_fid":null,"crm_last_sync":null,"crm_url":null,"is_do_not_email":null,"is_do_not_call":null,"opted_out":null,"is_reviewed":1,"is_starred":null,"created_at":"2022-01-21 18:21:46","updated_at":"2022-01-21 18:48:41","campaign":{"id":42113,"name":"Test","crm_fid":"7012y000000MNOCLL4"},"assigned_to":{"user":{"id":38443703,"email":"test_rudderstack@testcompany.com","first_name":"Rudderstack","last_name":"User","job_title":null,"role":"Administrator","account":489853,"created_at":"2021-02-26 06:25:17","updated_at":"2021-02-26 06:25:17"}},"Are_you_shipping_large_fragile_or_bulky_items":false,"Calendly":false,"Country_Code":"AU","Currency":"AUD","Inventory_or_Warehouse_Management_System":false,"Lead_Status":"New","Marketing_Stage":"SAL","Record_Type_ID":"TestCompany Lead","profile":{"id":304,"name":"Default","profile_criteria":[{"id":1500,"name":"Shipping Volume","matches":"Unknown"},{"id":1502,"name":"Industry","matches":"Unknown"},{"id":1506,"name":"Job Title","matches":"Unknown"},{"id":1508,"name":"Department","matches":"Unknown"}]},"visitors":null,"visitor_activities":null,"lists":null}}', + }, + ], }, - method: 'POST', }, + }, + }, + }, + { + id: 'pardot_v1_bussiness_scenario_2', + name: 'pardot', + description: '[Proxy v1 API] :: pardot fid type upsert', + successCriteria: 'Proper response from destination is received', + scenario: 'business', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + ...commonRequestParameters, + endpoint: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/fid/00Q6r000002LKhTPVR', + }), method: 'POST', }, }, @@ -56,118 +336,55 @@ export const businessV1TestScenarios = [ message: 'Request Processed Successfully', response: [ { - error: `{ - '@attributes': { - stat: 'ok', - version: 1, - }, - prospect: { - id: 123435, - campaign_id: 42213, - salutation: null, - first_name: 'Roger_12', - last_name: 'Federer_12', - email: 'Roger_12@waltair.io', - password: null, - company: null, - website: 'https://rudderstack.com', - job_title: null, - department: null, - country: 'AU', - address_one: null, - address_two: null, - city: null, - state: null, - territory: null, - zip: null, - phone: null, - fax: null, - source: null, - annual_revenue: null, - employees: null, - industry: null, - years_in_business: null, - comments: null, - notes: null, - score: 14, - grade: null, - last_activity_at: null, - recent_interaction: 'Never active.', - crm_lead_fid: null, - crm_contact_fid: null, - crm_owner_fid: '00G2v000004WYXaEAO', - crm_account_fid: null, - salesforce_fid: null, - crm_last_sync: null, - crm_url: null, - is_do_not_email: null, - is_do_not_call: null, - opted_out: null, - is_reviewed: 1, - is_starred: null, - created_at: '2022-01-21 18:21:46', - updated_at: '2022-01-21 18:48:41', - campaign: { - id: 42113, - name: 'Test', - crm_fid: '7012y000000MNOCLL4', - }, - assigned_to: { - user: { - id: 38443703, - email: 'test_rudderstack@testcompany.com', - first_name: 'Rudderstack', - last_name: 'User', - job_title: null, - role: 'Administrator', - account: 489853, - created_at: '2021-02-26 06:25:17', - updated_at: '2021-02-26 06:25:17', - }, - }, - Are_you_shipping_large_fragile_or_bulky_items: false, - Calendly: false, - Country_Code: 'AU', - Currency: 'AUD', - Inventory_or_Warehouse_Management_System: false, - Lead_Status: 'New', - Marketing_Stage: 'SAL', - Record_Type_ID: 'TestCompany Lead', - profile: { - id: 304, - name: 'Default', - profile_criteria: [ - { - id: 1500, - name: 'Shipping Volume', - matches: 'Unknown', - }, - { - id: 1502, - name: 'Industry', - matches: 'Unknown', - }, - { - id: 1506, - name: 'Job Title', - matches: 'Unknown', - }, - { - id: 1508, - name: 'Department', - matches: 'Unknown', - }, - ], - }, - visitors: null, - visitor_activities: null, - lists: null, - }, - }`, statusCode: 200, metadata: generateMetadata(1), + error: + '{"@attributes":{"stat":"ok","version":1},"prospect":{"id":123435,"campaign_id":42213,"salutation":null,"first_name":"Roger_12","last_name":"Federer_12","email":"Roger_12@federer.io","password":null,"company":null,"website":"https://rudderstack.com","job_title":null,"department":null,"country":"AU","address_one":null,"address_two":null,"city":null,"state":null,"territory":null,"zip":null,"phone":null,"fax":null,"source":null,"annual_revenue":null,"employees":null,"industry":null,"years_in_business":null,"comments":null,"notes":null,"score":14,"grade":null,"last_activity_at":null,"recent_interaction":"Never active.","crm_lead_fid":"00Q6r000002LKhTPVR","crm_contact_fid":null,"crm_owner_fid":"00G2v000004WYXaEAO","crm_account_fid":null,"salesforce_fid":"00Q6r000002LKhTPVR","crm_last_sync":"2022-01-21 18:47:37","crm_url":"https://testcompany.my.salesforce.com/00Q6r000002LKhTPVR","is_do_not_email":null,"is_do_not_call":null,"opted_out":null,"is_reviewed":1,"is_starred":null,"created_at":"2022-01-21 18:21:46","updated_at":"2022-01-21 18:48:41","campaign":{"id":42113,"name":"Test","crm_fid":"7012y000000MNOCLL4"},"assigned_to":{"user":{"id":38443703,"email":"test_rudderstack@testcompany.com","first_name":"Rudderstack","last_name":"User","job_title":null,"role":"Administrator","account":489853,"created_at":"2021-02-26 06:25:17","updated_at":"2021-02-26 06:25:17"}},"Are_you_shipping_large_fragile_or_bulky_items":false,"Calendly":false,"Country_Code":"AU","Currency":"AUD","Inventory_or_Warehouse_Management_System":false,"Lead_Status":"New","Marketing_Stage":"SAL","Record_Type_ID":"TestCompany Lead","profile":{"id":304,"name":"Default","profile_criteria":[{"id":1500,"name":"Shipping Volume","matches":"Unknown"},{"id":1502,"name":"Industry","matches":"Unknown"},{"id":1506,"name":"Job Title","matches":"Unknown"},{"id":1508,"name":"Department","matches":"Unknown"}]},"visitors":null,"visitor_activities":null,"lists":null}}', + }, + ], + }, + }, + }, + }, + }, + { + id: 'pardot_v1_oauth_scenario_2', + name: 'pardot', + description: '[Proxy v1 API] :: Response with other retryable codes', + successCriteria: 'the proxy should return 500 with retryable tag', + scenario: 'Oauth', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + ...commonRequestParameters, + endpoint: + 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/rolex_waltair@test.com', + params: { + destination: 'pardot', + }, + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: + 'Unable to verify Salesforce connector during Pardot response transformation', + statusCode: 500, + metadata: generateMetadata(1), }, ], + statTags: retryStatTags, + message: 'Unable to verify Salesforce connector during Pardot response transformation', + status: 500, }, }, }, diff --git a/test/integrations/destinations/pardot/dataDelivery/constant.ts b/test/integrations/destinations/pardot/dataDelivery/constant.ts new file mode 100644 index 0000000000..97e456998e --- /dev/null +++ b/test/integrations/destinations/pardot/dataDelivery/constant.ts @@ -0,0 +1,27 @@ +export const retryStatTags = { + destType: 'PARDOT', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'retryable', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; +const commonHeaders = { + Authorization: 'Bearer myToken', + 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', + 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', + 'User-Agent': 'RudderLabs', +}; + +export const commonRequestParameters = { + headers: commonHeaders, + FORM: { + first_name: 'Roger12', + last_name: 'Federer12', + website: 'https://rudderstack.com', + score: 14, + campaign_id: 42213, + }, +}; diff --git a/test/integrations/destinations/pardot/dataDelivery/data.ts b/test/integrations/destinations/pardot/dataDelivery/data.ts index 9529b98e03..752ef22cb1 100644 --- a/test/integrations/destinations/pardot/dataDelivery/data.ts +++ b/test/integrations/destinations/pardot/dataDelivery/data.ts @@ -1,5 +1,10 @@ -import { businessV1TestScenarios } from './business'; +import { businessV0TestScenarios, businessV1TestScenarios } from './business'; import { v1OauthScenarios } from './oauth'; import { otherScenariosV1 } from './other'; -export const data = [...v1OauthScenarios, ...businessV1TestScenarios, ...otherScenariosV1]; +export const data = [ + ...v1OauthScenarios, + ...businessV1TestScenarios, + ...businessV0TestScenarios, + ...otherScenariosV1, +]; diff --git a/test/integrations/destinations/pardot/dataDelivery/oauth.ts b/test/integrations/destinations/pardot/dataDelivery/oauth.ts index e4bf5d4588..4a0116a951 100644 --- a/test/integrations/destinations/pardot/dataDelivery/oauth.ts +++ b/test/integrations/destinations/pardot/dataDelivery/oauth.ts @@ -1,160 +1,11 @@ import { ProxyV1TestData } from '../../../testTypes'; -import { - generateMetadata, - generateProxyV0Payload, - generateProxyV1Payload, -} from '../../../testUtils'; - -const commonHeaders = { - Authorization: 'Bearer abcd123', - 'Content-Type': 'application/json', - 'User-Agent': 'RudderLabs', -}; - -const commonRequestParameters = { - headers: commonHeaders, - JSON: { - users: [ - { - schema: ['EMAIL_SHA256'], - data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']], - }, - ], - }, -}; - -const commonDeleteRequestParameters = { - headers: commonHeaders, - JSON: { - users: [ - { - id: '123456', - schema: ['EMAIL_SHA256'], - data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']], - }, - ], - }, -}; - -const retryStatTags = { - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'retryable', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', -}; - -const abortStatTags = { - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', -}; - -export const v0OauthScenarios = [ - { - id: 'snapchat_custom_audience_v0_oauth_scenario_2', - name: 'snapchat_custom_audience', - description: - '[Proxy v0 API] :: Oauth where valid credentials are missing as mock response from destination', - successCriteria: - 'Since the error from the destination is 401 - the proxy should return 500 with authErrorCategory as REFRESH_TOKEN', - scenario: 'Oauth', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: generateProxyV0Payload({ - ...commonRequestParameters, - endpoint: 'https://adsapi.snapchat.com/v1/segments/456/users', - params: { - destination: 'snapchat_custom_audience', - }, - }), - method: 'POST', - }, - }, - output: { - response: { - status: 500, - body: { - output: { - status: 500, - destinationResponse: { - response: 'unauthorized', - status: 401, - }, - message: - 'Failed with unauthorized during snapchat_custom_audience response transformation', - statTags: retryStatTags, - authErrorCategory: 'REFRESH_TOKEN', - }, - }, - }, - }, - }, - { - id: 'snapchat_custom_audience_v0_oauth_scenario_3', - name: 'snapchat_custom_audience', - description: - '[Proxy v0 API] :: Oauth where ACCESS_TOKEN_SCOPE_INSUFFICIENT error as mock response from destination', - successCriteria: - 'Since the error from the destination is 403 - the proxy should return 500 with authErrorCategory as AUTH_STATUS_INACTIVE', - scenario: 'Oauth', - feature: 'dataDelivery', - module: 'destination', - version: 'v0', - input: { - request: { - body: generateProxyV0Payload({ - ...commonRequestParameters, - endpoint: 'https://adsapi.snapchat.com/v1/segments/999/users', - params: { - destination: 'snapchat_custom_audience', - }, - }), - method: 'POST', - }, - }, - output: { - response: { - status: 400, - body: { - output: { - authErrorCategory: 'AUTH_STATUS_INACTIVE', - status: 400, - destinationResponse: { - response: { - request_status: 'ERROR', - request_id: '98e2a602-3cf4-4596-a8f9-7f034161f89a', - debug_message: 'Caller does not have permission', - display_message: - "We're sorry, but the requested resource is not available at this time", - error_code: 'E3002', - }, - status: 403, - }, - message: 'undefined during snapchat_custom_audience response transformation', - statTags: abortStatTags, - }, - }, - }, - }, - }, -]; +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; +import { commonRequestParameters, retryStatTags } from './constant'; export const v1OauthScenarios: ProxyV1TestData[] = [ { - id: 'snapchat_custom_audience_v1_oauth_scenario_1', - name: 'snapchat_custom_audience', + id: 'pardot_v1_oauth_scenario_1', + name: 'pardot', description: '[Proxy v1 API] :: Oauth where valid credentials are missing as mock response from destination', successCriteria: @@ -167,9 +18,10 @@ export const v1OauthScenarios: ProxyV1TestData[] = [ request: { body: generateProxyV1Payload({ ...commonRequestParameters, - endpoint: 'https://adsapi.snapchat.com/v1/segments/456/users', + endpoint: + 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/rolex_waltair@mywebsite.io', params: { - destination: 'snapchat_custom_audience', + destination: 'pardot', }, }), method: 'POST', @@ -182,7 +34,8 @@ export const v1OauthScenarios: ProxyV1TestData[] = [ output: { response: [ { - error: '"unauthorized"', + error: + 'access_token is invalid, unknown, or malformed: Inactive token during Pardot response transformation', statusCode: 500, metadata: generateMetadata(1), }, @@ -190,55 +43,11 @@ export const v1OauthScenarios: ProxyV1TestData[] = [ statTags: retryStatTags, authErrorCategory: 'REFRESH_TOKEN', message: - 'Failed with unauthorized during snapchat_custom_audience response transformation', + 'access_token is invalid, unknown, or malformed: Inactive token during Pardot response transformation', status: 500, }, }, }, }, }, - { - id: 'snapchat_custom_audience_v1_oauth_scenario_2', - name: 'snapchat_custom_audience', - description: - '[Proxy v1 API] :: Oauth where ACCESS_TOKEN_SCOPE_INSUFFICIENT error as mock response from destination', - successCriteria: - 'Since the error from the destination is 403 - the proxy should return 500 with authErrorCategory as AUTH_STATUS_INACTIVE', - scenario: 'Oauth', - feature: 'dataDelivery', - module: 'destination', - version: 'v1', - input: { - request: { - body: generateProxyV1Payload({ - ...commonRequestParameters, - endpoint: 'https://adsapi.snapchat.com/v1/segments/999/users', - params: { - destination: 'snapchat_custom_audience', - }, - }), - method: 'POST', - }, - }, - output: { - response: { - status: 400, - body: { - output: { - response: [ - { - error: `{"request_status":"ERROR","request_id":"98e2a602-3cf4-4596-a8f9-7f034161f89a","debug_message":"Caller does not have permission","display_message":"We're sorry, but the requested resource is not available at this time","error_code":"E3002"}`, - statusCode: 400, - metadata: generateMetadata(1), - }, - ], - statTags: abortStatTags, - message: 'undefined during snapchat_custom_audience response transformation', - status: 400, - authErrorCategory: 'AUTH_STATUS_INACTIVE', - }, - }, - }, - }, - }, ]; diff --git a/test/integrations/destinations/pardot/dataDelivery/other.ts b/test/integrations/destinations/pardot/dataDelivery/other.ts new file mode 100644 index 0000000000..b7454e691c --- /dev/null +++ b/test/integrations/destinations/pardot/dataDelivery/other.ts @@ -0,0 +1,205 @@ +import { ProxyV1TestData } from '../../../testTypes'; +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; + +const expectedStatTags = { + destType: 'PARDOT', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'retryable', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; + +export const otherScenariosV1: ProxyV1TestData[] = [ + { + id: 'pardot_v1_other_scenario_1', + name: 'pardot', + description: + '[Proxy v1 API] :: Scenario for testing Service Unavailable error from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_service_not_available', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: + '{"error":{"message":"Service Unavailable","description":"The server is currently unable to handle the request due to temporary overloading or maintenance of the server. Please try again later."}} during Pardot response transformation', + statusCode: 503, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 503, + message: + '{"error":{"message":"Service Unavailable","description":"The server is currently unable to handle the request due to temporary overloading or maintenance of the server. Please try again later."}} during Pardot response transformation', + }, + }, + }, + }, + }, + { + id: 'pardot_v1_other_scenario_2', + name: 'pardot', + description: '[Proxy v1 API] :: Scenario for testing Internal Server error from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_internal_server_error', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"Internal Server Error" during Pardot response transformation', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: '"Internal Server Error" during Pardot response transformation', + }, + }, + }, + }, + }, + { + id: 'pardot_v1_other_scenario_3', + name: 'pardot', + description: '[Proxy v1 API] :: Scenario for testing Gateway Time Out error from destination', + successCriteria: 'Should return 504 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_gateway_time_out', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"Gateway Timeout" during Pardot response transformation', + statusCode: 504, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 504, + message: '"Gateway Timeout" during Pardot response transformation', + }, + }, + }, + }, + }, + { + id: 'pardot_v1_other_scenario_4', + name: 'pardot', + description: '[Proxy v1 API] :: Scenario for testing null response from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_null_response', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"" during Pardot response transformation', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: '"" during Pardot response transformation', + }, + }, + }, + }, + }, + { + id: 'pardot_v1_other_scenario_5', + name: 'pardot', + description: + '[Proxy v1 API] :: Scenario for testing null and no status response from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_null_and_no_status', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"" during Pardot response transformation', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: '"" during Pardot response transformation', + }, + }, + }, + }, + }, +]; diff --git a/test/integrations/destinations/pardot/network.ts b/test/integrations/destinations/pardot/network.ts index bef172472b..9493aab01f 100644 --- a/test/integrations/destinations/pardot/network.ts +++ b/test/integrations/destinations/pardot/network.ts @@ -4,14 +4,6 @@ export const networkCallsData = [ { httpReq: { url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/Roger_12@waltair.io', - data: 'first_name=Roger12&last_name=Federer12&website=https%3A%2F%2Frud', - params: { destination: 'pardot' }, - headers: { - Authorization: 'Bearer myToken', - 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', - 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', - 'User-Agent': 'RudderLabs', - }, method: 'POST', }, httpRes: { @@ -129,55 +121,7 @@ export const networkCallsData = [ }, { httpReq: { - url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/rolex_waltair@mywebsite.io', - data: getFormData({ - first_name: 'Rolex', - last_name: 'Waltair', - website: 'https://rudderstack.com', - score: 15, - campaign_id: 42213, - format: 'json', - }).toString(), - params: { destination: 'pardot' }, - headers: { - Authorization: 'Bearer myExpiredToken', - 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', - 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', - 'User-Agent': 'RudderLabs', - }, - method: 'POST', - }, - httpRes: { - data: { - '@attributes': { - stat: 'fail', - version: 1, - err_code: 184, - }, - err: 'access_token is invalid, unknown, or malformed: Inactive token', - }, - status: 401, - statusText: 'Unauthorized', - }, - }, - { - httpReq: { - url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/id/123435', - data: getFormData({ - first_name: 'Roger12', - last_name: 'Federer12', - website: 'https://rudderstack.com', - score: 14, - campaign_id: 42213, - format: 'json', - }).toString(), - params: { destination: 'pardot' }, - headers: { - Authorization: 'Bearer myToken', - 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8', - 'Pardot-Business-Unit-Id': '0Uv2v000000k9tHCAQ', - 'User-Agent': 'RudderLabs', - }, + url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/fid/00Q6r000002LKhTPVR', method: 'POST', }, httpRes: { @@ -190,9 +134,9 @@ export const networkCallsData = [ id: 123435, campaign_id: 42213, salutation: null, - first_name: 'Roger12', - last_name: 'Federer12', - email: 'Roger12@waltair.io', + first_name: 'Roger_12', + last_name: 'Federer_12', + email: 'Roger_12@federer.io', password: null, company: null, website: 'https://rudderstack.com', @@ -218,13 +162,13 @@ export const networkCallsData = [ grade: null, last_activity_at: null, recent_interaction: 'Never active.', - crm_lead_fid: null, + crm_lead_fid: '00Q6r000002LKhTPVR', crm_contact_fid: null, crm_owner_fid: '00G2v000004WYXaEAO', crm_account_fid: null, - salesforce_fid: null, - crm_last_sync: null, - crm_url: null, + salesforce_fid: '00Q6r000002LKhTPVR', + crm_last_sync: '2022-01-21 18:47:37', + crm_url: 'https://testcompany.my.salesforce.com/00Q6r000002LKhTPVR', is_do_not_email: null, is_do_not_call: null, opted_out: null, @@ -295,12 +239,30 @@ export const networkCallsData = [ }, { httpReq: { - url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/fid/00Q6r000002LKhTPVR', + url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/rolex_waltair@mywebsite.io', + method: 'POST', + }, + httpRes: { + data: { + '@attributes': { + stat: 'fail', + version: 1, + err_code: 184, + }, + err: 'access_token is invalid, unknown, or malformed: Inactive token', + }, + status: 401, + statusText: 'Unauthorized', + }, + }, + { + httpReq: { + url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/id/123435', data: getFormData({ - first_name: 'Nick', - last_name: 'Kyrgios', + first_name: 'Roger12', + last_name: 'Federer12', website: 'https://rudderstack.com', - score: 12, + score: 14, campaign_id: 42213, format: 'json', }).toString(), @@ -323,9 +285,9 @@ export const networkCallsData = [ id: 123435, campaign_id: 42213, salutation: null, - first_name: 'Roger_12', - last_name: 'Federer_12', - email: 'Roger_12@federer.io', + first_name: 'Roger12', + last_name: 'Federer12', + email: 'Roger12@waltair.io', password: null, company: null, website: 'https://rudderstack.com', @@ -351,13 +313,13 @@ export const networkCallsData = [ grade: null, last_activity_at: null, recent_interaction: 'Never active.', - crm_lead_fid: '00Q6r000002LKhTPVR', + crm_lead_fid: null, crm_contact_fid: null, crm_owner_fid: '00G2v000004WYXaEAO', crm_account_fid: null, - salesforce_fid: '00Q6r000002LKhTPVR', - crm_last_sync: '2022-01-21 18:47:37', - crm_url: 'https://testcompany.my.salesforce.com/00Q6r000002LKhTPVR', + salesforce_fid: null, + crm_last_sync: null, + crm_url: null, is_do_not_email: null, is_do_not_call: null, opted_out: null, @@ -426,4 +388,22 @@ export const networkCallsData = [ statusText: 'OK', }, }, + { + httpReq: { + url: 'https://pi.pardot.com/api/prospect/version/4/do/upsert/email/rolex_waltair@test.com', + method: 'POST', + }, + httpRes: { + data: { + '@attributes': { + stat: 'fail', + version: 1, + err_code: 120, + }, + err: 'Unable to verify Salesforce connector', + }, + status: 500, + statusText: 'Invalid action', + }, + }, ];