Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pactum

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pactum - npm Package Compare versions

Comparing version 3.1.10 to 3.1.11

2

package.json
{
"name": "pactum",
"version": "3.1.10",
"version": "3.1.11",
"description": "REST API Testing Tool for all levels in a Test Pyramid",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -23,2 +23,3 @@ export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE';

body?: object;
file?: string;
fixedDelay?: number;

@@ -25,0 +26,0 @@ randomDelay?: RandomDelay;

@@ -93,3 +93,5 @@ const { URL } = require('url');

for (const prop in multiPartHeaders) {
request.headers[prop] = multiPartHeaders[prop];
if (request.headers[prop] === undefined) {
request.headers[prop] = multiPartHeaders[prop];
}
}

@@ -96,0 +98,0 @@ }

@@ -169,2 +169,5 @@ const { setMatchingRules, getValue } = require('pactum-matchers').utils;

}
if (response.file) {
this.file = getValue(response.file);
}
}

@@ -171,0 +174,0 @@ }

const polka = require('polka');
const fs = require('fs');
const mime = require('mime-lite')
const fs_path = require('path');

@@ -141,5 +144,5 @@ const Interaction = require('./Interaction.model');

if (delay > 0) {
setTimeout(() => sendResponseBody(res, _response.body), delay);
setTimeout(() => sendResponse(res, _response), delay);
} else {
sendResponseBody(res, _response.body);
sendResponse(res, _response);
}

@@ -168,7 +171,9 @@ }

* @param {ExpressResponse} res - HTTP response
* @param {object} body - response body to be sent
* @param {object} interaction_response - response body to be sent
*/
function sendResponseBody(res, body) {
if (body) {
res.send(body);
function sendResponse(res, interaction_response) {
if (interaction_response.file) {
res.download(interaction_response);
} else if (interaction_response.body) {
res.send(interaction_response.body);
} else {

@@ -397,3 +402,6 @@ res.send();

if (typeof data === 'object') {
this.res.setHeader('Content-Type', 'application/json');
const header_keys = this.res.getHeaderNames();
if (!header_keys.includes('content-type')) {
this.res.setHeader('Content-Type', 'application/json');
}
this.res.end(JSON.stringify(data));

@@ -407,4 +415,18 @@ } else {

}
download(interaction_response) {
if (interaction_response.headers) {
const header_keys = Object.keys(interaction_response.headers).map(_ => _.toLowerCase());
if (!header_keys.includes('content-type')) {
const file_name = fs_path.basename(interaction_response.file)
this.res.setHeader('content-type', mime.getType(file_name));
}
} else {
const file_name = fs_path.basename(interaction_response.file)
this.res.setHeader('content-type', mime.getType(file_name));
}
fs.createReadStream(interaction_response.file).pipe(this.res);
}
}
module.exports = Server;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc