[deploy] Add Back Tracking API-keys in Honeycomb (#7868)

This commit is contained in:
Molly Struve 2020-05-14 15:10:15 -05:00 committed by GitHub
parent 203e8e1ae7
commit 7dd249ac21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -21,6 +21,7 @@ class Rack::Attack
return if request.env["HTTP_FASTLY_CLIENT_IP"].blank?
if request.path.starts_with?("/api/") && (request.put? || request.post? || request.delete?)
Honeycomb.add_field("user_api_key", request.env["HTTP_API_KEY"])
track_and_return_ip(request.env["HTTP_FASTLY_CLIENT_IP"])
end
end

View file

@ -64,6 +64,8 @@ describe Rack::Attack, type: :request, throttle: true do
expect(new_api_response).not_to eq(429)
expect(Honeycomb).to have_received(:add_field).with("fastly_client_ip", "5.6.7.8").exactly(3).times
expect(Honeycomb).to have_received(:add_field).with("fastly_client_ip", "1.1.1.1").exactly(2).times
expect(Honeycomb).to have_received(:add_field).with("user_api_key", api_secret.secret).exactly(2).times
expect(Honeycomb).to have_received(:add_field).with("user_api_key", another_api_secret.secret)
end
end
end