I want to write some test against an REST endpoint which is using a callback parameter. Might sound confusing so here's an explanation:
first call is a POST to
/publish
with the payload:{"callbackURL":"http://localhost:609/test"}
server replies with 200 and some json
the server does an async POST to
http://localhost:609/test/status
(based on the provided callback URL), with some json payload
I built a test using TestNG and Rest-assured (not mandatory). My problem is how to validate both the initial reply and the message received at the callback URL.
A (maybe naive) approach I first thought of is to implement a HTTP server which listens at http://localhost:609/test/status
, when something comes it writes to a synchronized object from which the test reads and validates. However, sounds a bit tricky (the test local server will use an inner class, etc.) and fragile. Can anyone think of a better approach?