mockserver-client
Advanced tools
+1
-1
| { | ||
| "name": "mockserver-client", | ||
| "version": "1.0.6", | ||
| "version": "1.0.7", | ||
| "homepage": "https://github.com/jamesdbloom/mockserver-client-node", | ||
@@ -5,0 +5,0 @@ "authors": [ |
+2
-2
@@ -91,3 +91,3 @@ /* | ||
| cookies: [], | ||
| parameters: [] | ||
| queryStringParameters: [] | ||
| }; | ||
@@ -313,3 +313,3 @@ }; | ||
| cookies: [], | ||
| parameters: [] | ||
| queryStringParameters: [] | ||
| }; | ||
@@ -316,0 +316,0 @@ }; |
+1
-1
| { | ||
| "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": { |
+5
-5
@@ -6,9 +6,9 @@ # mockserver-client-node | ||
| [](https://drone.io/github.com/jamesdbloom/mockserver-client-node/latest) [](https://david-dm.org/jamesdbloom/mockserver-client-node) [](https://david-dm.org/jamesdbloom/mockserver-client-node#info=devDependencies) | ||
| [](http://stillmaintained.com/jamesdbloom/mockserver) | ||
| [](http://stillmaintained.com/jamesdbloom/mockserver) | ||
| [](https://waffle.io/jamesdbloom/mockserver) [](https://waffle.io/jamesdbloom/mockserver) [](https://waffle.io/jamesdbloom/mockserver) | ||
| [](https://nodei.co/npm/mockserver-client/) [](https://app.wercker.com/project/bykey/7b78f11513b3dc5379f510a7ac82d0d6) | ||
| [](https://nodei.co/npm/mockserver-client/) [](https://app.wercker.com/project/bykey/7b78f11513b3dc5379f510a7ac82d0d6) | ||
| For chat room: [](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 @@ "}>"); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
223145
10.55%5182
8.61%