Giter Site home page Giter Site logo

matthewgallina / smockin Goto Github PK

View Code? Open in Web Editor NEW
82.0 10.0 24.0 11.92 MB

Dynamic API, S3 & Mail mocking for web, mobile & microservice development.

Home Page: https://www.smockin.com

License: Apache License 2.0

Shell 0.55% Batchfile 0.27% Java 49.56% CSS 1.83% HTML 8.75% JavaScript 38.92% RAML 0.09% Dockerfile 0.04%
api raml api-mocking api-rest mock-server mocking java-8 simulation api-simulation api-mock

smockin's Issues

Create rule with input data (json)

Hi All,

I created an HTTP Endpoint with some rule conditions and it´s working.

image

image

But if I have 2 arrays in my request and added it to the rule conditions, it doesn't work.

This is my request:

{
"partyadddata": {
"attribute": [{
"name": "servtype",
"value": "99"
}, {
"name": "authcode",
"value": "AAA"
}
]
},
"source": {
"name": "Pedro",
"lastname": "Yepes",
"age": "35"
}
}

This is my rule conditions:
image

image

Thank you very much for your help!

Unable to use live trace in Docker

I'm using Smockin inside a Kubernetes environment. Traffic is routed via Traefik to the docker container.

Everything works perfectly, but I'm having issues enabling the HTTP live feed.
After checking the chrome DevTools it seems that after opening the Live Feed panel Smockin tries to open a connection to: http://localhost:8000/liveLoggingFeed .
I'm assuming this is due to https://github.com/mgtechsoftware/smockin/blob/master/src/main/resources/public/js/controller/view_http_requests.js#L172

Since hostname and port should be the same as the ones where the UI is served, may we be able to retrieve them dynamically?

Deployment in kubernetes with nginx ingress controller

Hello,

Smockin is great and works perfectly locally in our dev stack :)

I've deployed smockin in a kubernetes cluster for my frontend dev team to be able to use it without having to manage it locally.

It mostly works but we've hit a limitation : HTTP live feed (and new response interception feature) does not work.

Probable cause is that admin interface and api are reachable on 2 separated domains on standard 443 HTTPS port. This is mandatory when using default kubernetes nginx ingress controller : we can only expose 80 & 443 ports.

Could Smockin be updated to allow such a setup ?
Or maybe is such a setup already possible with some config step or workaround ?

Use a local server address

Hello,

Is it possible to configure the Mock server for a local address only (in 127.x.x.x), to avoid to expose Mock on network ?

Thanks,

CLI REST API

Hi!
I want to do automated backups of our mock data.
In my opinion the simplest method would be to have an endpoint that downloads all data.
I've seen that there already is an POST endpoint that we could maybe use, but it requires the request ids.

Is there such a mechanism already in place, or a simple way of getting all the data?
(via a curl call, I'm fine with downloading the database as well)

Responding to Websocket onconnect and onmessage methods

The product is really good for REST calls. I am now trying to respond to Websocket messages and connection events.

Is there a way to mock a response from the server when a client connects to the websocket?
Similarly, how would I add mocked responses for a given websocket request?

Is there a way to generate server push events?

Thanks!

Dan

Post body issues with the use of Custom JavaScript option

We are currently using the a docker images the latest one as per the documentation here: https://hub.docker.com/r/mgallina/smockin

We are running the following this commands to boot up the server.

1. Run docker run --name smockin -d -p 8000:8000 -p 8001:8001 mgallina/smockin:290
2. Open the sMockin dashboard http://localhost:8000/index.html

We are using the Javascript based mocking option to create/configure the post endpoint and tried hitting that passing in a json body but we see the following.

ERROR

Looks like there is an issue with the Javascript driving this mock <eval>:1:161 Missing close quote

var request = {  path : null, pathVars : {}, body : null, headers : {}, parameters : {}};request.path='/money-movement/rtp/v1/credit-transfers'; request.body='{

                                                                                                                                                                 ^ in <eval> at line number 1 at column number 161

Not sure if we are missing something here?

Stay on Endpoint details after save

When using sMockin, I often need to change data in the same endpoint multiple times.
At the moment the process is:

  1. Change data
  2. Hit save
  3. Search for the endpoint in the list
  4. Change data again

This is kind of time consuming.

It would be nice to stay on the endpoint details after clicking on save. Maybe you could just change the current save button to stay on the page or add another button "Save & Exit".

Thanks for your help

Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor

Hi Matt,

I just got an erro like this,

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project smockin: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x81368c9) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x81368c9 -> [Help 1]

Any idea?

Record and replay feature

  • Record and replay will be the interesting feature for integration testing phase
  • If we have a feature to set up a mock by proxying the real request and responses and later redo the integration testing using smockin

Copy endpoint

Sometimes we need to have a copy of an endpoint and change only a few things (e.g. the path).
At the moment we export the endpoint, make the changes in the json, and import it again.

It would be nice to have a "Copy endpoint" option, which will open the create endpoint page prefilled with the existing data. There we can make our changes and have an easy was for copying endpoints.

Vulnerable docker container due to obselete debian:jessie base image

Hi Matthew,

I did a scan of the docker image for smockin:240. My scanner found hundreds of vulnerabilities.

You have not shared the Dockerfile for the image, so it's a bit more guess work for me to remediate this problem.

Could you share your Dockerfile with me (or in Github) so that we could generate a more secure one, please?

Thanks!

Dan

FileNotFoundException

Hi,
smockin version [2201] running on windows server 2022,
java version "11.0.20" 2023-07-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.20+9-LTS-256)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.20+9-LTS-256, mixed mode)
Http endpoint with javascrip logic parse XML:
image
Everything is working fine, but smockin on all requests, write this exception to the log:
2023-12-19 13:03:20,673 ERROR [qtp1355973015-102] com.smockin.mockserver.service.JavaScriptResponseHandlerImpl : Error loading JS extensions java.io.FileNotFoundException: file:\C:\WEB\smockin-2.20.1.sa.win-x64\lib\smockin-2.20.1.jar!\BOOT-INF\classes!\js-extensions\from-xml.min.js (The filename, directory name, or volume label syntax is incorrect) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:219) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157) at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112) at java.base/java.io.FileReader.<init>(FileReader.java:60) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl.loadEngineExtensions(JavaScriptResponseHandlerImpl.java:312) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl.buildEngine(JavaScriptResponseHandlerImpl.java:302) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl.executeJS(JavaScriptResponseHandlerImpl.java:89) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl.executeUserResponse(JavaScriptResponseHandlerImpl.java:55) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl$$FastClassBySpringCGLIB$$53a8bb1b.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at com.smockin.mockserver.service.JavaScriptResponseHandlerImpl$$EnhancerBySpringCGLIB$$a06d86e.executeUserResponse(<generated>) at com.smockin.mockserver.engine.MockedRestServerEngineUtils.processRequest(MockedRestServerEngineUtils.java:346) at com.smockin.mockserver.engine.MockedRestServerEngineUtils.handleMockLookup(MockedRestServerEngineUtils.java:143) at com.smockin.mockserver.engine.MockedRestServerEngineUtils.loadMockedResponse(MockedRestServerEngineUtils.java:93) at com.smockin.mockserver.engine.MockedRestServerEngineUtils$$FastClassBySpringCGLIB$$932885eb.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at com.smockin.mockserver.engine.MockedRestServerEngineUtils$$EnhancerBySpringCGLIB$$98137ade.loadMockedResponse(<generated>) at com.smockin.mockserver.engine.MockedRestServerEngine.processResponse(MockedRestServerEngine.java:333) at com.smockin.mockserver.engine.MockedRestServerEngine.lambda$buildGlobalHttpEndpointsHandler$6(MockedRestServerEngine.java:277) at spark.RouteImpl$1.handle(RouteImpl.java:72) at spark.http.matching.Routes.execute(Routes.java:61) at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:134) at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1598) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) at org.eclipse.jetty.server.Server.handle(Server.java:516) at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:137) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) at java.base/java.lang.Thread.run(Thread.java:834)

File location is OK:
image
and also js location is ok
image

Error when try to update proxy config

when I try to update proxy config, then the interface shows the message: "Oops looks like something went wrong!" and the servers throw an "NullPointerException".
I'm on Ubuntu 22.04.2 LTS, running smockin on docker version 2201
I tried the version 2200 and 2190, but both throw the same error

image

2023-07-24 17:17:12,554 ERROR com.smockin.admin.controller.ExceptionHandlerController : Error
java.lang.NullPointerException: null
        at com.smockin.mockserver.engine.ProxyMappingCache.lambda$update$3(ProxyMappingCache.java:44)
        at java.base/java.util.concurrent.atomic.AtomicReference.getAndUpdate(Unknown Source)
        at com.smockin.mockserver.engine.ProxyMappingCache.update(ProxyMappingCache.java:41)
        at com.smockin.admin.service.MockedServerEngineServiceImpl.saveProxyForwardMappingsForUser(MockedServerEngineServiceImpl.java:505)
        at com.smockin.admin.service.MockedServerEngineServiceImpl$$FastClassBySpringCGLIB$$b636bd76.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
        at com.smockin.admin.service.MockedServerEngineServiceImpl$$EnhancerBySpringCGLIB$$698c5257.saveProxyForwardMappingsForUser(<generated>)
        at com.smockin.admin.controller.MockedServerEngineController.postServerConfigUserProxyMappings(MockedServerEngineController.java:231)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:517)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:584)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
        at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1656)
        at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:292)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
        at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
        at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1626)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:516)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
        at java.base/java.lang.Thread.run(Unknown Source)

Deployment in kubernetes with nginx ingress controller

Good Evening, I'm trying to configure smockin behind nginx-ingress in a kubernets cluster and it works fine, but when I activate the MULTI_USER_MODE variable to TRUE I can no longer access due to authentication activation, can you tell me which annotations I can use in my nginx-ingress on kubernetes.?

Thanks

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.