Skip to content
Snippets Groups Projects
Commit cf32f7da authored by abcang's avatar abcang Committed by Eugen Rochko
Browse files

Fix response of signature_verification_failure_reason (#6441)

parent 2bb39368
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ class ActivityPub::InboxesController < Api::BaseController ...@@ -11,7 +11,7 @@ class ActivityPub::InboxesController < Api::BaseController
process_payload process_payload
head 202 head 202
else else
[signature_verification_failure_reason, 401] render plain: signature_verification_failure_reason, status: 401
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
class Api::SalmonController < Api::BaseController class Api::SalmonController < Api::BaseController
include SignatureVerification
before_action :set_account before_action :set_account
respond_to :txt respond_to :txt
...@@ -9,7 +11,7 @@ class Api::SalmonController < Api::BaseController ...@@ -9,7 +11,7 @@ class Api::SalmonController < Api::BaseController
process_salmon process_salmon
head 202 head 202
elsif payload.present? elsif payload.present?
[signature_verification_failure_reason, 401] render plain: signature_verification_failure_reason, status: 401
else else
head 400 head 400
end end
......
...@@ -40,7 +40,7 @@ RSpec.describe Api::SalmonController, type: :controller do ...@@ -40,7 +40,7 @@ RSpec.describe Api::SalmonController, type: :controller do
end end
end end
context 'with invalid post data' do context 'with empty post data' do
before do before do
request.env['RAW_POST_DATA'] = '' request.env['RAW_POST_DATA'] = ''
post :update, params: { id: account.id } post :update, params: { id: account.id }
...@@ -50,5 +50,19 @@ RSpec.describe Api::SalmonController, type: :controller do ...@@ -50,5 +50,19 @@ RSpec.describe Api::SalmonController, type: :controller do
expect(response).to have_http_status(400) expect(response).to have_http_status(400)
end end
end end
context 'with invalid post data' do
before do
service = double(call: false)
allow(VerifySalmonService).to receive(:new).and_return(service)
request.env['RAW_POST_DATA'] = File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
post :update, params: { id: account.id }
end
it 'returns http client error' do
expect(response).to have_http_status(401)
end
end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment