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

mockserver-client

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mockserver-client - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

bower.json
{
"name": "mockserver-client",
"version": "1.0.6",
"version": "1.0.7",
"homepage": "https://github.com/jamesdbloom/mockserver-client-node",

@@ -5,0 +5,0 @@ "authors": [

@@ -91,3 +91,3 @@ /*

cookies: [],
parameters: []
queryStringParameters: []
};

@@ -313,3 +313,3 @@ };

cookies: [],
parameters: []
queryStringParameters: []
};

@@ -316,0 +316,0 @@ };

{
"name": "mockserver-client",
"description": "A node client for the MockServer",
"version": "1.0.6",
"version": "1.0.7",
"homepage": "https://github.com/jamesdbloom/mockserver",

@@ -6,0 +6,0 @@ "author": {

@@ -6,9 +6,9 @@ # mockserver-client-node

[![Build Status](https://drone.io/github.com/jamesdbloom/mockserver-client-node/status.png)](https://drone.io/github.com/jamesdbloom/mockserver-client-node/latest) [![Dependency Status](https://david-dm.org/jamesdbloom/mockserver-client-node.png)](https://david-dm.org/jamesdbloom/mockserver-client-node) [![devDependency Status](https://david-dm.org/jamesdbloom/mockserver-client-node/dev-status.png)](https://david-dm.org/jamesdbloom/mockserver-client-node#info=devDependencies)
[![Still Maintained](http://stillmaintained.com/jamesdbloom/mockserver.png)](http://stillmaintained.com/jamesdbloom/mockserver)
[![Still Maintained](http://stillmaintained.com/jamesdbloom/mockserver.png)](http://stillmaintained.com/jamesdbloom/mockserver)
[![Stories in Backlog](https://badge.waffle.io/jamesdbloom/mockserver.png?label=proposal&title=Proposals)](https://waffle.io/jamesdbloom/mockserver) [![Stories in Backlog](https://badge.waffle.io/jamesdbloom/mockserver.png?label=ready&title=Ready)](https://waffle.io/jamesdbloom/mockserver) [![Stories in Backlog](https://badge.waffle.io/jamesdbloom/mockserver.png?label=in%20progress&title=In%20Progress)](https://waffle.io/jamesdbloom/mockserver)
[![NPM](https://nodei.co/npm/mockserver-client.png?downloads=true&stars=true)](https://nodei.co/npm/mockserver-client/) [![wercker status](https://app.wercker.com/status/7b78f11513b3dc5379f510a7ac82d0d6/m "wercker status")](https://app.wercker.com/project/bykey/7b78f11513b3dc5379f510a7ac82d0d6)
[![NPM](https://nodei.co/npm/mockserver-client.png?downloads=true&stars=true)](https://nodei.co/npm/mockserver-client/) [![wercker status](https://app.wercker.com/status/7b78f11513b3dc5379f510a7ac82d0d6/m "wercker status")](https://app.wercker.com/project/bykey/7b78f11513b3dc5379f510a7ac82d0d6)
For chat room: [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/jamesdbloom/mockserver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -49,4 +49,3 @@ ## Getting Started

'path': '/somePath',
'queryString': 'test=true',
'parameters': [
'queryStringParameters': [
{

@@ -104,2 +103,3 @@ 'name': 'test',

* 2015-06-02   v1.0.6   Improved clear and dumpToLog options
* 2015-09-27   v1.0.7   Fixed error with query parameter handling

@@ -106,0 +106,0 @@ ---

@@ -11,3 +11,3 @@ (function () {

function sendRequest(method, host, port, path, jsonBody) {
function sendRequest(method, host, port, path, jsonBody, headers) {
var deferred = Q.defer();

@@ -20,3 +20,4 @@

path: path,
port: port
port: port,
headers: headers
};

@@ -71,4 +72,3 @@

'path': '/somePath',
'queryString': 'test=true',
'parameters': [
'queryStringParameters': [
{

@@ -130,2 +130,243 @@ 'name': 'test',

'should match on method only': function (test) {
// given - a client
var client = mockServerClient("localhost", 1080);
// and - an expectation
client.mockAnyResponse(
{
'httpRequest': {
'method': 'GET'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'first_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// and - another expectation
client.mockAnyResponse(
{
'httpRequest': {
'method': 'POST'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'second_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// then - matching no expectation
sendRequest("PUT", "localhost", 1080, "/somePath")
.then(function (response) {
test.ok(false, "should not match expectation");
}, function (error) {
test.equal(error, 404);
}).then(function () {
// then - matching first expectation
sendRequest("GET", "localhost", 1080, "/somePath")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"first_body"}');
}, function () {
test.ok(false, "should match expectation");
}).then(function () {
// then - request that matches second expectation
sendRequest("POST", "localhost", 1080, "/somePath")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"second_body"}');
}, function (error) {
test.ok(false, "should match expectation");
}).then(function () {
test.done();
});
});
});
});
});
},
'should match on path only': function (test) {
// given - a client
var client = mockServerClient("localhost", 1080);
// and - an expectation
client.mockAnyResponse(
{
'httpRequest': {
'path': '/firstPath'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'first_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// and - another expectation
client.mockAnyResponse(
{
'httpRequest': {
'path': '/secondPath'
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'second_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// then - matching no expectation
sendRequest("GET", "localhost", 1080, "/otherPath")
.then(function (response) {
test.ok(false, "should not match expectation");
}, function (error) {
test.equal(error, 404);
}).then(function () {
// then - matching first expectation
sendRequest("GET", "localhost", 1080, "/firstPath")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"first_body"}');
}, function () {
test.ok(false, "should match expectation");
}).then(function () {
// then - request that matches second expectation
sendRequest("GET", "localhost", 1080, "/secondPath")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"second_body"}');
}, function (error) {
test.ok(false, "should match expectation");
}).then(function () {
test.done();
});
});
});
});
});
},
'should match on query string parameters only': function (test) {
// given - a client
var client = mockServerClient("localhost", 1080);
// and - an expectation
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
{
'name': 'param',
'values': ['first']
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'first_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// and - another expectation
client.mockAnyResponse(
{
'httpRequest': {
'queryStringParameters': [
{
'name': 'param',
'values': ['second']
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'second_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// then - matching no expectation
sendRequest("GET", "localhost", 1080, "/somePath?param=other")
.then(function (response) {
test.ok(false, "should not match expectation");
}, function (error) {
test.equal(error, 404);
}).then(function () {
// then - matching first expectation
sendRequest("GET", "localhost", 1080, "/somePath?param=first")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"first_body"}');
}, function () {
test.ok(false, "should match expectation");
}).then(function () {
// then - request that matches second expectation
sendRequest("GET", "localhost", 1080, "/somePath?param=second")
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"second_body"}');
}, function (error) {
test.ok(false, "should match expectation");
}).then(function () {
test.done();
});
});
});
});
});
},
'should match on body only': function (test) {

@@ -138,3 +379,2 @@ // given - a client

'httpRequest': {
'path': '/somePath',
'body': {

@@ -163,3 +403,2 @@ 'type': "STRING",

'httpRequest': {
'path': '/somePath',
'body': {

@@ -185,3 +424,3 @@ 'type': "REGEX",

// then - non matching request
// then - matching no expectation
sendRequest("POST", "localhost", 1080, "/otherPath", "someIncorrectBody")

@@ -194,3 +433,3 @@ .then(function (response) {

// then - request that matches first expectation
// then - matching first expectation
sendRequest("POST", "localhost", 1080, "/somePath", "someBody")

@@ -220,2 +459,176 @@ .then(function (response) {

'should match on headers only': function (test) {
// given - a client
var client = mockServerClient("localhost", 1080);
// and - an expectation
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
{
'name': 'header',
'values': ['first']
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'first_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// and - another expectation
client.mockAnyResponse(
{
'httpRequest': {
'headers': [
{
'name': 'header',
'values': ['second']
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'second_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// then - matching no expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'header': 'other'})
.then(function (response) {
test.ok(false, "should not match expectation");
}, function (error) {
test.equal(error, 404);
}).then(function () {
// then - matching first expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'header': 'first'})
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"first_body"}');
}, function () {
test.ok(false, "should match expectation");
}).then(function () {
// then - request that matches second expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'header': 'second'})
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"second_body"}');
}, function (error) {
test.ok(false, "should match expectation");
}).then(function () {
test.done();
});
});
});
});
});
},
'should match on cookies only': function (test) {
// given - a client
var client = mockServerClient("localhost", 1080);
// and - an expectation
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
{
'name': 'cookie',
'value': 'first'
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'first_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// and - another expectation
client.mockAnyResponse(
{
'httpRequest': {
'cookies': [
{
'name': 'cookie',
'value': 'second'
}
]
},
'httpResponse': {
'statusCode': 200,
'body': JSON.stringify({ name: 'second_body' }),
'delay': {
'timeUnit': 'MILLISECONDS',
'value': 250
}
},
'times': {
'remainingTimes': 1,
'unlimited': false
}
}
).then(function () {
// then - matching no expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'Cookie': 'cookie=other'})
.then(function (response) {
test.ok(false, "should not match expectation");
}, function (error) {
test.equal(error, 404);
}).then(function () {
// then - matching first expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'Cookie': 'cookie=first'})
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"first_body"}');
}, function () {
test.ok(false, "should match expectation");
}).then(function () {
// then - request that matches second expectation
sendRequest("GET", "localhost", 1080, "/somePath", "", {'Cookie': 'cookie=second'})
.then(function (response) {
test.equal(response.statusCode, 200);
test.equal(response.body, '{"name":"second_body"}');
}, function (error) {
test.ok(false, "should match expectation");
}).then(function () {
test.done();
});
});
});
});
});
},
'should create simple response expectation': function (test) {

@@ -385,2 +798,4 @@ // given - a client and expectation

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -432,2 +847,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -479,2 +896,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -481,0 +900,0 @@ "}>");

@@ -165,2 +165,4 @@ (function () {

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -208,2 +210,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -251,2 +255,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -312,2 +318,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -394,2 +402,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -478,2 +488,4 @@ "}>");

" } ],\n" +
" \"keepAlive\" : true,\n" +
" \"secure\" : false,\n" +
" \"body\" : \"someBody\"\n" +

@@ -480,0 +492,0 @@ "}>");

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