-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deserialization): error message is different when invalid data is…
… passed for payment method data (#4022)
- Loading branch information
1 parent
f5697f3
commit f1fe295
Showing
20 changed files
with
718 additions
and
97 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
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
...act for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/event.test.js
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,26 @@ | ||
// Validate status 400 | ||
pm.test("[POST]::/payments - Status code is 400", function () { | ||
pm.response.to.be.error | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[POST]::/payments - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); | ||
|
||
// Set response object as internal variable | ||
let jsonData = {}; | ||
try { | ||
jsonData = pm.response.json(); | ||
} catch (e) { } | ||
|
||
pm.test("[POST]::/payments - Response has appropriate error message", function () { | ||
pm.expect(jsonData.error.message).eql("Invalid card_cvc length"); | ||
}) |
41 changes: 41 additions & 0 deletions
41
...ract for Payment Method Data/Payments - Card Payment Method Invalid Card CVC/request.json
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,41 @@ | ||
{ | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"amount": 6540, | ||
"currency": "USD", | ||
"payment_method": "card", | ||
"payment_method_data": { | ||
"card": { | ||
"card_number": "4242424242424242", | ||
"card_exp_month": "10", | ||
"card_exp_year": "25", | ||
"card_holder_name": "joseph Doe", | ||
"card_cvc": "" | ||
} | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments"] | ||
}, | ||
"description": "Create a Payment to ensure api contract is intact" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r Payment Method Data/Payments - Card Payment Method Invalid Card Number/.event.meta.json
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,6 @@ | ||
{ | ||
"eventOrder": [ | ||
"event.test.js", | ||
"event.prerequest.js" | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
... for Payment Method Data/Payments - Card Payment Method Invalid Card Number/event.test.js
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,16 @@ | ||
// Validate status 400 | ||
pm.test("[POST]::/payments - Status code is 400", function () { | ||
pm.response.to.be.error | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[POST]::/payments - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); |
41 changes: 41 additions & 0 deletions
41
...t for Payment Method Data/Payments - Card Payment Method Invalid Card Number/request.json
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,41 @@ | ||
{ | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"amount": 6540, | ||
"currency": "USD", | ||
"payment_method": "card", | ||
"payment_method_data": { | ||
"card": { | ||
"card_number": "1234", | ||
"card_exp_month": "10", | ||
"card_exp_year": "25", | ||
"card_holder_name": "joseph Doe", | ||
"card_cvc": "123" | ||
} | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments"] | ||
}, | ||
"description": "Create a Payment to ensure api contract is intact" | ||
} |
6 changes: 6 additions & 0 deletions
6
... Payment Method Data/Payments - Card Payment Method Invalid Expiry month/.event.meta.json
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,6 @@ | ||
{ | ||
"eventOrder": [ | ||
"event.test.js", | ||
"event.prerequest.js" | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
...for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/event.test.js
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,26 @@ | ||
// Validate status 400 | ||
pm.test("[POST]::/payments - Status code is 400", function () { | ||
pm.response.to.be.error | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[POST]::/payments - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); | ||
|
||
// Set response object as internal variable | ||
let jsonData = {}; | ||
try { | ||
jsonData = pm.response.json(); | ||
} catch (e) { } | ||
|
||
pm.test("[POST]::/payments - Response has appropriate error message", function () { | ||
pm.expect(jsonData.error.message).eql("Invalid Expiry Month"); | ||
}) |
41 changes: 41 additions & 0 deletions
41
... for Payment Method Data/Payments - Card Payment Method Invalid Expiry month/request.json
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,41 @@ | ||
{ | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"amount": 6540, | ||
"currency": "USD", | ||
"payment_method": "card", | ||
"payment_method_data": { | ||
"card": { | ||
"card_number": "4242424242424242", | ||
"card_exp_month": "13", | ||
"card_exp_year": "69", | ||
"card_holder_name": "joseph Doe", | ||
"card_cvc": "123" | ||
} | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments"] | ||
}, | ||
"description": "Create a Payment to ensure api contract is intact" | ||
} |
6 changes: 6 additions & 0 deletions
6
...r Payment Method Data/Payments - Card Payment Method Invalid Expiry year/.event.meta.json
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,6 @@ | ||
{ | ||
"eventOrder": [ | ||
"event.test.js", | ||
"event.prerequest.js" | ||
] | ||
} |
31 changes: 31 additions & 0 deletions
31
... for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/event.test.js
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,31 @@ | ||
// Validate status 400 | ||
pm.test("[POST]::/payments - Status code is 400", function () { | ||
pm.response.to.be.error | ||
}); | ||
|
||
// Validate if response header has matching content-type | ||
pm.test("[POST]::/payments - Content-Type is application/json", function () { | ||
pm.expect(pm.response.headers.get("Content-Type")).to.include( | ||
"application/json", | ||
); | ||
}); | ||
|
||
// Validate if response has JSON Body | ||
pm.test("[POST]::/payments - Response has JSON Body", function () { | ||
pm.response.to.have.jsonBody(); | ||
}); | ||
|
||
// Set response object as internal variable | ||
let jsonData = {}; | ||
try { | ||
jsonData = pm.response.json(); | ||
} catch (e) { } | ||
|
||
if (jsonData?.error?.message) { | ||
pm.test( | ||
"[POST]::/payments - Content check for error message to equal `Invalid Expiry Year`", | ||
function () { | ||
pm.expect(jsonData.error.message).to.eql("Invalid Expiry Year"); | ||
}, | ||
); | ||
} |
41 changes: 41 additions & 0 deletions
41
...t for Payment Method Data/Payments - Card Payment Method Invalid Expiry year/request.json
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,41 @@ | ||
{ | ||
"method": "POST", | ||
"header": [ | ||
{ | ||
"key": "Content-Type", | ||
"value": "application/json" | ||
}, | ||
{ | ||
"key": "Accept", | ||
"value": "application/json" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
}, | ||
"raw_json_formatted": { | ||
"amount": 6540, | ||
"currency": "USD", | ||
"payment_method": "card", | ||
"payment_method_data": { | ||
"card": { | ||
"card_number": "4242424242424242", | ||
"card_exp_month": "10", | ||
"card_exp_year": "22", | ||
"card_holder_name": "joseph Doe", | ||
"card_cvc": "123" | ||
} | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{baseUrl}}/payments", | ||
"host": ["{{baseUrl}}"], | ||
"path": ["payments"] | ||
}, | ||
"description": "Create a Payment to ensure api contract is intact" | ||
} |
6 changes: 6 additions & 0 deletions
6
... Contract for Payment Method Data/Payments - Card Payment Method Success/.event.meta.json
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,6 @@ | ||
{ | ||
"eventOrder": [ | ||
"event.test.js", | ||
"event.prerequest.js" | ||
] | ||
} |
Oops, something went wrong.