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

ci(test): Fix nmi postman collection #5928

Merged
merged 13 commits into from
Sep 20, 2024
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"childrenOrder": [
"Payments - Create",
"Payments - Retrieve",
"List payment methods for a Customer",
"Save card payments - Create",
"Save card payments - Confirm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pm.test("[GET]::/payments/:id - Status code is 2xx", function () {
// Validate if response header has matching content-type
pm.test("[GET]::/payments/:id - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json",
"application/json"
);
});

Expand All @@ -26,11 +26,11 @@ if (jsonData?.payment_id) {
pm.collectionVariables.set("payment_id", jsonData.payment_id);
console.log(
"- use {{payment_id}} as collection variable for value",
jsonData.payment_id,
jsonData.payment_id
);
} else {
console.log(
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.",
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined."
);
}

Expand All @@ -39,11 +39,11 @@ if (jsonData?.mandate_id) {
pm.collectionVariables.set("mandate_id", jsonData.mandate_id);
console.log(
"- use {{mandate_id}} as collection variable for value",
jsonData.mandate_id,
jsonData.mandate_id
);
} else {
console.log(
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.",
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined."
);
}

Expand All @@ -52,10 +52,10 @@ if (jsonData?.client_secret) {
pm.collectionVariables.set("client_secret", jsonData.client_secret);
console.log(
"- use {{client_secret}} as collection variable for value",
jsonData.client_secret,
jsonData.client_secret
);
} else {
console.log(
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.",
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined."
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
}
],
"url": {
"raw": "{{baseUrl}}/payments/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"payments",
":id"
"raw": "{{baseUrl}}/payments/:id?force_sync=true",
"host": ["{{baseUrl}}"],
"path": ["payments", ":id"],
"query": [
{
"key": "force_sync",
"value": "true"
}
],
"variable": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"childrenOrder": [
"Payments - Create",
"Payments - Retrieve",
"List payment methods for a Customer",
"Save card payments - Create",
"Save card payments - Confirm"
]
}
]}
Original file line number Diff line number Diff line change
@@ -1,60 +1,83 @@
// Validate status 2xx
// Validate status 2xx
pm.test("[POST]::/payments - Status code is 2xx", function () {
pm.response.to.be.success;
pm.response.to.be.success;
});

// 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");
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json"
);
});

// Validate if response has JSON Body
// Validate if response has JSON Body
pm.test("[POST]::/payments - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
pm.response.to.have.jsonBody();
});

// Set response object as internal variable
let jsonData = {};
try {jsonData = pm.response.json();}catch(e){}
try {
jsonData = pm.response.json();
} catch (e) {}

// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id
if (jsonData?.payment_id) {
pm.collectionVariables.set("payment_id", jsonData.payment_id);
console.log("- use {{payment_id}} as collection variable for value",jsonData.payment_id);
pm.collectionVariables.set("payment_id", jsonData.payment_id);
console.log(
"- use {{payment_id}} as collection variable for value",
jsonData.payment_id
);
} else {
console.log('INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined.');
};

console.log(
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined."
);
}

// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id
if (jsonData?.mandate_id) {
pm.collectionVariables.set("mandate_id", jsonData.mandate_id);
console.log("- use {{mandate_id}} as collection variable for value",jsonData.mandate_id);
pm.collectionVariables.set("mandate_id", jsonData.mandate_id);
console.log(
"- use {{mandate_id}} as collection variable for value",
jsonData.mandate_id
);
} else {
console.log('INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined.');
};
console.log(
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined."
);
}

// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret
if (jsonData?.client_secret) {
pm.collectionVariables.set("client_secret", jsonData.client_secret);
console.log("- use {{client_secret}} as collection variable for value",jsonData.client_secret);
pm.collectionVariables.set("client_secret", jsonData.client_secret);
console.log(
"- use {{client_secret}} as collection variable for value",
jsonData.client_secret
);
} else {
console.log('INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined.');
};
console.log(
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined."
);
}

// Response body should have value "processing" for "status"
if (jsonData?.status) {
pm.test(
"[POST]::/payments - Content check if value for 'status' matches 'processing'",
function () {
pm.expect(jsonData.status).to.eql("processing");
},
}
);
}

if (jsonData?.customer_id) {
pm.collectionVariables.set("customer_id", jsonData.customer_id);
console.log("- use {{customer_id}} as collection variable for value",jsonData.customer_id);
pm.collectionVariables.set("customer_id", jsonData.customer_id);
console.log(
"- use {{customer_id}} as collection variable for value",
jsonData.customer_id
);
} else {
console.log('INFO - Unable to assign variable {{customer_id}}, as jsonData.customer_id is undefined.');
};
console.log(
"INFO - Unable to assign variable {{customer_id}}, as jsonData.customer_id is undefined."
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"eventOrder": [
"event.test.js"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Validate status 2xx
pm.test("[GET]::/payments/:id - Status code is 2xx", function () {
pm.response.to.be.success;
});

// Validate if response header has matching content-type
pm.test("[GET]::/payments/:id - Content-Type is application/json", function () {
pm.expect(pm.response.headers.get("Content-Type")).to.include(
"application/json"
);
});

// Set response object as internal variable
let jsonData = {};
try {
jsonData = pm.response.json();
} catch (e) {}

// Validate if response has JSON Body
pm.test("[GET]::/payments/:id - Response has JSON Body", function () {
pm.response.to.have.jsonBody();
});

// pm.collectionVariables - Set payment_id as variable for jsonData.payment_id
if (jsonData?.payment_id) {
pm.collectionVariables.set("payment_id", jsonData.payment_id);
console.log(
"- use {{payment_id}} as collection variable for value",
jsonData.payment_id
);
} else {
console.log(
"INFO - Unable to assign variable {{payment_id}}, as jsonData.payment_id is undefined."
);
}

// pm.collectionVariables - Set mandate_id as variable for jsonData.mandate_id
if (jsonData?.mandate_id) {
pm.collectionVariables.set("mandate_id", jsonData.mandate_id);
console.log(
"- use {{mandate_id}} as collection variable for value",
jsonData.mandate_id
);
} else {
console.log(
"INFO - Unable to assign variable {{mandate_id}}, as jsonData.mandate_id is undefined."
);
}

// pm.collectionVariables - Set client_secret as variable for jsonData.client_secret
if (jsonData?.client_secret) {
pm.collectionVariables.set("client_secret", jsonData.client_secret);
console.log(
"- use {{client_secret}} as collection variable for value",
jsonData.client_secret
);
} else {
console.log(
"INFO - Unable to assign variable {{client_secret}}, as jsonData.client_secret is undefined."
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/payments/:id?force_sync=true",
"host": ["{{baseUrl}}"],
"path": ["payments", ":id"],
"query": [
{
"key": "force_sync",
"value": "true"
}
],
"variable": [
{
"key": "id",
"value": "{{payment_id}}",
"description": "(Required) unique payment id"
}
]
},
"description": "To retrieve the properties of a Payment. This may be used to get the status of a previously initiated payment or next action for an ongoing payment"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Loading