How to set up dredd to ignore headers in the assertion

224 Views Asked by At

I am using Dredd to test one of my endpoints. I think the test is failling due to the headers, because I'm getting the following expected:

headers:
    Content-Type: application/json

body:
[
  {
    "id": 15107,
    "name": "Route Name",
    "date": "2022-01-27T09:00:00",
    "full_user_name": "Test Admin",
    "url": "api/2/users/1/routes/15107"
  }
]
statusCode: 200

And the following actual:

statusCode: 200
headers:
    date: Wed, 02 Feb 2022 12:54:11 GMT
    server: WSGIServer/0.2 CPython/3.6.9
    content-type: application/json; charset=utf-8
    vary: Accept, Cookie
    allow: GET, POST, PATCH, HEAD, OPTIONS
    access-control-allow-origin: None
    access-control-allow-methods: POST,GET
    access-control-allow-headers: Origin,Content-Type,Accept,Accept-Encoding
    access-control-allow-credentials: true
    x-frame-options: SAMEORIGIN
    content-length: 136

bodyEncoding: utf-8
body:
[
  {
    "id": 15107,
    "name": "Route Name",
    "date": "2022-01-27T09:00:00",
    "full_user_name": "Test Admin",
    "url": "api/2/users/1/routes/15107"
  }
]

The only difference I see is the headers. Is there any way to ignore those? Like, for instance, content-length header. Maybe I only need to include the auth header in the Open API file. Right now I have specified documentation as follows:

...
  securitySchemes:
    ApiKey:
      type: apiKey
      name: Authorization
      in: header
      description: Authentication token
security:
  - ApiKey: []

And running dredd as follows with a python server:

dredd oas-routes.yaml http://127.0.0.1:8000/api/2/users/1/routes --header="Authorization: Token 6b232e1c00bbc8b12d0066a483bf401009fbdb21"

Any idea how to do this correctly? I'm quite new to testing with dredd to be honest.

0

There are 0 best solutions below