Middleware in capture mode

40 views
Skip to first unread message

Alex Soto

unread,
Jan 23, 2018, 8:00:09 AM1/23/18
to hoverfly

Hi, I am trying to capture some real data (hoverfly capture mode) and when I receive it then encrypts some sensible data.

My code looks like:

def main():
    payload = sys.stdin.readlines()[0]
    logging.debug(payload)
    try:
        token = payload_dict['data']['pairs'][0]['request']['headers']['Authorization'][0]
        logging.debug("token %s" % (token))
   .......

The problem is that the body of the payload is empty, but for example, running curl --proxy http://localhost:8500 http://localhost:8080/cart  prints the real output, so what I see is that what I am intercepting is the request but not the response. How can I do that?

Thanks.

Tommy Situ

unread,
Jan 23, 2018, 8:32:24 AM1/23/18
to Alex Soto, hoverfly
Hi Alex, 

That’s a good question. I think you need MODIFY mode to intercept both request and response, see this diagram: http://hoverfly.readthedocs.io/en/latest/pages/keyconcepts/modes/modify.html

In CAPTURE mode, it only intercepts the request according to here: http://hoverfly.readthedocs.io/en/latest/pages/keyconcepts/middleware.html

I need to find out why CAPTURE can’t intercept the response which is useful for your scenario


Thanks,
Tommy


--
You received this message because you are subscribed to the Google Groups "hoverfly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoverfly+u...@specto.io.
To post to this group, send email to hove...@specto.io.
To view this discussion on the web visit https://groups.google.com/a/specto.io/d/msgid/hoverfly/cc8db3b3-0f47-43fe-96a6-27616853fd23%40specto.io.

Alex Soto

unread,
Jan 26, 2018, 5:56:46 AM1/26/18
to hoverfly, aso...@gmail.com
So, now we are wondering how is the best way to achieve next scenario.

We want to mask some sensitive data, so when we are in capture mode, the sensitive data from request and response can be stored as simulations masked.

So the idea is that when we run the tests in the simulate mode the data retrieved that is stored contains masked fields. In this way, we are able to share this simulation to other people or even push in github.

The problem we are facing is that to do this we need to start hoverfly in MODIFY mode, and reading docs says that in MODIFY mode the requests and the responses are not stored, so it means that in the simulate mode we get no data.

So what is the best way to proceed in this case?



El dimarts, 23 gener de 2018 14:32:24 UTC+1, Tommy Situ va escriure:
Reply all
Reply to author
Forward
0 new messages