From cd9030506c6843c0331bc93d67590d12e280ecca Mon Sep 17 00:00:00 2001 From: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:34:07 +0530 Subject: [PATCH] ci(postman): Add Customer list endpoint (#2623) --- .../stripe/Customers/.meta.json | 1 + .../Customers/List Customer/.event.meta.json | 5 ++ .../Customers/List Customer/event.test.js | 64 +++++++++++++++++++ .../Customers/List Customer/request.json | 19 ++++++ .../Customers/List Customer/response.json | 1 + 5 files changed, 90 insertions(+) create mode 100644 postman/collection-dir/stripe/Customers/List Customer/.event.meta.json create mode 100644 postman/collection-dir/stripe/Customers/List Customer/event.test.js create mode 100644 postman/collection-dir/stripe/Customers/List Customer/request.json create mode 100644 postman/collection-dir/stripe/Customers/List Customer/response.json diff --git a/postman/collection-dir/stripe/Customers/.meta.json b/postman/collection-dir/stripe/Customers/.meta.json index db26627bb9..3b7497b1ea 100644 --- a/postman/collection-dir/stripe/Customers/.meta.json +++ b/postman/collection-dir/stripe/Customers/.meta.json @@ -1,6 +1,7 @@ { "childrenOrder": [ "Create Customer", + "List Customer", "Retrieve Customer", "Update Customer", "Ephemeral Key", diff --git a/postman/collection-dir/stripe/Customers/List Customer/.event.meta.json b/postman/collection-dir/stripe/Customers/List Customer/.event.meta.json new file mode 100644 index 0000000000..688c85746e --- /dev/null +++ b/postman/collection-dir/stripe/Customers/List Customer/.event.meta.json @@ -0,0 +1,5 @@ +{ + "eventOrder": [ + "event.test.js" + ] +} diff --git a/postman/collection-dir/stripe/Customers/List Customer/event.test.js b/postman/collection-dir/stripe/Customers/List Customer/event.test.js new file mode 100644 index 0000000000..2d1ce4bd2f --- /dev/null +++ b/postman/collection-dir/stripe/Customers/List Customer/event.test.js @@ -0,0 +1,64 @@ +// Validate status 2xx +pm.test("[POST]::/customers - Status code is 2xx", function () { + pm.response.to.be.success; +}); + +// Validate if response header has matching content-type +pm.test("[POST]::/customers - 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]::/customers - 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) {} + + +// Response body should have a minimum length of "1" for "customer_id" +if (jsonData?.customer_id) { + pm.test( + "[POST]::/customers - Content check if value of 'customer_id' has a minimum length of '2'", + function () { + pm.expect(jsonData.customer_id.length).is.at.least(2); + }, + ); +} + + +// Define the regular expression pattern to match customer_id +var customerIdPattern = /^[a-zA-Z0-9_]+$/; + +// Define an array to store the validation results +var validationResults = []; + +// Iterate through the JSON array +jsonData.forEach(function(item, index) { + if (item.hasOwnProperty("customer_id")) { + if (customerIdPattern.test(item.customer_id)) { + validationResults.push("customer_id " + item.customer_id + " is valid."); + } else { + validationResults.push("customer_id " + item.customer_id + " is not valid."); + } + } else { + validationResults.push("customer_id is missing for item at index " + index); + } +}); + +// Check if any customer_id is not valid and fail the test if necessary +if (validationResults.some(result => !result.includes("is valid"))) { + pm.test("Customer IDs validation failed: " + validationResults.join(", "), function() { + pm.expect(false).to.be.true; + }); +} else { + pm.test("All customer IDs are valid: " + validationResults.join(", "), function() { + pm.expect(true).to.be.true; + }); +} diff --git a/postman/collection-dir/stripe/Customers/List Customer/request.json b/postman/collection-dir/stripe/Customers/List Customer/request.json new file mode 100644 index 0000000000..40d39448bb --- /dev/null +++ b/postman/collection-dir/stripe/Customers/List Customer/request.json @@ -0,0 +1,19 @@ +{ + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "url": { + "raw": "{{baseUrl}}/customers/list", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "customers", + "list" + ] + } +} diff --git a/postman/collection-dir/stripe/Customers/List Customer/response.json b/postman/collection-dir/stripe/Customers/List Customer/response.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/postman/collection-dir/stripe/Customers/List Customer/response.json @@ -0,0 +1 @@ +[]