Additional specs for URI handling (#2759)
This commit is contained in:
parent
aa6a26a2d5
commit
8d4e7504b1
5 changed files with 133 additions and 0 deletions
|
@ -15,6 +15,10 @@ RSpec.describe FollowRemoteAccountService do
|
|||
stub_request(:get, "https://quitter.no/.well-known/webfinger?resource=acct:catsrgr8@quitter.no").to_return(status: 404)
|
||||
stub_request(:get, "https://quitter.no/api/statuses/user_timeline/7477.atom").to_return(request_fixture('feed.txt'))
|
||||
stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt'))
|
||||
stub_request(:get, "https://localdomain.com/.well-known/host-meta").to_return(request_fixture('localdomain-hostmeta.txt'))
|
||||
stub_request(:get, "https://localdomain.com/.well-known/webfinger?resource=acct:foo@localdomain.com").to_return(status: 404)
|
||||
stub_request(:get, "https://webdomain.com/.well-known/webfinger?resource=acct:foo@localdomain.com").to_return(request_fixture('localdomain-webfinger.txt'))
|
||||
stub_request(:get, "https://webdomain.com/users/foo.atom").to_return(request_fixture('localdomain-feed.txt'))
|
||||
end
|
||||
|
||||
it 'raises error if no such user can be resolved via webfinger' do
|
||||
|
@ -56,4 +60,12 @@ RSpec.describe FollowRemoteAccountService do
|
|||
it 'prevents hijacking inexisting accounts' do
|
||||
expect { subject.call('hacker2@redirected.com') }.to raise_error Goldfinger::Error
|
||||
end
|
||||
|
||||
it 'returns a new remote account' do
|
||||
account = subject.call('foo@localdomain.com')
|
||||
|
||||
expect(account.username).to eq 'foo'
|
||||
expect(account.domain).to eq 'localdomain.com'
|
||||
expect(account.remote_url).to eq 'https://webdomain.com/users/foo.atom'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'rails_helper'
|
|||
RSpec.describe ProcessInteractionService do
|
||||
let(:receiver) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account }
|
||||
let(:sender) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
|
||||
let(:remote_sender) { Fabricate(:account, username: 'carol', domain: 'localdomain.com', uri: 'https://webdomain.com/users/carol') }
|
||||
|
||||
subject { ProcessInteractionService.new }
|
||||
|
||||
|
@ -31,6 +32,35 @@ XML
|
|||
end
|
||||
end
|
||||
|
||||
describe 'follow request slap from known remote user identified by email' do
|
||||
before do
|
||||
receiver.update(locked: true)
|
||||
# Copy already-generated key
|
||||
remote_sender.update(private_key: sender.private_key, public_key: remote_sender.public_key)
|
||||
|
||||
payload = <<XML
|
||||
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:activity="http://activitystrea.ms/spec/1.0/">
|
||||
<author>
|
||||
<email>carol@localdomain.com</email>
|
||||
<name>carol</name>
|
||||
<uri>https://webdomain.com/users/carol</uri>
|
||||
</author>
|
||||
|
||||
<id>someIdHere</id>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/request-friend</activity:verb>
|
||||
</entry>
|
||||
XML
|
||||
|
||||
envelope = OStatus2::Salmon.new.pack(payload, remote_sender.keypair)
|
||||
subject.call(envelope, receiver)
|
||||
end
|
||||
|
||||
it 'creates a record' do
|
||||
expect(FollowRequest.find_by(account: remote_sender, target_account: receiver)).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'follow request authorization slap' do
|
||||
before do
|
||||
receiver.update(locked: true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue