Disable follow redirect in Karate BDD framework?

896 Views Asked by At

I have a part of my application flow that reuses an old login service. This old login service uses a 302 redirect with a Location header that includes a query param I have to capture and use as an auth code.

Right now, the Karate framework is helpfully forwarding me to the location specified in the Location header. How can I disable this so that instead I can capture the values myself?

09:39:26.096 [main] DEBUG com.intuit.karate -
2 < 302
2 < Connection: keep-alive
2 < Content-Length: 0
2 < Content-Type: application/json;charset=ISO-8859-1
2 < Date: Fri, 08 Sep 2017 15:39:25 GMT
2 < Server: nginx/1.4.6 (Ubuntu)
2 < Set-Cookie: [JSESSIONID=0000UDF76JJ7ZGsFlTs9FPYcVoN:1bj4v930o; Path=/; HttpOnly, PD-S-SESSION-ID=1_2_1_upREX6Zqm0NTxJ5dNQeSyVeaiUFYnO1OdgUVYXYnekLFY-A7; Path=/; Secure; HttpOnly, PD-ID=ZugwEuE0PZmTNhZkIlog5FqfvlDKD2nfvKAZ+ebfTvVx2dzw0JAgyOMeviZx3xsxYndwQxGmURx6n32fscUXMw3X8P9FpNDssgIz355kfTeda/25qxPf+uaEvs8JpE2FxsMWkzQ25qM2KmrhAK9QTRu31oflpD6eL+klFfDahSSTQlFMXZmB4Yjsc8DOnoGAhbv19Yh9A8OuzDFXimwML2a+Yn9UYN/ZjRXF45veNQGsA9/dtP/nfZl6eAPyy7mdSKunhHuWggBtYFP9kAgmB1LJ87MFWsOhZEwcnmLsJM078tRStGLeOFo7KX+1FtMhhcV76UkTxDFj1VR68fSPdzF+84oeyxf0WhQ0UZB+oc76kQtl94B7uW4X/lp9jADlGUwrE8hPQ5asPcPblt6E0yPyi+TvouK/0XHpy7QfAeXZqyifs+yeUOKHBdHUXHI7QhnadEX0GViHPsqZ5amztnYkF5mMQLkdXYIO22oSHCtci7M08gr1usTLrHc/hIBm; Path=/; Secure; HttpOnly, BigIPWebSeal=rd3o00000000000000000000ffff0a1bf852o443; path=/]
2 < X-Application-Context: sv:dev:8080
2 < X-B3-Sampled: 1
2 < X-B3-SpanId: 3229b43a709ac873
2 < X-B3-TraceId: 3229b43a709ac873
2 < X-Backside-Transport: OK OK
2 < X-Client-IP: x.x.x.x
2 < X-Global-Transaction-ID: 1890531591
2 < cache-control: no-cache="set-cookie, set-cookie2"
2 < content-language: en-US
2 < expires: Thu, 01 Dec 1994 16:00:00 GMT
2 < iis_server_name: APPA014D
2 < location: https://a-url.com/path?code=a51769a482e5
2 < p3p: CP="NON CUR OTPi OUR NOR UNI"
2 < strict-transport-security: max-age=31536000; includeSubDomains
2 < x-powered-by: Servlet/3.0
2 < x-xss-protection: 1;mode=block
1

There are 1 best solutions below

4
On BEST ANSWER

Wow, to be honest no-one has asked for this. Until now. Looks like we'll have to add this support: http://www.baeldung.com/httpclient-stop-follow-redirect

This can be implemented rather quickly, can you raise a feature request ? If this is a blocker, you could temporarily call into Java and use an instance of the Apache Http Client or something. I was wondering if you had the option to access a lastRedirectUrl instead would that have helped.

edit: this has been implemented in dev and will be available in version 0.6.0