How to make DREDD follow a redirect?
I am trying to validate xkcd GET api in dredd?
actual:
statusCode: 301
headers:
server: Varnish
retry-after: 0
location: https://xkcd.com/info.0.json/
content-length: 0
accept-ranges: bytes
date: Mon, 11 Jun 2018 07:53:26 GMT
via: 1.1 varnish
connection: close
x-served-by: cache-ams4426-AMS
x-cache: HIT
x-cache-hits: 0
x-timer: S1528703606.197007,VS0,VE0
dredd emiyaml.yaml http://xkcd.com
$ dredd ( write your CLI options here )
No CLI options
dredd.yml?No dredd.yml
dredd --version output?dredd v5.1.9 (Darwin 17.6.0; x64)
dredd --level=debug uncover something?
verbose: Loading configuration file: ./dredd.yml
debug: Dredd version: 5.1.9
debug: Node.js version: v10.3.0
debug: Node.js environment: http_parser=2.8.0, node=10.3.0, v8=6.6.346.32-node.9, uv=1.20.3, zlib=1.2.11, ares=1.14.0, modules=64, nghttp2=1.29.0, napi=3, openssl=1.1.0h, icu=61.1, unicode=10.0, cldr=33.0, tz=2018c
debug: System version: Darwin 17.6.0 x64
debug: npm version: 6.1.0
debug: Configuration: {"server":"http://xkcd.com","options":{"_":["emiyaml.yaml"],"level":"debug","l":"debug","dry-run":null,"y":null,"hookfiles":null,"f":null,"language":"nodejs","a":"nodejs","sandbox":false,"b":false,"server":null,"g":null,"server-wait":3,"init":false,"i":false,"custom":{},"j":[],"names":false,"n":false,"only":[],"x":[],"reporter":[],"r":[],"output":[],"o":[],"header":[],"h":[],"sorted":false,"s":false,"user":null,"u":null,"inline-errors":false,"e":false,"details":false,"d":false,"method":[],"m":[],"color":true,"c":true,"timestamp":false,"t":false,"silent":false,"q":false,"path":["emiyaml.yaml","emiyaml.yaml"],"p":["emiyaml.yaml","emiyaml.yaml"],"hooks-worker-timeout":5000,"hooks-worker-connect-timeout":1500,"hooks-worker-connect-retry":500,"hooks-worker-after-connect-wait":100,"hooks-worker-term-timeout":5000,"hooks-worker-term-retry":500,"hooks-worker-handler-host":"127.0.0.1","hooks-worker-handler-port":61321,"config":"./dredd.yml","$0":"/usr/local/bin/dredd"},"custom":{"cwd":"/Users/ramakrishna.chilaka/Downloads","argv":["emiyaml.yaml","http://xkcd.com","--level=debug"]}}
verbose: Using 'base' reporter.
verbose: Configuring reporters: []
verbose: Using 'cli' reporter.
verbose: No backend server process specified, starting testing at once
verbose: Running Dredd instance.
verbose: Expanding glob patterns.
verbose: Reading API description files.
verbose: Parsing API description files and compiling a list of HTTP transactions to test.
verbose: Compiling HTTP transactions from API description file: emiyaml.yaml
verbose: Starting reporters and waiting until all of them are ready.
info: Beginning Dredd testing...
verbose: Starting transaction runner.
verbose: Sorting HTTP transactions
verbose: Configuring HTTP transactions
verbose: Reading hook files and registering hooks
verbose: Executing HTTP transactions
verbose: Running 'beforeAll' hooks
verbose: Processing transaction #1: /info.0.json/ > Get method for XKCD > 200
verbose: Running 'beforeEach' hooks
verbose: Running 'before' hooks
debug: Emitting to reporters: test start
verbose: About to perform an HTTP request to the server under test: GET http://xkcd.com/info.0.json/
verbose: Handling HTTP response from tested server
verbose: Running 'beforeEachValidation' hooks
verbose: Running 'beforeValidation' hooks
verbose: Validating HTTP transaction by Gavel.js
debug: Determining whether HTTP transaction is valid (getting boolean verdict)
debug: Validating HTTP transaction (getting verbose validation result)
verbose: Running 'afterEach' hooks
verbose: Running 'after' hooks
debug: Evaluating results of transaction execution #1: /info.0.json/ > Get method for XKCD > 200
debug: Emitting to reporters: test fail
fail: GET (200) /info.0.json/ duration: 329ms
verbose: Running 'afterAll' hooks
verbose: Wrapping up testing.
info: Displaying failed tests...
fail: GET (200) /info.0.json/ duration: 329ms
fail: statusCode: Status code is not '200'
Hi, thanks for the issue! Dredd is designed to not to follow redirects, intentionally. See previous discussion here: https://github.com/apiaryio/dredd/issues/795#issuecomment-337818031
I take this issue as a feature request and I'd be happy to discuss the use cases when this is useful under this issue.
@honzajavorek i have gone through the discussion thrice already!, to be sure that i am not missing anything, there should be some Command line options, analogous to curl, where we can specify -L option for redirecting the requests. The same here would be very helpful. Don't change the default behaviour because not many want to test the redirects. Please provide an option for enabling the redirects. 馃榾
A good place to start is to make this assignment parametric:
It should propagate via some flat (i.e. --follow-redirects) to the CLI options -> runner configuration, and land in performRequest.
Most helpful comment
@honzajavorek i have gone through the discussion thrice already!, to be sure that i am not missing anything, there should be some Command line options, analogous to curl, where we can specify -L option for redirecting the requests. The same here would be very helpful. Don't change the default behaviour because not many want to test the redirects. Please provide an option for enabling the redirects. 馃榾