Filtering sensitive data with VCR

后端 未结 2 1897
野性不改
野性不改 2021-02-13 04:14

I\'m using VCR gem to record http interactions and replay them in future. I want to filter-out my actual password value in the uri request. Here\'s sample of what the uri look

2条回答
  •  情歌与酒
    2021-02-13 05:00

    VCR.configure do |c|
      c.filter_sensitive_data("") do
        ENV['SOMESITE_PASSWORD']
        # or $credentials['somesite']['password'] or whatever
      end
    end
    

    Essentially, you give VCR a bit of placeholder text, and then the block needs to return the real password, reading it from whatever the canonical password "repository" is.

    Note that the real password is only needed the first time, when the request is recorded; on subsequent runs, it can be a fake password (as long as it's the same fake password used by the code making the request).

提交回复
热议问题