parroty / exvcr

HTTP request/response recording library for elixir, inspired by VCR.
MIT License
722 stars 132 forks source link

Request headers not being filtered. Httpc #117

Closed Ivor closed 7 years ago

Ivor commented 7 years ago

I am using Tesla, with Httpc and ExVCR in my project. I sign requests with basic authentication. I am trying to setup the VCR recording to filter out the basic authentication.

I wanted to test that my config is working so I could remove it by using a hardcoded authentication value and filter_sensitive_data. That works, but when I use a regular expression to match it fails.

This is my config in test.exs:

config :exvcr, [
  filter_request_headers: ["Authorization", "authorization"]
]

As you can see in the response below this doesn't work. I am testing how my code handles the remote server being down so the failed_connect should not be unrelated. The fact that I can remove, for example, the context-type using filter-sensitive-data tells me its not related to the entire ExVCR setup but to specifically filter_request_headers.

[
  {
    "request": {
      "body": "{\"grant_type\":\"client_credentials\"}",
      "headers": {
        "authorization": "Basic VFdOUlZGTTNZMmMzVjNwUlluQmlUZz09OlIzQmlMMG92S3pGRWNEVjBWbE5tWjJ0YVpWQnVRbEJ3YlRGS2RHMTBTa2hEYm5aT1lrRTRRbkpRTTJ4dWJ6TTBMMmM5UFE9PQ==",
        "content-type": "application/json"
      },
      "method": "post",
      "options": {
        "httpc_options": [],
        "http_options": {
          "autoredirect": "false"
        }
      },
      "request_body": "",
      "url": "http://localhost:4000/api/v2/token"
    },
    "response": {
      "body": "failed_connect",
      "headers": [],
      "status_code": null,
      "type": "error"
    }
  }
]

Hope someone can shed some light. Thanks!

Ivor commented 7 years ago

🙈 hmm, now its working. I must have changed something. I'll try and figure out what happened.