fabric8io / mockwebserver

An extension of okhttp's mockwebserver, that provides a DSL and is easier to use
Apache License 2.0
113 stars 38 forks source link

Describing multiple expectations (header and path) #55

Closed ginkel closed 3 years ago

ginkel commented 3 years ago

This is more of a question rather than an issue:

I'm trying to express an expectation that that comprises a path and a header, such as in:

    mockServer
        .expect()
        .withPath("/foo?arg=value")
        .withHeader("Authorization", "bearer ...")

Unfortunately, path and header can't seem to be combined -- withPath returns a Pathable, which does not expose withHeader.

Is there any way to combine both expectations that I may have missed?

ginkel commented 3 years ago

I sorted out the issue by using takeRequest to validate that the expected headers were sent.