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

chore: add v1 proxy tests for salesforce #3074

Merged
merged 29 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7d6ea12
feat: update proxy data type for response handler input
utsabc Jan 25, 2024
b1327eb
feat: update proxy v1 test cases
utsabc Jan 25, 2024
30c4eca
Merge branch 'develop' into fix.network-handlers
utsabc Jan 25, 2024
9dd8625
feat: update proxy tests for cm360
utsabc Jan 29, 2024
650911e
fix: typo
utsabc Jan 29, 2024
84b6a5d
Update test/integrations/destinations/campaign_manager/dataDelivery/b…
utsabc Jan 29, 2024
686f524
Update test/integrations/destinations/campaign_manager/dataDelivery/b…
utsabc Jan 29, 2024
76e0284
fix: api contract for v1 proxy
utsabc Feb 1, 2024
93947db
fix: api contract for v1 proxy (#3049)
utsabc Feb 2, 2024
d2e65f4
chore: clean up zod type
Feb 5, 2024
7ce0a66
chore: update testutils
Feb 5, 2024
99f5cb2
chore: update V0 proxy request type and zod schema
Feb 5, 2024
0504ffa
feat: update proxy tests for cm360 (#3039)
utsabc Feb 7, 2024
bd6af6b
Merge branch 'develop' into fix.network-handlers
utsabc Feb 7, 2024
014bf5e
Merge branch 'develop' of github.com:rudderlabs/rudder-transformer in…
Feb 8, 2024
b57a926
Merge branch 'fix.network-handlers' of github.com:rudderlabs/rudder-t…
Feb 8, 2024
325433b
feat: adding zod validations (#3066)
utsabc Feb 8, 2024
689b0cd
chore: update delivery test cases for criteo audience
ItsSudip Feb 8, 2024
9e04774
Revert "chore: update delivery test cases for criteo audience"
ItsSudip Feb 8, 2024
a6f8725
chore: add initial business tests
yashasvibajpai Feb 9, 2024
7114f9b
chore: add type def for proxy v1 test
Feb 9, 2024
33d4d62
chore: fix generateMetdata func
Feb 9, 2024
d5e8b3c
chore: cleanup
yashasvibajpai Feb 9, 2024
a31bc12
chore: add other scenario test, refactor
yashasvibajpai Feb 11, 2024
14d9e4f
Merge branch 'fix.network-handlers' into chore.salesforce.update-prox…
yashasvibajpai Feb 13, 2024
d2c4f7c
chore: address commentsx1
yashasvibajpai Feb 13, 2024
a94c54d
chore: move test to other
yashasvibajpai Feb 19, 2024
2401b55
Merge branch 'develop' into chore.salesforce.update-proxy-tests.v1
yashasvibajpai Feb 23, 2024
8a3fbf4
chore: address commentsx2
yashasvibajpai Mar 1, 2024
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
380 changes: 380 additions & 0 deletions test/integrations/destinations/salesforce/dataDelivery/business.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,380 @@
import { ProxyMetdata } from '../../../../../src/types';
import { ProxyV1TestData } from '../../../testTypes';
import { generateProxyV1Payload } from '../../../testUtils';

const commonHeaders = {
Authorization: 'Bearer token',
'Content-Type': 'application/json',
};
const params = { destination: 'salesforce' };

const users = [
{
Email: '[email protected]',
Company: 'itus.ru',
LastName: 'Danis',
FirstName: 'Archurav',
LeadSource: 'App Signup',
account_type__c: 'free_trial',
},
];

const statTags = {
aborted: {
destType: 'SALESFORCE',
destinationId: 'dummyDestinationId',
errorCategory: 'network',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'dummyWorkspaceId',
},
retryable: {
destType: 'SALESFORCE',
destinationId: 'dummyDestinationId',
errorCategory: 'network',
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'dummyWorkspaceId',
},
throttled: {
destType: 'SALESFORCE',
destinationId: 'dummyDestinationId',
errorCategory: 'network',
errorType: 'throttled',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'dummyWorkspaceId',
},
};

export const proxyMetdata: ProxyMetdata = {
jobId: 1,
attemptNum: 1,
userId: 'dummyUserId',
sourceId: 'dummySourceId',
destinationId: 'dummyDestinationId',
workspaceId: 'dummyWorkspaceId',
secret: {},
dontBatch: false,
};

export const reqMetadataArray = [proxyMetdata];

const commonRequestParameters = {
headers: commonHeaders,
JSON: users[0],
params,
};

const externalIdSearchData = { Planning_Categories__c: 'pc', External_ID__c: 123 };
export const externalIDSearchedData = {
headers: commonHeaders,
JSON: externalIdSearchData,
params,
};

export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'salesforce_v1_scenario_1',
name: 'salesforce',
description:
'[Proxy v1 API] :: Test for a valid request - Lead creation with existing unchanged leadId and unchanged data',
successCriteria: 'Should return 200 with no error with destination response',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint:
'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/existing_unchanged_leadId',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: 'Request for destination: salesforce Processed Successfully',
response: [
{
error: '{"statusText":"No Content"}',
metadata: proxyMetdata,
statusCode: 200,
},
],
},
},
},
},
},
{
id: 'salesforce_v1_scenario_2',
name: 'salesforce',
description: '[Proxy v1 API] :: Test with session expired scenario',
successCriteria: 'Should return 5XX with error Session expired or invalid, INVALID_SESSION_ID',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint:
'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/invalid_session_id',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 500,
message:
'Salesforce Request Failed - due to "Session expired or invalid", (Retryable) during Salesforce Response Handling',
response: [
{
error:
'[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]',
metadata: proxyMetdata,
statusCode: 500,
},
],
statTags: statTags.retryable,
},
},
},
},
},
{
id: 'salesforce_v1_scenario_3',
name: 'salesforce',
description: '[Proxy v1 API] :: Test for Invalid Auth token passed in header',
successCriteria: 'Should return 401 INVALID_AUTH_HEADER',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/2',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message:
'Salesforce Request Failed: "401" due to "INVALID_HEADER_TYPE", (Aborted) during Salesforce Response Handling',
response: [
{
error: '[{"message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER"}]',
metadata: proxyMetdata,
statusCode: 400,
},
],
statTags: statTags.aborted,
},
},
},
},
},
{
id: 'salesforce_v1_scenario_4',
name: 'salesforce',
description: '[Proxy v1 API] :: Test for rate limit exceeded scenario',
successCriteria: 'Should return 429 with error message "Request limit exceeded"',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/4',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message:
'Salesforce Request Failed - due to "REQUEST_LIMIT_EXCEEDED", (Throttled) during Salesforce Response Handling',
response: [
{
error:
'[{"message":"Request limit exceeded","errorCode":"REQUEST_LIMIT_EXCEEDED"}]',
metadata: proxyMetdata,
statusCode: 429,
},
],
statTags: statTags.throttled,
status: 429,
},
},
},
},
},
{
id: 'salesforce_v1_scenario_5',
name: 'salesforce',
description: '[Proxy v1 API] :: Test for server unavailable scenario',
successCriteria: 'Should return 500 with error message "Server Unavailable"',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/5',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message:
'Salesforce Request Failed - due to "Server Unavailable", (Retryable) during Salesforce Response Handling',
response: [
{
error: '[{"message":"Server Unavailable","errorCode":"SERVER_UNAVAILABLE"}]',
metadata: proxyMetdata,
statusCode: 500,
},
],
statTags: statTags.retryable,
status: 500,
},
},
},
},
},
{
id: 'salesforce_v1_scenario_6',
name: 'salesforce',
description: '[Proxy v1 API] :: Test for invalid grant scenario due to authentication failure',
successCriteria:
'Should return 400 with error message "invalid_grant" due to "authentication failure"',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/6',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message:
'Salesforce Request Failed: "400" due to "{"error":"invalid_grant","error_description":"authentication failure"}", (Aborted) during Salesforce Response Handling',
response: [
{
error: '{"error":"invalid_grant","error_description":"authentication failure"}',
metadata: proxyMetdata,
statusCode: 400,
},
],
statTags: statTags.aborted,
status: 400,
},
},
},
},
},
{
id: 'salesforce_v1_scenario_7',
name: 'salesforce',
description: '[Proxy v1 API] :: Test for a valid request - External ID search',
successCriteria: 'Should return 200 with list of matching records with External ID',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...externalIDSearchedData,
endpoint:
'https://rudderstack.my.salesforce.com/services/data/v50.0/parameterizedSearch/?q=123&sobject=object_name&in=External_ID__c&object_name.fields=id,External_ID__c',
},
reqMetadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message: 'Request for destination: salesforce Processed Successfully',
response: [
{
error:
'{"searchRecords":[{"attributes":{"type":"object_name","url":"/services/data/v50.0/sobjects/object_name/a0J75100002w97gEAA"},"Id":"a0J75100002w97gEAA","External_ID__c":"external_id"},{"attributes":{"type":"object_name","url":"/services/data/v50.0/sobjects/object_name/a0J75200002w9ZsEAI"},"Id":"a0J75200002w9ZsEAI","External_ID__c":"external_id TEST"}]}',
metadata: proxyMetdata,
statusCode: 200,
},
],
status: 200,
},
},
},
},
},
];
Loading
Loading