divmain / drydock Goto Github PK
View Code? Open in Web Editor NEWA stateful, configurable mock server built for predictable end-to-end testing and offline UI development.
License: MIT License
A stateful, configurable mock server built for predictable end-to-end testing and offline UI development.
License: MIT License
Is there a reason for why Drydock does not support case insensitive routes? Would you be open to add support for case insensitive routes?
We are using Drydock for one of our testing strategies and are very happy with it. Adding support for case insensitive routes is necessary for us, and we are already using a fork of the project where we can do so. However, we don't want to put ourselves in a situation where it's impossible to drop our fork and use the main version.
I'm attempting to mock an api that has endpoints with overlapping paths. For example one endpoint will have a path of "/a/b/c" and another will have a path of "a/b/c/d". When I try to run the drydock file I receive an error of "New route conflicts with existing". Is there a way around this, is this simply not supported by drydock, or is this a true issue?
We are attempting to start multiple instances of drydock in webdriverIO so that tests can be run in parallel and encountered an issue with hapi.
Since the port needs to be unique we attempted to use port scanning to find a free port and then start drydock, but since the tests run in parallel we encountered the race condition that the both processes selected the same free port, but one of the processes would still error with EADDRINUSE. I would have expected this error to be passed to the start callback, but appearantly there is a bug in hapi hapijs/hapi#2561.
This bug has already been fixed in latest hapi version, but is not in version 6.x used by drydock. I tried a simple update to package, but it appear the HAPI api has changed a bit.
Would you accept a PR that updates the HAPI version?
npmjs.org artifact states version 0.7.0 was published 2 months ago, with git head e4dbfdf14d41ecbc85535fdc52c0cf18c401b033 which is not the latest master updated 2 days ago.
Could you bump the to version 0.8.0 and republish?
Right now name only accepts [A-Za-z\-]
but I'm trying to use it with a customer ID which has 0-9
. Happy to PR this if you're interested.
drydock.jsonRoute({
name: "ABC0001",
method: "GET",
path: "/customers/ABC0001",
handlers: {
"success": {
description: "Return customer ABC0001",
handler: function () {
return require("./data/customers-ABC0001.json");
}
}
}
});
Define a route that will be automatically forwarded to an endpoint at a different URL. This can be used as a placeholder, where a route you intend to mock can still work (using the real service), or may be used indefinitely in some cases.
Can I use drydock to start and stop the frontend for my app for frontend testing or is that not advised?
In principle all that would have to be done is npm start and npm stop.
It would integrate nicely into something like boilerplate-nightwatch.
@Maciek416 @geekdave - looks like this isn't being used internally. Would you mind if I move this to a new location, so I can continue to maintain it for my own use?
Modifying the example slightly to use https
instead of http
fails:
import Drydock from 'drydock';
const drydock = new Drydock();
drydock.proxyRoute({
method: "GET",
path: "/google",
forwardTo: "https://www.google.com/"
});
drydock.start();
response:
{
statusCode: 500,
error: "Internal Server Error",
message: "An internal server error occurred"
}
console:
debug: hapi, internal, implementation, error
TypeError: Uncaught error: Cannot read property 'statusCode' of undefined
at Request._callback (/Users/pairing/projects/churro/taco/node_modules/drydock/lib/node/routes/instance.js:179:32)
at self.callback (/Users/pairing/projects/churro/taco/node_modules/request/request.js:200:22)
at emitOne (events.js:90:13)
at Request.emit (events.js:182:7)
at Request.onRequestError (/Users/pairing/projects/churro/taco/node_modules/request/request.js:831:8)
at emitOne (events.js:90:13)
at ClientRequest.emit (events.js:182:7)
at TLSSocket.socketErrorListener (_http_client.js:306:9)
at emitOne (events.js:90:13)
at TLSSocket.emit (events.js:182:7)
at emitErrorNT (net.js:1249:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
The root cause gets swallowed by checking statusCode in the callback before checking the err, but quick hack to add console.log around the err we find the root cause is actually:
Error: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:www.google.com"]
reason: 'Host: localhost. is not in the cert\'s altnames: DNS:www.google.com'
This is a result of also forwarding the "Host: " header.
We found if we delete host.header
or set it explicitly the request succeeds.
Anything we are missing here? Should we determine host from the forwardTo?
If a URL is requested that is not defined as a mock route (or the control panel route), forward that request along to the intended endpoint. This assumes that the client has been configured to use the mock IP and port as a proxy.
It would be useful to proxy an entire url prefix to another server.
drydock.proxyRoute({
method: "GET",
path: "/something/*",
forwardTo: "https:/host/something/"
});
I think we need to currently proxy each route explicitly.
A path currently can only contain regex(/^[A-Za-z\-\/\_\{\}]+$/)
but a URl can contain any valid unicode character including emoji. Practically speaking this prevents the use of User or Product IDs in a resource name which would be common for a RESTful API.
Happy to PR this if you are interested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.