Skip to content

Commit

Permalink
fix: review comments address
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Mar 11, 2024
1 parent bc3a235 commit fb2bff1
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const commonHeadersForWrongToken = {
Authorization: 'Bearer expiredAccessToken',
'Content-Type': 'application/json',
};

const commonHeadersForRightToken = {
Authorization: 'Bearer correctAccessToken',
'Content-Type': 'application/json',
};
const params = { destination: 'salesforce_oauth' };

const users = [
Expand All @@ -32,13 +37,19 @@ const statTags = {
},
};

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

export const proxyMetdataWithSecret: ProxyMetdata = {
const commonRequestParametersWithRightToken = {
headers: commonHeadersForRightToken,
JSON: users[0],
params,
};

export const proxyMetdataWithSecretWithWrongAccessToken: ProxyMetdata = {
jobId: 1,
attemptNum: 1,
userId: 'dummyUserId',
Expand All @@ -53,7 +64,23 @@ export const proxyMetdataWithSecret: ProxyMetdata = {
dontBatch: false,
};

export const reqMetadataArrayWithSecret = [proxyMetdataWithSecret];
export const proxyMetdataWithSecretWithRightAccessToken: ProxyMetdata = {
jobId: 1,
attemptNum: 1,
userId: 'dummyUserId',
sourceId: 'dummySourceId',
destinationId: 'dummyDestinationId',
workspaceId: 'dummyWorkspaceId',
secret: {
access_token: 'expiredRightToken',
instanceUrl: 'https://rudderstack.my.salesforce_oauth.com',
},
destInfo: { authKey: 'dummyDestinationId' },
dontBatch: false,
};

export const reqMetadataArrayWithWrongSecret = [proxyMetdataWithSecretWithWrongAccessToken];
export const reqMetadataArray = [proxyMetdataWithSecretWithRightAccessToken];

export const testScenariosForV1API: ProxyV1TestData[] = [
{
Expand All @@ -70,11 +97,11 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
...commonRequestParametersWithWrongToken,
endpoint:
'https://rudderstack.my.salesforce_oauth.com/services/data/v50.0/sobjects/Lead/20',
},
reqMetadataArrayWithSecret,
reqMetadataArrayWithWrongSecret,
),
method: 'POST',
},
Expand All @@ -92,7 +119,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
{
error:
'[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]',
metadata: proxyMetdataWithSecret,
metadata: proxyMetdataWithSecretWithWrongAccessToken,
statusCode: 500,
},
],
Expand All @@ -102,4 +129,46 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
},
},
},
{
id: 'salesforce_v1_scenario_2',
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(
{
...commonRequestParametersWithRightToken,
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: proxyMetdataWithSecretWithRightAccessToken,
statusCode: 200,
},
],
},
},
},
},
},
];
19 changes: 19 additions & 0 deletions test/integrations/destinations/salesforce_oauth/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const headerWithWrongAccessToken = {
'Content-Type': 'application/json',
};

const headerWithRightAccessToken = {
Authorization: 'Bearer correctAccessToken',
'Content-Type': 'application/json',
};

const dataValue = {
Email: 'danis.archurav@sbermarket.ru',
Company: 'itus.ru',
Expand All @@ -27,6 +32,20 @@ const businessMockData = [
status: 401,
},
},
{
description:
'Mock response from destination depicting a valid lead request, with no changed data',
httpReq: {
method: 'post',
url: 'https://rudderstack.my.salesforce.com/services/data/v50.0/sobjects/Lead/existing_unchanged_leadId',
data: dataValue,
headers: headerWithRightAccessToken,
},
httpRes: {
data: { statusText: 'No Content' },
status: 204,
},
},
];

export const networkCallsData = [...businessMockData];

0 comments on commit fb2bff1

Please sign in to comment.