Add `response_avatar_link` helper to webfinger request spec (#31999)

pull/32034/head
Matt Jankowski 2024-09-23 06:44:52 -04:00 committed by GitHub
parent 447d0a3e88
commit 2b4bda8004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 12 deletions

View File

@ -168,10 +168,12 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'returns avatar in response' do it 'returns avatar in response' do
perform_request! perform_request!
avatar_link = get_avatar_link(response.parsed_body) expect(response_avatar_link)
expect(avatar_link).to_not be_nil .to be_present
expect(avatar_link[:type]).to eq alice.avatar.content_type .and include(
expect(avatar_link[:href]).to eq Addressable::URI.new(host: Rails.configuration.x.local_domain, path: alice.avatar.to_s, scheme: 'https').to_s type: eq(alice.avatar.content_type),
href: eq(Addressable::URI.new(host: Rails.configuration.x.local_domain, path: alice.avatar.to_s, scheme: 'https').to_s)
)
end end
context 'with limited federation mode' do context 'with limited federation mode' do
@ -182,8 +184,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'does not return avatar in response' do it 'does not return avatar in response' do
perform_request! perform_request!
avatar_link = get_avatar_link(response.parsed_body) expect(response_avatar_link)
expect(avatar_link).to be_nil .to be_nil
end end
end end
@ -197,8 +199,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
it 'does not return avatar in response' do it 'does not return avatar in response' do
perform_request! perform_request!
avatar_link = get_avatar_link(response.parsed_body) expect(response_avatar_link)
expect(avatar_link).to be_nil .to be_nil
end end
end end
end end
@ -212,8 +214,8 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
end end
it 'does not return avatar in response' do it 'does not return avatar in response' do
avatar_link = get_avatar_link(response.parsed_body) expect(response_avatar_link)
expect(avatar_link).to be_nil .to be_nil
end end
end end
@ -247,7 +249,9 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
private private
def get_avatar_link(json) def response_avatar_link
json[:links].find { |link| link[:rel] == 'http://webfinger.net/rel/avatar' } response
.parsed_body[:links]
.find { |link| link[:rel] == 'http://webfinger.net/rel/avatar' }
end end
end end