mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-30 17:54:13 +00:00
Add fallback redirection when getting a webfinger query LOCAL_DOMAIN@LOCAL_DOMAIN
(#23600)
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
This commit is contained in:
parent
5e060e1f44
commit
9189e90ff2
|
@ -18,7 +18,14 @@ module WellKnown
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = Account.find_local!(username_from_resource)
|
username = username_from_resource
|
||||||
|
@account = begin
|
||||||
|
if username == Rails.configuration.x.local_domain
|
||||||
|
Account.representative
|
||||||
|
else
|
||||||
|
Account.find_local!(username)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def username_from_resource
|
def username_from_resource
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
describe 'GET #show' do
|
describe 'GET #show' do
|
||||||
subject do
|
subject(:perform_show!) do
|
||||||
get :show, params: { resource: resource }, format: :json
|
get :show, params: { resource: resource }, format: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
let(:resource) { alice.to_webfinger_s }
|
let(:resource) { alice.to_webfinger_s }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'a successful response'
|
it_behaves_like 'a successful response'
|
||||||
|
@ -56,7 +56,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
alice.suspend!
|
alice.suspend!
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it_behaves_like 'a successful response'
|
it_behaves_like 'a successful response'
|
||||||
|
@ -68,7 +68,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
before do
|
before do
|
||||||
alice.suspend!
|
alice.suspend!
|
||||||
alice.deletion_request.destroy
|
alice.deletion_request.destroy
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http gone' do
|
it 'returns http gone' do
|
||||||
|
@ -80,7 +80,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
let(:resource) { 'acct:not@existing.com' }
|
let(:resource) { 'acct:not@existing.com' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http not found' do
|
it 'returns http not found' do
|
||||||
|
@ -92,7 +92,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
let(:alternate_domains) { ['foo.org'] }
|
let(:alternate_domains) { ['foo.org'] }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when an account exists' do
|
context 'when an account exists' do
|
||||||
|
@ -116,11 +116,39 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the old name scheme is used to query the instance actor' do
|
||||||
|
let(:resource) do
|
||||||
|
"#{Rails.configuration.x.local_domain}@#{Rails.configuration.x.local_domain}"
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
perform_show!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns http success' do
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not set a Vary header' do
|
||||||
|
expect(response.headers['Vary']).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns application/jrd+json' do
|
||||||
|
expect(response.media_type).to eq 'application/jrd+json'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns links for the internal account' do
|
||||||
|
json = body_as_json
|
||||||
|
expect(json[:subject]).to eq 'acct:mastodon.internal@cb6e6126.ngrok.io'
|
||||||
|
expect(json[:aliases]).to eq ['https://cb6e6126.ngrok.io/actor']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with no resource parameter' do
|
context 'with no resource parameter' do
|
||||||
let(:resource) { nil }
|
let(:resource) { nil }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http bad request' do
|
it 'returns http bad request' do
|
||||||
|
@ -132,7 +160,7 @@ describe WellKnown::WebfingerController, type: :controller do
|
||||||
let(:resource) { 'df/:dfkj' }
|
let(:resource) { 'df/:dfkj' }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject
|
perform_show!
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http bad request' do
|
it 'returns http bad request' do
|
||||||
|
|
Loading…
Reference in a new issue