Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
har2postman
Advanced tools
Javascript Har to Postman converter. THIS PROJECT IS RIGHT NOW UNDER HEAVY DEVELOPMENT
The main goal of the project is the creation of a JS library to convert .har
files to Postman requests/collection in .JSON
format.
HTTP Archive format
or HAR
files are a JSON-formatted archive file format for logging of a web browser's interaction with a site (HTTP transactions).
On the other hand Postman
is a testing API client tool, allowing us to test a request against a specific environment.
The intended audience is, therefore, anybody who finds a use case where this library is useful in any way.
npm install har2postman
var Har2Postman = require('har2postman');
var includeTests = true;
harToPostman.createPostmanCollection(stringifiedHarFile, includeTests);
includeTests
: default false
, set to true
for including test assertions in requestsPlease note every version should include a suite of test cases ensuring new requirements are working. The last test case of the suite should check the library produces a JSON
output matching the content of the file /test/x.x.x/output.json
given a JSON
input matching the content of the file /test/x.x.x/input.json
.
createPostmanCollection
function able to produce a valid postman collection including the expected file
(postman metadata) and item
(request itself) objects out of a har
file.Har2Postman
in npm if new tag is released.har
file (response code, maybe id if path param?).createPostmanCollection
function should include a second optional boolean
argument to decide whether the output should include the test section or not. By default, the behaviour of the boolean flag should be false
.query params
; those should also be mapped from the har file to the postman collection. Evaluate whether some of them (FK?) should be included as part of the test assertions.har
file can contain multiple requests, and all them should be contained within the swagger collectionContent-Type
should be included in the request.xml
formatid
if contained in response as env variable for future requests over same entity (GET, PUT or DELETE)var generateItem = function(){
var item = [{
name: generateItemName(harRequest.method, harRequestUrl.pathname, harResponse.status, generateTest),
event: generateItemEvent(harResponse, harRequestUrl),
request: {
method: harRequest.method,
url: {
raw: harRequestUrl.toString(),
protocol: harRequestUrl.protocol.slice(0, -1),
host: harRequestUrl.hostname.split('.'),
path: harPathnameArray.slice(1)
}
}
}];
}
The right way for this function would be:
var generateItem = function(){
return [{
name: generateItemName(harRequest.method, harRequestUrl.pathname, harResponse.status, generateTest),
event: generateItemEvent(harResponse, harRequestUrl),
request: generateRequest(harRequest, harRequestUrl);
}];
}
var generateRequest = function(){
return {
method: harRequest.method,
url: generateUrl(harRequestUrl);
}
}
//var generateUrl = function() ...
Also important have a look at the functions returning arrays instead of objects, this will have to change in the future if those arrays need more than one element.
This project is licensed under the MIT License - see the LICENSE file for details
FAQs
Har to postman converter
The npm package har2postman receives a total of 24 weekly downloads. As such, har2postman popularity was classified as not popular.
We found that har2postman demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.