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

fix: update getConversionActionId function for gaoc #3594

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -16,7 +16,6 @@ const {
getFieldValueFromMessage,
isDefinedAndNotNullAndNotEmpty,
isDefinedAndNotNull,
getAuthErrCategoryFromStCode,
getAccessToken,
getIntegrationsObj,
} = require('../../util');
Expand All @@ -34,7 +33,7 @@ const {
const { processAxiosResponse } = require('../../../adapters/utils/networkUtils');
const Cache = require('../../util/cache');
const helper = require('./helper');
const { finaliseConsent } = require('../../util/googleUtils');
const { finaliseConsent, getAuthErrCategory } = require('../../util/googleUtils');

const conversionActionIdCache = new Cache(CONVERSION_ACTION_ID_CACHE_TTL);

Expand Down Expand Up @@ -86,7 +85,7 @@ const getConversionActionId = async ({ headers, params, metadata }) => {
)} during google_ads_offline_conversions response transformation`,
status,
response,
getAuthErrCategoryFromStCode(get(searchStreamResponse, 'status')),
getAuthErrCategory(searchStreamResponse),
);
}
const conversionAction = get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,76 @@ export const v1oauthScenarios = [
},
},
},
{
id: 'gaoc_v1_oauth_scenario_4',
name: 'google_adwords_offline_conversions',
description:
"[Proxy v1 API] :: Oauth when the user doesn't enabled 2 factor authentication but the google ads account has it enabled for not store sales conversion",
successCriteria: 'The proxy should return 401 with authErrorCategory as AUTH_STATUS_INACTIVE',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...{ ...commonRequestParameters, JSON: { isStoreConversion: false } },
headers: {
Authorization: 'Bearer invalidabcd1234',
'Content-Type': 'application/json',
'developer-token': 'ijkl91011',
'login-customer-id': 'logincustomerid',
},
endpoint:
'https://googleads.googleapis.com/v16/customers/customerid/offlineUserDataJobs',
},
metadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 401,
body: {
output: {
authErrorCategory: 'AUTH_STATUS_INACTIVE',
message:
'[Google Ads Offline Conversions]:: {"error":{"code":401,"details":[{"@type":"type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure","errors":[{"errorCode":{"authenticationError":"TWO_STEP_VERIFICATION_NOT_ENROLLED"},"message":"An account administrator changed this account\'s authentication settings. To access this Google Ads account, enable 2-Step Verification in your Google account at https://www.google.com/landing/2step."}],"requestId":"wy4ZYbsjWcgh6uC2Ruc_Zg"}],"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}} during google_ads_offline_conversions response transformation',
response: [
{
error:
'[Google Ads Offline Conversions]:: {"error":{"code":401,"details":[{"@type":"type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure","errors":[{"errorCode":{"authenticationError":"TWO_STEP_VERIFICATION_NOT_ENROLLED"},"message":"An account administrator changed this account\'s authentication settings. To access this Google Ads account, enable 2-Step Verification in your Google account at https://www.google.com/landing/2step."}],"requestId":"wy4ZYbsjWcgh6uC2Ruc_Zg"}],"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}} during google_ads_offline_conversions response transformation',
metadata: {
attemptNum: 1,
destinationId: 'default-destinationId',
dontBatch: false,
jobId: 1,
secret: {
accessToken: 'default-accessToken',
},
sourceId: 'default-sourceId',
userId: 'default-userId',
workspaceId: 'default-workspaceId',
},
statusCode: 401,
},
],
statTags: {
destType: 'GOOGLE_ADWORDS_OFFLINE_CONVERSIONS',
destinationId: 'default-destinationId',
errorCategory: 'network',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'default-workspaceId',
},
status: 401,
},
},
},
},
},
];
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
const commonResponse = {
status: 401,
data: {
error: {
code: 401,
details: [
{
'@type': 'type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure',
errors: [
{
errorCode: {
authenticationError: 'TWO_STEP_VERIFICATION_NOT_ENROLLED',
},
message:
"An account administrator changed this account's authentication settings. To access this Google Ads account, enable 2-Step Verification in your Google account at https://www.google.com/landing/2step.",
},
],
requestId: 'wy4ZYbsjWcgh6uC2Ruc_Zg',
},
],
message:
'Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.',
status: 'UNAUTHENTICATED',
},
},
};

export const networkCallsData = [
{
httpReq: {
Expand Down Expand Up @@ -647,7 +674,7 @@ export const networkCallsData = [
},
{
description:
'Mock response from destination depicting a request with invalid authentication credentials',
'Mock response from destination depicting a request from user who has not enabled 2 factor authentication',
httpReq: {
url: 'https://googleads.googleapis.com/v16/customers/customerid/offlineUserDataJobs:create',
data: {
Expand All @@ -669,31 +696,25 @@ export const networkCallsData = [
},
method: 'POST',
},
httpRes: {
status: 401,
httpRes: commonResponse,
},
{
description:
'Mock response from destination depicting a request from user who has not enabled 2 factor authentication',
httpReq: {
url: 'https://googleads.googleapis.com/v16/customers/1112223333/googleAds:searchStream',
data: {
error: {
code: 401,
details: [
{
'@type': 'type.googleapis.com/google.ads.googleads.v16.errors.GoogleAdsFailure',
errors: [
{
errorCode: {
authenticationError: 'TWO_STEP_VERIFICATION_NOT_ENROLLED',
},
message:
"An account administrator changed this account's authentication settings. To access this Google Ads account, enable 2-Step Verification in your Google account at https://www.google.com/landing/2step.",
},
],
requestId: 'wy4ZYbsjWcgh6uC2Ruc_Zg',
},
],
message:
'Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.',
status: 'UNAUTHENTICATED',
},
query:
"SELECT conversion_action.id FROM conversion_action WHERE conversion_action.name = 'Sign-up - click'",
},
headers: {
Authorization: 'Bearer invalidabcd1234',
'Content-Type': 'application/json',
'developer-token': 'ijkl91011',
'login-customer-id': 'logincustomerid',
},
method: 'POST',
},
httpRes: commonResponse,
},
];
Loading