Giter Site home page Giter Site logo

bbyars / mountebank Goto Github PK

View Code? Open in Web Editor NEW
2.0K 56.0 258.0 52.07 MB

Over the wire test doubles

Home Page: http://www.mbtest.org

License: MIT License

Shell 0.15% JavaScript 53.35% CSS 0.49% Dockerfile 0.02% EJS 45.98%
mountebank service-virtualization test-automation testing test-framework microservices-testing mocking stubbing

mountebank's Introduction

Welcome, friend

mountebank is the only open source service virtualization tool that competes with the commercial offerings in terms of protocol diversity, capability, and performance. Here's what Capital One wrote about their mobile cloud migration (emphasis theirs):

In fact, halfway through we discovered our corporate mocking software couldn’t handle the sheer amount of performance testing we were running as part of this effort (we completely crushed some pretty industrial enterprise software in the process). As a result, we made the call to move the entire program over to a Mountebank OSS-based solution with a custom provision to give us the ability to expand/shrink our mocking needs on demand.

At the moment, the following protocols are implemented, either directly in the tool or as a community extension:

  • http
  • https
  • tcp (text and binary)
  • smtp
  • ldap
  • grpc
  • websockets
  • graphql
  • snmp
  • telnet
  • ssh
  • netconf

mountebank supports mock verification, stubbing with advanced predicates, JavaScript injection, and record-playback through proxying.

how it works

See getting started guide for more information.

Install and Run

Install:

npm install -g mountebank

Run:

mb

There are a number of command line options if you need to customize mountebank.

All pre-release versions of mountebank are available with the beta npm tag. No beta version is published unless it has passed all tests.

Learn More

After installing and running, view the docs in your browser at http://localhost:2525, or visit the public site.

You can always learn more and support mountebank development by buying the book:

Testing Microservices with Mountebank

Roadmap and Support

mountebank is used by a large number of companies and I think it's important to convey my best guess as to what the feature roadmap is. I've adopted GitHub tools to manage the roadmap. Specifically, the Roadmap project page shows the features by release. I generally re-prioritize and update the ETAs each release.

Visit the Google group for any support questions. Don't be shy!

mountebank is provided free of charge and maintained in my free time. As such, I'm unable to make any kind of guarantees around either support turn-around time or release dates.

Building

There are two packages: mountebank itself, and a test package called mbTest (which houses all out-of-process tests against mountebank). First ensure all dependencies are installed for both packages:

npm install

Then, run all tests:

npm test

Several other test configurations exist. You can see the CI pipeline in .circleci/config.yml.

There are some tests that require network access. A few of these tests verify the correct behavior under DNS failures. If your ISP is kind enough to hijack the NXDOMAIN DNS response in an attempt to allow you to conveniently peruse their advertising page, those tests will fail. I suggest that, under such circumstances, you talk to your ISP and let them know that their policies are causing mountebank tests to fail. You can also set the environment variable MB_AIRPLANE_MODE=true, which will avoid tests requiring your DNS resolver.

Support

I make a good faith effort to monitor conversations in the mountebank Google group. Given that mountebank is a free tool freely maintained in my (increasingly limited) free time, I make no promises about response time (or responses at all).

Contributing

Contributions are welcome! Some tips for contributing are in the CONTRIBUTING.md.

mountebank's People

Contributors

arosenberg01 avatar bbyars avatar cebiggs avatar cgrad01 avatar colinnewell avatar david-connolly-gp avatar dependabot[bot] avatar gepower avatar greenkeeper[bot] avatar ibnc avatar jamiegeddes avatar jasonareid avatar jbolda avatar kebernet avatar mario-git avatar mario54 avatar mijailr avatar mike-gore-cko avatar mmillsatrepay avatar moodmosaic avatar ndrwdn avatar njenan avatar prayerslayer avatar ruudk avatar snyk-bot avatar stkac55 avatar stormsys avatar thejamesthomas avatar vpalivela avatar zedar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mountebank's Issues

Does not handle tcp requests greater than 1 packet

mountebank assumes all tcp requests are 1 packet in length. Any tcp requests greater than 1 packet will be treated as multiple requests.

Not sure how to handle this, as it may rely on protocol-specific end-of-request sentinel data in the final packet? If sender sends the FIN bit then it's just a matter of waiting for that to end the request - that can perhaps be controlled through another imposter parameter.

Link to imposter page from /logs

Change logs page to link the [http:2526] to the imposter page
Would need to add createdAt field to imposter, and only link to imposters created after the timestamp

Improved validation

Right now, during the validation phase, the first stub is validated by dry running it. However, only errors detected from the first stub are detected. Improve the validation by dry running all stub resolvers, even if predicates fail or it is second in the responses array.

/logs does not handle log rotation correctly

The winston logger rotates logs by appending a number to the end of the normal log file, resulting in the newest log file being called (for example) mb3.log. The /logs file only reads mb.log.

Cannot create imposter on Windows without setting content type

POST /imposters fails:

bbyars@WIN-1H1KP2T2PHK /cygdrive/c/Users/bbyars/Downloads/mountebank-v1.1.20-win-x86/mountebank-v1.1.20-win-x86

Client:

$ curl -i -X POST -d'{"protocol": "http"}' http://localhost:2525/imposters
HTTP/1.1 400 Bad Request
content-type: application/json
content-length: 109
Date: Wed, 07 May 2014 04:07:58 GMT
Connection: keep-alive

{
"errors": [
{
"code": "bad data",
"message": "'protocol' is a required field"
}
]
}

Server:

C:\Users\bbyars\Downloads>mb
info: [mb:2525] mountebank v1.0.385 now taking orders - point your browser to http://localhost:2525 for help
info: [mb:2525] POST /imposters
warn: [mb:2525] error creating imposter: [{"code":"bad data","message":"'protocol' is a required field"}]

Incorrect handling of JSON null values

Send this to /imposters

{"port":"8899",
"stubs":[
{"predicates":[
{"endsWith":{"path":"/ned/flight/status"}}
],
"responses":[{"is":{"statusCode":400,"body":null}}]}
],
"protocol":"http"}

Mountebank will not respond at all.

Wait until it comes back and do a GET and you get back a 500 and this:

TypeError: Cannot read property '_links' of null

at changeLinks (/home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:25:28)

at traverse (/home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:32:21)

at /home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:35:29

at Array.forEach (native)

at traverse (/home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:33:38)

at /home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:35:29

at Array.forEach (native)

at traverse (/home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:33:38)

at /home/developer/work/domestic-api/build_tmp/nodejs/lib/node_modules/mountebank/src/util/middleware.js:35:29

at Array.forEach (native)

DELETE will delete it and MB seems to work just fine after the delete (but, of course, the same error message comes back.

We fixed it by removing the "body".

Lee

The lint grunt task fails on windows

On Windows, the grunt task

lint

results in

Running "wsCheck" task
Fatal error: Command failed: 'scripts' is not recognized as an internal or external command,
operable program or batch file.

How to handle conditional stub?

I have a stub for a RESTful endpoint that just returns the object's JSON. Later on my test I made a call to the stub that deletes that object, how do I make it so that the next call to object endpoint returns the 404 stub?

HTTP/1.1 500 Internal Server Error when visiting an SMTP imposter through the browser

I issue a POST request to an SMTP imposter

POST http://192.168.1.4:2525/imposters/ HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: 192.168.1.4:2525
Content-Length: 36
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

{ "port": 4547, "protocol": "smtp" }

The result is HTTP/1.1 201 Created

HTTP/1.1 201 Created
Location: http://192.168.1.4:2525/imposters/4547
content-type: application/json
content-length: 167
Date: Tue, 20 May 2014 19:40:37 GMT
Connection: keep-alive

{
  "protocol": "smtp",
  "port": 4547,
  "requests": [],
  "stubs": [],
  "_links": {
    "self": {
      "href": "http://192.168.1.4:2525/imposters/4547"
    }
  }
}

Then, I visit the Location URL with a browser (issuing a GET request - 192.168.1.4 is localhost)

GET http://192.168.1.4:2525/imposters/4547 HTTP/1.1
Host: localhost:2525
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Referer: http://localhost:2525/imposters/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

The result is HTTP/1.1 500 Internal Server Error

HTTP/1.1 500 Internal Server Error
vary: Accept
Content-Type: text/html
Content-Length: 1638
Date: Tue, 20 May 2014 19:43:46 GMT
Connection: keep-alive

TypeError: C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\src\views\imposter.ejs:9
    7| <% requests.forEach(function (request) { -%>
    8|   <pre><code>
 >> 9|     <%= request.method %> <%=request.path %> HTTP/1.1
    10| <% Object.keys(request.headers).forEach(function (name) { -%>
    11|     <%= name %>: <%= request.headers[name] %>
    12| <% }); -%>

Object.keys called on non-object
    at Function.keys (native)
    at __stack.lineno (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:31:395)
    at Array.forEach (native)
    at eval (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:31:199)
    at eval (eval at <anonymous> (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:33:37)
    at C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:255:15
    at Object.exports.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:293:13)
    at View.exports.renderFile [as engine] (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\ejs\lib\ejs.js:323:20)
    at View.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\express\lib\view.js:76:8)
    at Function.app.render (C:\Users\Nikos\AppData\Roaming\npm\node_modules\mountebank\node_modules\express\lib\application.js:502:10)

Add ssh protocol

Add ssh protocol, primarily for mock verification. From Max Lincoln:

SSH would be a very powerful protocol to use. A lot of the new infra-as-code cloud tools basically:

  1. Use REST to call cloud providers to build servers/load balancers/etc
  2. (Optionally) Send data from the cloud provider to a management tool, like Hosted Chef, using REST again.
  3. Then SSH to the server(s) for configuration, running commands and/or using SSH-based file-transfer protocols.

1 & 2 are easily stubbed, but 3 is not.

What's awesome is that apparently writing an rsync server in node is easy, and sftp seems a little more complicated, but scp and rsync just send simple commands to start a server, and gives clues about the file it's going to receive:
Sending command: scp -v -t asdf
Sending command: rsync --server -v . 22:asdf

In other words, SSH looks very recordable/mockable.

Content-negotiated pages fail to render in IE

IE sends an accept header of /, and mountebank defaults to JSON representation unless text/html is requested. For pages where no JSON representation is available (e.g. /docs/gettingStarted), IE renders OK. For the pages on the header, which depend on content negotiation, IE asks to download the file.

Allow decorating proxies

I want to proxy a HTTP URL which I could do successfully.

But my requirement also says that with response, I need to add some additional header. It means once my backend sends response back to Mountebank, before Mountebank sends response back to consumer/client application, it should add some custom header. Please suggest how it's possible?

I couldn't find any option with stub proxy to customize received server response before sending back to client application.

imposter POST functional tests behave erratically

On Windows, the grunt task

test:functional

results in 1 failing test

1) tcp imposter POST /imposters with injections should allow asynchronous injection:
   AssertionError: -1 === 0
    at \mountebank\functionalTest\api\tcp\tcpInjectionTest.js:139:24
    at _fulfilled (\mountebank\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (\mountebank\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (\mountebank\node_modules\q\q.js:749:13)
    at \mountebank\node_modules\q\q.js:557:44
    at flush (\mountebank\node_modules\q\q.js:108:17)
    at process._tickDomainCallback (node.js:463:13)

and sometimes it results in 2 failing tests

1) http imposter POST /imposters with stubs should add latency when using behaviors.wait:
   AssertionError: false == true
    at \mountebank\functionalTest\api\http\httpStubTest.js:194:28
    at _fulfilled (\mountebank\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (\mountebank\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (\mountebank\node_modules\q\q.js:749:13)
    at \mountebank\node_modules\q\q.js:557:44
    at flush (\mountebank\node_modules\q\q.js:108:17)
    at process._tickDomainCallback (node.js:463:13)

2) tcp imposter POST /imposters with injections should allow asynchronous injection:
   AssertionError: -1 === 0
    at \mountebank\functionalTest\api\tcp\tcpInjectionTest.js:139:24
    at _fulfilled (\mountebank\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (\mountebank\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (\mountebank\node_modules\q\q.js:749:13)
    at \mountebank\node_modules\q\q.js:557:44
    at flush (\mountebank\node_modules\q\q.js:108:17)
    at process._tickDomainCallback (node.js:463:13)

Predicates do not match ints, floats, booleans

One thing I ran into with configuring a stub was a predicate like this --

    {
      "deepEquals": {
        "path": "/imoji/index.php",
        "query": {
          "fb_id": 100
        },
        "method": "GET"
      }
    }

Initially I was surprised it never matched. Then I changed the query value to a string and it worked.

http proxy adds ? to all urls, even those without query params

I created a proxy on my local machine like this on port 6768

    "responses": [
            {
                "proxy": {
                    "to": "http://dp18de.dev.org:6363",
                    "mode": "proxyAlways"
                }
            }
        ]

When I make a call to proxy like this
http://localhost:6568/accounts/banking

I noticed that it's adding '?' in the URI when it reach to server. The incoming URL to server looks like this http://dp18de.dev.org:6363/accounts/banking?

Can anyone suggest why extra character getting added in the end of the URL?

Create MSI for Windows installation

There are currently package installs for some platforms, but not Windows. Ideally, I need a Powershell script to generate an MSI that installs a self-contained package in the path, bundled with the right version of node. See the already bundled zip files.

mb stop and restart commands don't work on Windows

The mb script uses a pidfile for process management, with the stop command supporting killing a running mb process. The implementation shells out to the kill command, making it non-portable to Windows.

Cannot proxy to https from http

I setup proxy imposters to talk to client webservice server (SOAP).
There are both HTTP and HTTPS
Here is the configuration

{
"port": 9094,
"protocol": "http",
"stubs": [{
"responses": [
{ "proxy": {
"to": "https://XXX-SERVER_NAME?wsdl",
"mode": "proxyAlways",
"predicateGenerators": [
{
"matches": {
"method": true,
"path": true,
"query": true
}
}
]
}
}
]
}]
}

I set up port 9094 to call HTTPS and this is the response

{"errors":[{"message":"Hostname/IP doesn't match certificate's altnames","name":"Error","stack":"Error: Hostname/IP doesn't match certificate's altnames\n at SecurePair. (tls.js:1379:23)\n at SecurePair.EventEmitter.emit (events.js:92:17)\n at SecurePair.maybeInitFinished (tls.js:982:10)\n at CleartextStream.read as _read\n at CleartextStream.Readable.read (_stream_readable.js:320:10)\n at EncryptedStream.write as _write\n at doWrite (_stream_writable.js:226:10)\n at writeOrBuffer (_stream_writable.js:216:5)\n at EncryptedStream.Writable.write (_stream_writable.js:183:11)\n at write (_stream_readable.js:583:24)"}]}

This is the response I got from MB. I’ve tried using my hostname, and IP, I got the same result.

  1.    {
    
  2.        "protocol": "http",
    
  3.        "port": 9094,
    
  4.        "requests": [],
    
  5.        "stubs": [{
    
  6.            "responses": [{
    
  7.                "proxy": {
    
  8.                    "to": "XXX-SERVER-XXX?wsdl",
    
  9.                    "mode": "proxyAlways",
    
  10.                 "predicateGenerators": [{
    
  11.                     "matches": {
    
  12.                         "method": true,
    
  13.                         "path": true,
    
  14.                         "query": true
    
  15.                     }
    
  16.                 }]
    
  17.             }
    
  18.         }]
    
  19.     }],
    
  20.     "_links": {
    
  21.         "self": {
    
  22.             "href": "http://127.0.0.1:2525/imposters/9097"
    
  23.         }
    
  24.     }
    
  25. }
    

Here is the response for 9095 when I try to connect to HTTP
Not Found
HTTP Error 404. The requested resource is not found.
Let me know if you need any more information

restarting mountebank will cause everything lost

is that mountebank, as a node.js application, relies on in-memory storage? I found out after stop/re-start mb, all the imposters are gone.

so question: if I want to use mountebank as a stub API server, what are the best practises?

Response Injection: Request body expected in JSON but received in text

Hi,

I'm extending the response injection exemple found in the documentation:
http://www.mbtest.org/docs/api/injection
(in the "response injection" chapter)

What I'm trying is to inject a little of functional logic in my mock.

I should:

  1. read the request body
  2. compute some of it's values
  3. serve a response accordingly

My request body is a json string. My app send data to the mock using:

unirest.post(full_url)
        .header('Accept', 'application/json')
        .send({'str': text})

What I received in my mountebank script is a string:

str=message2

where I expected json.

For analysis:

  • I use EJS templates (same structure than in http://www.mbtest.org/docs/commandLine)

  • I launch mountbank from the commandline with this parameters:

    ./node_modules/.bin/mb --configfile ./test/lib/mountebank/imposters.ejs --allowInjection --port 2526

  • Below is the code of my mock.

Thanks for your time and for this usefull tool !

function (request, state, logger, callback) {

    if (request.isDryRun) {
        callback({});
    }


    logger.info('ADVANCED MOCK MARK I');
    state.requests = state.requests || 0;
    state.requests += 1;

    var reqsize=1;
    var note="mbdefault";
    var req_status = 200;

    if (request.body){
        logger.info("request", request);
        logger.info("state", state);
        logger.info("body", request.body);
        var req = request.body.replace("str=","");

        if (req === "404"){
            req_status=404;
        }
        reqsize = req.length;
        note = "test";

        if (reqsize < 10){
            note="small";
        }else{
            note="big";
        }
    }

    return {
    headers: {
        "content-type": "application/json",
        "content-length": "44",
        "server": "Werkzeug/0.9.6 Python/3.4.0",
        "date": "Tue, 07 Apr 2015 15:01:57 GMT",
        "connection": "close"
    },
    statusCode: req_status,
    body: JSON.stringify({
        nb_char: reqsize,
        weight: note,
        state: state.requests
    }),
    _mode: "text"
    };
}

mountebank extensions

tl;dr
A hypothetical extension for mountebank could supply over the wire Equivalence Sets for primary data types (String, Number, Boolean) and composite data types (Object, Array).

Motivation

Test Doubles (Mocks, Spies, Stubs, etc) often play an important role in test robustness – another concept in test robustness is the Equivalence Classes (or Equivalence Sets).

Pareto principle

Imagine, for example, a SUT that accepts a direct input value and if the input value is > 1 and < 100 the expected value is always equal to actual result value.

In this example, any number from the Equivalence Set [1 .. 100] is guaranteed to exercise the same path of the code thus making the test more robust.

In AutoFixture we have generalized this approach by the 80–20 rule:

In most mainstream scenarios, numbers of the Equivalence Set [1 .. 255] tend to exercise the same path in the code.

In practise

The same way we create an imposter – we could ask a mountebank extension to create a fixture and transmit values for requested data types drained from an Equivalence Set over the wire.

A good collection of Equivalence Sets for primary data types (String, Number, Boolean) gives the ability to create composite data types (Object, Array).

Example

One could request the following JSON Schema from a mountebank extension:

{
    "name": "Product",
    "properties": {
        "id": {
            "type": "number",
            "description": "Product identifier",
            "required": true
        },
        "name": {
            "type": "string",
            "description": "Name of the product",
            "required": true
        },
        "price": {
            "type": "number",
            "minimum": 0,
            "required": true
        },
       "datetime": {
            "type": "date"
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "stock": {
            "type": "object",
            "properties": {
                "warehouse": {
                    "type": "number"
                },
                "retail": {
                    "type": "number"
                }
            }
        }
    }
}

And the mountebank extension would respond with a JSON generalized by the 80–20 rule:

{
    "id": 50,
    "name": "89071263-eeb2-4a1d-84bf-31c760360bc9",
    "price": 123,
    "datetime": "2014-05-10T00:18:40.055Z" 
    "tags": [ "Bar-89071263-eeb2", "Eek-89071263-eeb2" ],
    "stock": {
        "warehouse": 300,
        "retail": 20
    }
}

It should be also possible to create custom Equivalence Sets (via HTTP) by specifying the Boundary Values in the JSON string.

Benefits

Mountebank could eventually become the de facto, truly cross-platform, tool around test robustness, capable of creating Test Doubles, and also Fixtures via extensions using Equivalence Sets generalized by the 80–20 rule.

References


If this hypothetical mountebank extension falls into a direction you would like to take, please let me know. I may work on it, in my spare time, and I may open a pull request sometime.

Transmission error is logged to console output after deleting SMTP imposter

I issue a DELETE request to an SMTP imposter:

DELETE http://192.168.1.3:2525/imposters/4547 HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: 192.168.1.3:2525
Accept-Encoding: gzip, deflate

The result is HTTP/1.1 200 OK:

HTTP/1.1 200 OK
content-type: application/json
content-length: 550
Date: Tue, 22 Apr 2014 11:22:06 GMT
Connection: keep-alive

{
    "protocol": "smtp",
    "port": 4547,
    "requests": [
        {
            "requestFrom": "192.168.1.4",
            "envelopeFrom": "[email protected]",
            "envelopeTo": [
                "[email protected]"
            ],
            "from": {
                "address": "[email protected]",
                "name": ""
            },
            "to": [
                {
                    "address": "[email protected]",
                    "name": ""
                }
            ],
            "cc": [],
            "bcc": [],
            "subject": "Thank you for your order!",
            "priority": "normal",
            "references": [],
            "inReplyTo": [],
            "text": "Hello Customer, Thank you for your order from .\n",
            "html": "",
            "attachments": []
        }
    ],
    "stubs": [],
    "_links": {
        "self": {
            "href": "http://192.168.1.3:2525/imposters/4547"
        }
    }
}

Additionally, the following error is logged to the console output:

error: [smtp:4547] 192.168.1.4:59540 transmission error X=> 
{"code":"ECONNRESET","errno":"ECONNRESET","syscall":"read"}

image

I tested this with mountebank 1.0.371 and 1.0.376.

Support custom keystore for https

Currently, mountebank always uses a self-signed certificate bundled with the application. Support command line parameters that allow the key and cert to be parameterized in httpsServer.js.

Add HTTP attachment support

The http request and response objects do not currently support any notion of attachments, which makes recording attachments for mocking and returning them for stubbing not possible.

Issue with Injection in Predicate

Hi

I am unable to inject any Javascript function inside the predicates of one of the stub.
In the request i have asked to match the Query under PredicateGenerators.

The function which i have written is very simple
"predicates": [
{
{ "deepEquals":
{
"query":
{"inject": "function(logger)
{logger.info('Inside injection';)}"
}}}
}
I am not able to see any information on logs.
I have allowed Injection on mountebank startup by
mb --allowInjection.

Can anyone suggest anything ? Or if any changes has to be made ?

Better support for replaying proxyAlways proxies

Right now when you use proxyAlways, it's up to you to remove the proxy in front of the saved responses before replaying. I'd like a way for the user to have mountebank do that for them. I think the following makes sense:

Add ?removeProxies=true to GET /imposters and GET /imposters/3000, which works in conjunction with ?replayable=true. This would remove all proxy responses from the responses array from the returned representation.

Add SMTP stubbing behavior

Right now, SMTP only supports mocking/spying. It could be more consistent with the other protocols by allowing some measure of stubbing. At the very least:

{
  accept: true
}

to signify the server accepting / rejecting the email.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.