Save value from request to send back as a response for another request?

347 views
Skip to first unread message

phuong...@gmail.com

unread,
Dec 29, 2017, 12:51:26 PM12/29/17
to mountebank-discuss
Hi,

This is a scenario for my test:

1. Send PUT request to mountebank with a request-id. The imposter should return 200 success but saves value of the request-id.
2. Later, send a GET request to mountebank and expects the request-id to be returned

As I don't know the request-id beforehand, I cannot create a data file so that mountebank can read (From step 2).

I tried to search for answer but I am not able to find any way to do that. Is it possible to do that in mountebank?

Thanks,

Phuong

Brandon Byars

unread,
Dec 29, 2017, 8:23:37 PM12/29/17
to phuong...@gmail.com, mountebank-discuss
Hi,
As it stands now, there are only two ways to maintain dynamic state across requests.

1. Use response injection. The second parameter is a state variable that is initially an empty object. Anything you set on that object will be persisted across requests to the same imposter.
2. Use a shellTransform behavior. It's typical use is post-processing middleware on responses, but as it shells out, you are free to use whatever persistence mechanism you want.

-Brandon



--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

phuong...@gmail.com

unread,
Jan 2, 2018, 2:50:38 PM1/2/18
to mountebank-discuss
Response injection indeed helped me to solve my issue.

Thanks,

Phuong

> To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages