Skip to content

Instantly share code, notes, and snippets.

@jobertabma
Created August 24, 2017 18:29
Show Gist options
  • Save jobertabma/0a58da0c3470fa468983549acaf49ddc to your computer and use it in GitHub Desktop.
Save jobertabma/0a58da0c3470fa468983549acaf49ddc to your computer and use it in GitHub Desktop.
One-liner to reset last 1000 git commits and extract the Authorization header to look for tokens from VCR cassettes
# VCR cassettes stored in JSON
v = []; 1000.times { `git reset --hard HEAD~1`; v << Dir.glob('spec/support/cassettes/**/*.json').map { |f| c = JSON.parse(IO.read(f)); c['http_interactions'].map { |i| i['request']['headers']['Authorization'] } }.flatten.uniq }; puts v.flatten.uniq
# VCR cassettes stored in YAML
v = []; 1000.times { `git reset --hard HEAD~1`; v << Dir.glob('spec/support/cassettes/**/*.yml').map { |f| c = YAML.load_file(f); c['http_interactions'].map { |i| i['request']['headers']['Authorization'] } }.flatten.uniq }; puts v.flatten.uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment