Giter Club home page Giter Club logo

stub-http's Introduction

Hi!

I’ve been interested in software development for as long as I can remember. I strongly believe that understanding the business is a must to make correct trade-offs and writing good software, which is why I also have a big interest in domain-driven design and software architeture. Speaking of code, I would mainly consider myself a backend developer who doesn’t shy away from the frontend if need be.

I'm into open-source and have created several popular libraries for the JVM platform (for example Occurrent, PowerMock, Rest Assured and Awaitility). I like learning new things and I have experience in different languages such as Java, Kotlin, Clojure, Scala, and Groovy.

Frequent speaker at user groups, companies and conferences such as Öredev, Jazoon, Devoxx, and JFokus.

Besides software, I’m also intrigued by philosophy, cognition, mathematics, and science in general.

📫 You can reach me at Twitter and LinkedIn.

stub-http's People

Contributors

abeltramo avatar conormcd avatar johanhaleby avatar jonassvalin avatar opqdonut avatar ricardoekm avatar roberttaylor426 avatar tfager avatar xelnaga 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

Watchers

 avatar  avatar  avatar

stub-http's Issues

Request matching doesn't check body

(with-routes! 
  {{:path "/y" :content-type "application/json" :body (json/generate-string {:q "something"})}
   {:status 200 :content-type "application/json"
    :body (json/generate-string {:hello "brave new world"})}}
  (clj-http.client/get (str uri "/y") {:body (json/generate-string {:q "something else"})}))

This works when I wouldn't expect it to. That also make is impossible to have several routes that have the same path but different request bodies without error. I realize that it's not standard to do GET with a body, but some APIs (e.g. Elasticsearch) work that way. Besides, it doesn't make a difference if I use POST.

Is it possible to add a delay in the response?

We'd like to test some timeout and resilience scenarios. Is it possible to add a delay in the request response?

Usually testing this kind of scenario is only possible using mocks/stubs.

Body match always fails with PUT request

Setting up a route for a PUT request with a body will always fail to match the body.

This is because the PUT body data is keyed on the request with "content" and not "postData".

Line 34 of stub-http.internal.spec needs to use the method to determine the correct key.

NullPointerException when stubbing endpoint with no body

Hi,

Thanks for the great library!

Having updated to version 0.2.13 from 0.2.12 I'm now seeing an NPE when stubbing a server that only returns status 500, with no body specified. For example:

(stub/start! {{:method :post :path "/api/foo"} {:status 500}})

yields:

java.lang.NullPointerException
at stub_http.internal.server$create_response.invokeStatic(server.clj:42)
at stub_http.internal.server$create_response.invoke(server.clj:24)
at stub_http.internal.server$new_server_BANG_$fn__38653.invoke(server.clj:106)
at stub_http.internal.server.proxy$fi.iki.elonen.NanoHTTPD$ff19274a.serve(Unknown Source)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Thread.java:750)

If I provide an empty body, there is no exception. Is specifying a body now mandatory?

Thanks!

Request with PATCH method do not include the body in the request structure.

When stubbing a PATCH method request the stub-request returned from the nano server has no body.
This means tests that rely on the body for generating a response for PATCH request cannot be written.

e.g.

(with-open [server (start! {{:path "/mypath" :method :patch} 
                                             (fn [request] 
                                               {:status 200
                                                ;; the request has a nil body
                                                :body (:body request)})})]
...
)

Headers in response spec not added as expected

(with-routes! 
  {"/something" {:status       200
                 :content-type "application/json"
                 :headers      {"Some Header" "some value"}}}
  (clj-http.client/get (str uri "/something")))

Unlike when content-type is set, the headers that are set aren't available in the response.

{:request-time 201,
 :repeatable? false,
 :protocol-version {:name HTTP, :major 1, :minor 1},
 :streaming? true,
 :chunked? true,
 :reason-phrase OK,
 :headers {Content-Type text/html, Connection close, Transfer-Encoding chunked},
 :orig-content-encoding nil,
 :status 200,
 :length -1,
 :body ,
 :trace-redirects []}

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.