-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: custify user-regulation logic (#3076)
- Loading branch information
Showing
3 changed files
with
272 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
test/integrations/destinations/custify/deleteUsers/data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
const destType = 'custify'; | ||
const commonData = { | ||
name: destType, | ||
feature: 'userDeletion', | ||
module: 'destination', | ||
version: 'v0', | ||
}; | ||
|
||
export const data = [ | ||
{ | ||
description: 'Test 0: should fail when config is not being sent', | ||
input: { | ||
request: { | ||
body: [ | ||
{ | ||
destType: destType.toUpperCase(), | ||
userAttributes: [ | ||
{ | ||
userId: 'rudder1', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 400, | ||
body: [ | ||
{ | ||
statusCode: 400, | ||
error: 'Config for deletion not present', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
description: 'Test 1: should fail when apiKey is not present in config', | ||
input: { | ||
request: { | ||
body: [ | ||
{ | ||
destType: destType.toUpperCase(), | ||
userAttributes: [ | ||
{ | ||
userId: 'rudder2', | ||
}, | ||
], | ||
config: { | ||
apiToken: 'dummyApiKey', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 400, | ||
body: [ | ||
{ | ||
statusCode: 400, | ||
error: 'api key for deletion not present', | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
|
||
{ | ||
description: 'Test 2: should pass when one of the users is not present in destination', | ||
input: { | ||
request: { | ||
body: [ | ||
{ | ||
destType: destType.toUpperCase(), | ||
userAttributes: [ | ||
{ | ||
userId: 'rudder1', | ||
}, | ||
{ | ||
userId: 'rudder2', | ||
}, | ||
], | ||
config: { | ||
apiKey: 'dummyApiKey', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 200, | ||
body: [{ statusCode: 200, status: 'successful' }], | ||
}, | ||
}, | ||
}, | ||
|
||
{ | ||
description: | ||
'Test 3: should fail when one of the users is returning with 4xx(not 404) from destination', | ||
input: { | ||
request: { | ||
body: [ | ||
{ | ||
destType: destType.toUpperCase(), | ||
userAttributes: [ | ||
{ | ||
userId: 'rudder1', | ||
}, | ||
{ | ||
userId: 'rudder3', | ||
}, | ||
], | ||
config: { | ||
apiKey: 'dummyApiKey', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 400, | ||
body: [{ statusCode: 400, error: '{"error":"User: rudder3 has a problem"}' }], | ||
}, | ||
}, | ||
}, | ||
|
||
{ | ||
description: | ||
'Test 4: should fail when one of the userAttributes does not contain `userId`', | ||
input: { | ||
request: { | ||
body: [ | ||
{ | ||
destType: destType.toUpperCase(), | ||
userAttributes: [ | ||
{ | ||
userId: 'rudder1', | ||
}, | ||
{ | ||
}, | ||
], | ||
config: { | ||
apiKey: 'dummyApiKey', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 400, | ||
body: [{ statusCode: 400, error: 'User id for deletion not present' }], | ||
}, | ||
}, | ||
}, | ||
].map((props) => ({ ...commonData, ...props })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,85 @@ | ||
export const networkCallsData = [ | ||
{ | ||
httpReq: { | ||
url: 'https://api.custify.com/company', | ||
method: 'POST', | ||
{ | ||
httpReq: { | ||
url: 'https://api.custify.com/company', | ||
method: 'POST', | ||
}, | ||
httpRes: { | ||
data: { | ||
company_id: '6', | ||
name: 'Pizzeria Presto', | ||
signed_up_at: '2019-05-30T12:00:00.000Z', | ||
size: 15, | ||
website: 'www.pizzeriapresto.com', | ||
industry: 'Restaurant', | ||
plan: 'Platinum', | ||
monthly_revenue: 1234567, | ||
churned: false, | ||
owners_csm: '[email protected]', | ||
owners_account: '[email protected]', | ||
parent_companies: [ | ||
{ | ||
id: '5ec50c9829d3c17c7cf455f2', | ||
}, | ||
{ | ||
id: '5ec50c9829d3c17c7cf457f2', | ||
}, | ||
], | ||
custom_attributes: { | ||
restaurants: 5, | ||
custom: 'template', | ||
}, | ||
httpRes: { | ||
data: { | ||
"company_id": "6", | ||
"name": "Pizzeria Presto", | ||
"signed_up_at": "2019-05-30T12:00:00.000Z", | ||
"size": 15, | ||
"website": "www.pizzeriapresto.com", | ||
"industry": "Restaurant", | ||
"plan": "Platinum", | ||
"monthly_revenue": 1234567, | ||
"churned": false, | ||
"owners_csm": "[email protected]", | ||
"owners_account": "[email protected]", | ||
"parent_companies": [ | ||
{ | ||
"id": "5ec50c9829d3c17c7cf455f2" | ||
}, | ||
{ | ||
"id": "5ec50c9829d3c17c7cf457f2" | ||
} | ||
], | ||
"custom_attributes": { | ||
"restaurants": 5, | ||
"custom": "template" | ||
} | ||
}, | ||
status: 200 | ||
}, | ||
} | ||
}, | ||
status: 200, | ||
}, | ||
}, | ||
|
||
{ | ||
httpReq: { | ||
method: 'delete', | ||
url: 'https://api.custify.com/people?user_id=rudder1', | ||
headers: { | ||
Authorization: 'Bearer dummyApiKey', | ||
}, | ||
}, | ||
httpRes: { | ||
data: { | ||
msg: 'All users associated with rudder1 were successfully deleted', | ||
code: 'Success', | ||
params: null, | ||
}, | ||
status: 200, | ||
}, | ||
}, | ||
{ | ||
httpReq: { | ||
method: 'delete', | ||
url: 'https://api.custify.com/people?user_id=rudder2', | ||
headers: { | ||
Authorization: 'Bearer dummyApiKey', | ||
}, | ||
}, | ||
httpRes: { | ||
data: { | ||
error: 'User: rudder2 not found', | ||
}, | ||
status: 404, | ||
}, | ||
}, | ||
|
||
{ | ||
httpReq: { | ||
method: 'delete', | ||
url: 'https://api.custify.com/people?user_id=rudder3', | ||
headers: { | ||
Authorization: 'Bearer dummyApiKey', | ||
}, | ||
}, | ||
httpRes: { | ||
data: { | ||
error: 'User: rudder3 has a problem', | ||
}, | ||
status: 400, | ||
}, | ||
}, | ||
]; |