Skip to content

Commit

Permalink
Bugfix DeliverAuthorizationRequestWebhookJob with hardcoded path
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed Mar 28, 2024
1 parent 4317b7c commit ff9bd1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/jobs/deliver_authorization_request_webhook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def perform(target_api, json, authorization_request_id)
private

def request(target_api, payload)
Faraday.new(webhook_url(target_api)).post('/webhook') do |req|
Faraday.new(webhook_uri(target_api).to_s).post(webhook_uri(target_api).path) do |req|
req.headers['Content-Type'] = 'application/json'
req.headers['X-Hub-Signature-256'] = "sha256=#{generate_hub_signature(target_api, payload)}"
req.body = payload.to_json
Expand Down Expand Up @@ -95,6 +95,10 @@ def generate_hub_signature(target_api, payload)
)
end

def webhook_uri(target_api)
URI(webhook_url(target_api))
end

def webhook_url(target_api)
Rails.application.credentials.webhooks.public_send(target_api)&.url
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end
let(:status) { [200, 201, 204].sample }
let(:body) { 'whatever' }
let(:webhook_url) { 'https://service.gouv.fr/webhook' }
let(:webhook_url) { 'https://service.gouv.fr/path/to/webhook' }
let(:verify_token) { 'verify_token' }
let(:hub_signature) do
OpenSSL::HMAC.hexdigest(
Expand Down

0 comments on commit ff9bd1c

Please sign in to comment.