dredd: Mixed topics


Logging

To run dredd with more logging infos you can set its loglevel to debug:

dredd swagger.json http://localhost:postnumber --loglevel debug

Authentication

If the microservice API you want to test requires authentication, you can use dredd hooks to add authentication information to the request sent by dredd to API.

For example the following dredd command uses a hook to do some preparatory activities:

dredd swagger.json http://localhost:postnumber --hookfiles=./hooks.js

In this example our hooks.js file should add authentication information to the header of the request which will be sent by dredd:

hooks.js:

const hooks = require('hooks');

hooks.beforeEach(function (transaction) {
   hooks.log('before each');
   transaction.request.headers.Authorization = 'Bearer long-token-string';
});