Merge remote-tracking branch 'parent/main' into upstream-20240201

This commit is contained in:
KMY 2024-02-01 11:32:27 +09:00
commit 92ef42d697
179 changed files with 1218 additions and 2902 deletions

View file

@ -21,20 +21,14 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
let(:account) { subject.call('https://example.com/alice', id: true) }
shared_examples 'sets profile data' do
it 'returns an account' do
expect(account).to be_an Account
end
it 'sets display name' do
expect(account.display_name).to eq 'Alice'
end
it 'sets note' do
expect(account.note).to eq 'Foo bar'
end
it 'sets URL' do
expect(account.url).to eq 'https://example.com/alice'
it 'returns an account with expected details' do
expect(account)
.to be_an(Account)
.and have_attributes(
display_name: eq('Alice'),
note: eq('Foo bar'),
url: eq('https://example.com/alice')
)
end
end
@ -49,18 +43,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'returns nil' do
it 'fetches resource and looks up webfinger and returns nil' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
end
@ -73,17 +60,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
it 'fetches resource and looks up webfinger and sets attributes' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'sets username and domain from webfinger' do
expect(account.username).to eq 'alice'
expect(account.domain).to eq 'example.com'
end
@ -101,22 +83,13 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
it 'fetches resource and looks up webfinger and follows redirection and sets attributes' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'looks up "redirected" webfinger' do
account
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
it 'sets username and domain from final webfinger' do
expect(account.username).to eq 'alice'
expect(account.domain).to eq 'iscool.af'
end
@ -133,18 +106,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'does not create account' do
it 'fetches resource and looks up webfinger and does not create account' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
end
@ -158,23 +124,12 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'looks up "redirected" webfinger' do
account
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
it 'does not create account' do
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
end

View file

@ -21,20 +21,14 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
let(:account) { subject.call('https://example.com/alice', id: true) }
shared_examples 'sets profile data' do
it 'returns an account' do
expect(account).to be_an Account
end
it 'sets display name' do
expect(account.display_name).to eq 'Alice'
end
it 'sets note' do
expect(account.note).to eq 'Foo bar'
end
it 'sets URL' do
expect(account.url).to eq 'https://example.com/alice'
it 'returns an account and sets attributes' do
expect(account)
.to be_an(Account)
.and have_attributes(
display_name: eq('Alice'),
note: eq('Foo bar'),
url: eq('https://example.com/alice')
)
end
end
@ -49,18 +43,11 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'returns nil' do
it 'fetches resource and looks up webfinger and returns nil' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
end
@ -73,17 +60,12 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
it 'fetches resource and looks up webfinger and sets values' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'sets username and domain from webfinger' do
expect(account.username).to eq 'alice'
expect(account.domain).to eq 'example.com'
end
@ -101,22 +83,13 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
it 'fetches resource and looks up webfinger and follows redirect and sets values' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'looks up "redirected" webfinger' do
account
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
it 'sets username and domain from final webfinger' do
expect(account.username).to eq 'alice'
expect(account.domain).to eq 'iscool.af'
end
@ -133,18 +106,11 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
stub_request(:get, 'https://example.com/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'does not create account' do
it 'fetches resource and looks up webfinger and does not create account' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
end
@ -158,23 +124,12 @@ RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
stub_request(:get, 'https://iscool.af/.well-known/nodeinfo').to_return(body: '{}')
end
it 'fetches resource' do
account
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
end
it 'looks up webfinger' do
account
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
end
it 'looks up "redirected" webfinger' do
account
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
it 'does not create account' do
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
expect(account).to be_nil
expect(a_request(:get, 'https://example.com/alice')).to have_been_made.once
expect(a_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')).to have_been_made.once
expect(a_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af')).to have_been_made.once
end
end