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: adding proxy test cases for salesforce oauth #3170

Merged
merged 14 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { testScenariosForV1API } from './oauth';

export const data = [...testScenariosForV1API];
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { ProxyMetdata } from '../../../../../src/types';
import { ProxyV1TestData } from '../../../testTypes';
import { generateProxyV1Payload } from '../../../testUtils';

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

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

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

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

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

export const reqMetadataArrayWithSecret = [proxyMetdataWithSecret];

export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'salesforce_v1_scenario_8',
shrouti1507 marked this conversation as resolved.
Show resolved Hide resolved
name: 'salesforce_oauth',
description: '[Proxy v1 API] :: Test with expired access token scenario',
utsabc marked this conversation as resolved.
Show resolved Hide resolved
successCriteria:
'Should return 5XX with error category REFRESH_TOKEN and 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_oauth.com/services/data/v50.0/sobjects/Lead/20',
},
reqMetadataArrayWithSecret,
),
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
status: 500,
authErrorCategory: 'REFRESH_TOKEN',
message:
'Salesforce Request Failed - due to "INVALID_SESSION_ID", (Retryable) during Salesforce Response Handling',
response: [
{
error:
'[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]',
metadata: proxyMetdataWithSecret,
statusCode: 500,
},
],
statTags: statTags.retryable,
},
},
},
},
},
];
32 changes: 32 additions & 0 deletions test/integrations/destinations/salesforce_oauth/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const headerWithWrongAccessToken = {
Authorization: 'Bearer expiredAccessToken',
'Content-Type': 'application/json',
};

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

const businessMockData = [
{
description: 'Mock response from destination depicting an expired access token',
httpReq: {
method: 'post',
url: 'https://rudderstack.my.salesforce_oauth.com/services/data/v50.0/sobjects/Lead/20',
headers: headerWithWrongAccessToken,
data: dataValue,
params: { destination: 'salesforce_oauth' },
},
httpRes: {
data: [{ message: 'Session expired or invalid', errorCode: 'INVALID_SESSION_ID' }],
status: 401,
},
},
];

export const networkCallsData = [...businessMockData];
Loading