Giter Site home page Giter Site logo

clafonta / mockey Goto Github PK

View Code? Open in Web Editor NEW
116.0 18.0 39.0 58.91 MB

Mockey is a tool for testing application interactions over http, with a focus on testing web services, specifically web or native applications that consume XML, JSON, and HTML. Mockey's purpose is to be a simple front end to writing mock-test-responses to the file system for persistence to git.

Java 63.61% CSS 2.81% HTML 1.08% JavaScript 32.50%
java testing-tools jetty mock-server

mockey's Introduction

README

Image of Mockey

What is Mockey?

A testing tool, used to mock end point web services for the purpose of testing web service client applications.

Features

  • Use Mockey as a proxy to a real service, to inspect request and response messages
  • Set up Mockey to go through a corporate proxy server, to reach an endpoint web service
  • Support for HTTP/s interactions (even if your corporate proxy server has https as an endpoint web service)
  • Ability to 'play back' conversations for when endpoint services are not available
  • Ability to run EVERYTHING in a sandbox - your application and the endpoint webservices your application is consuming.

What is Mockey not good at?

  • Large payloads used in conversations, e.g. 10MB per message
  • Transport protocols other than HTTP, e.g. FTP.
  • Complicated conversations e.g. if X, then call this database, else if Y, call 'rake FOO', else kick-off-Maven.
  • Solving everything

Getting Started - Quick

Pre-built jars are located here: https://github.com/clafonta/Mockey/wiki/Downloads

To start:

java -jar Mockey.jar

Mockey.jar is an executable jar file, which will start Mockey within a Jetty container and fire up your browser pointing at the defaults (port 8080, /home). You may need to 'click' refresh on your Browser to see the home page.

To build one locally, you'll need Ant and then do the following:

cd MOCKEY_HOME // root directory of where you checked out Mockey.

ant dist

After a successful build, do the following to start the app:

cd dist

java -jar Mockey.jar

For startup options:

java -jar Mockey.jar --help

For those who prefer to run Mockey in a Tomcat instance, you'll need to build the app:

ant webapptomcat

This will build a WAR file, which you can drop into Tomcat and run. You can set the location of Mockey definition file repot as follows:

export JAVA_OPTS="-DmockeyDefinitionsRepoHome=/Users/your-username/some-directory"

When Mockey starts up in Tomcat, it will look for the 'mockeyDefinitionsRepoHome' property and read write needed files in that directory. If not defined, it will read write files in the default user directory that Tomcat is started with.

mockey's People

Contributors

agherardi avatar cah-mohanrao avatar clafonta avatar gga avatar lkb2k avatar neilcronin avatar robfromca 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

mockey's Issues

CSS - Laborious

Move your laborious CSS into it's own directory, and anything custom goes into a custom directory, so you don't have to repeat CSS changes per laborious project.

Don't hide tags

Remove the show/hide tags - keep tags always displayed which means, information is always "in your face", encouraging users to keep things clean.

Support for other character encodings than ISO-8859-1 for responses

I need support for UTF-8 for my project. I'm hacking around it by the doing the following (not sure all of this is needed):

I needed to return utf-8 json response so I hacked together the following fix. I'm sure there is probably a better way to do this and this may not solve updating a utf-8 response via the UI (header.js hardcodes the character encoding so it will probably mess up UTF-8 responses when displaying and updating responses).

Also the code for detecting the charset and extracting formt he content-type header could probably be a little more robust I guess.

  1. creating an XML service import file with content-type set to application/json;charset=utf-8
  2. adding application/json;charset=utf-8 to the setup_service.jsp's options.
  3. adding code to the ResponseServlet.java to check for charset set on the content-type and if it is there attempting to use it instead(code inserted around line 110):
            //check content type for charset and try to use that if its there...
    //example: application/json;charset=utf-8
    //should use the charset "utf-8"
    String charSet=HTTP.ISO_8859_1;

    try {
        if(service.getHttpContentType()!=null) {
            final String contentTypeUpper=service.getHttpContentType().toLowerCase();
            int charsetIndex=contentTypeUpper.indexOf("charset=");

            if(charsetIndex>=0) {
                charSet=contentTypeUpper.substring(charsetIndex+"charset=".length());

                //make sure it is a valid charset
                Charset.forName(charSet);
            }
        }
    } catch(Exception e) { 
        charSet=HTTP.ISO_8859_1;
    }

    resp.setCharacterEncoding(charSet); // "UTF-8");
    resp.setContentType(service.getHttpContentType());
    if (!(service.getServiceResponseType() == Service.SERVICE_RESPONSE_TYPE_PROXY)) {
        resp.setContentType(service.getHttpContentType());
        byte[] myCharSetBytes = response.getBody().getBytes(charSet);
        new PrintStream(resp.getOutputStream()).write(myCharSetBytes);
        resp.getOutputStream().flush();
    } else {
        resp.setStatus(response.getStatusLine().getStatusCode());
        response.writeToOutput(resp);
    }

cannot proxy to service over SSL with self-signed cert

Proxying to a service using SSL with a self-signed certificate results in an error: "Proxy settings are NOT ENABLED". That's misleading, given that proxying a service and using an HTTP proxy for outbound requests are unrelated. The actual error is an SSLPeerUnverifiedException, thrown from httpclient.execute() in ClientExecuteProxy. Unfortunately, that gets caught and Mockey reports a problem with the proxy configuration. The SSL error is logged, but it's easily missed...

At minimum I'd like to see the problem surfaced in the service history (rather than mis-diagnosed as a problem with the HTTP proxy config). Better yet would be a way to allow self-signed certs, as Mockey is currently unusable in this situation (and I don't have control over the remote service to either allow HTTP requests or replace the self-signed cert).

Figure out how to pass the xml file on the command line

This would be pretty hard, but if we could figure out how to pass the mockey file we want to load on the command line, that would be really cool. Then you could just save off different scenarios as different xml files and then start up mockey with the pre-configured set you want.

Post an API

Next to or within the Help section, post the API and 'how-tos' to configure Mockey from outside the browser. Here's a story:
Need: have ant make an http request and set a Service Plan
Problem: what http request does Ant make to ensure "Gold Member" settings are set?

Creating a Scenario from Service History request fails in Firefox 4

Javascript object names are incorrect on lines 170 and 171 of web\WEB-INF\common\inc_scenario_create_dialog.jsp.

old lines read:
responseMessage: responsemsg.val(), universalErrorScenario: universalerrorscenario.val(),
errorScenario: errorscenario.val() } ,function(data){

lines with fixed object names:
responseMessage: responsemsg.val(), universalErrorScenario: universal_error_scenario.val(),
errorScenario: error_scenario.val() } ,function(data){

Move Proxy On/Off indicator

Appending On/Off indicator to the Proxy menu name is flaky - it makes the menu do weird things. Maybe, try floating in absolute position over the Proxy menu item?

Make service urls replaceable/tuneable somehow....

Service urls are usually environment specific, example:

https://qa1.test.com/veryspecialservice
https://qa2.test.com/veryspecialservice
...

To point mockey at that service, you'd use a URL like this:

https://mockeyserver:8080/service/https://qa1.test.com/veryspecialservice

But then if you record a bunch of interesting responses that you want to share, they are all pointing at qa1. When it comes time to test against qa2, new services are generated and the old responses aren't copied.

It should be possible to switch the "real" urls that a group of services point to without disturbing the service matching that is done.

history page - toggle text.

When "view" is clicked, toggle text to "hide". Don't always show both. Same with "tag". Don't we need an "untag"? Chad is lazy.

Bug with port handling in com.mockey.model.Url

Services are having colons replaced with semicolons fix below seems to work fine (assuming that the issue is caused by a typo):

public static String getSchemeHostPortPathFromURL(String validUrl) throws MalformedURLException {
    URL aURL = new URL(validUrl);
    String port = "";
    if(aURL.getPort() > -1){
        //port = ";"+aURL.getPort();
        port = ":"+aURL.getPort();
    }
    String schemeHostPortPath = aURL.getProtocol() + "://" + aURL.getHost() + port + aURL.getPath();
    return schemeHostPortPath;
}

Set-Plan via History view

Within the history view, you should be able to set a Plan based on a history path. Save each Response to each Service as a Scenario.

Search is broken. Fix it!

On the home page, searching for a service and/or scenario leads to a result set with broken links. It sometimes works - make sure you're escaping HTML characters.

Consolidate modal dialogs.

Mockey uses two types of modal dialogs: JQI and JQueryUI. We like the JQueryUI and get rid of JQI. This work is related to CSS - Laborious

When acting as a proxy, mockey return proxied service's status code

Really, I'd like to see it return all of the headers and cookies too and be able to setup services / scenarios that let me copy these values from the service history, but all I'm suggesting be fixed in the short term is that the http status code of the proxied service be passed to client instead of always returning 200 OK.

Proposed fix in com.mockey.server.ResponseServlet (line 115) add line:

resp.setStatus(response.getStatusLine().getStatusCode());

else branch now reads:

           else {
        resp.setStatus(response.getStatusLine().getStatusCode());
        response.writeToOutput(resp);
    }

thanks.

Handle a 15 MB message

Yes, the server is returning large payloads and Mockey can't manage this all in an XML. What to do? Some ideas: if the message payload is too large, then write to the file system but keep META in the service-definitions.xml.

What about viewing history? Mockey's History Servlet/Service should be able to break it down, like 'tail'.

Documentation needed

Add a new documentation section for the service API that accepts query parameters and responds with JSON.

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.