From 1eab53ee1030542a5c4c56203a61eecae9768131 Mon Sep 17 00:00:00 2001 From: unarist Date: Sun, 17 Sep 2017 18:54:23 +0900 Subject: Fix an error when actor json couldn't be fetched in ResolveRemoteAccountService (#4979) * Fix an error when actor json couldn't be fetched in ResolveRemoteAccountService * Add specs --- .../resolve_remote_account_service_spec.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'spec/services/resolve_remote_account_service_spec.rb') diff --git a/spec/services/resolve_remote_account_service_spec.rb b/spec/services/resolve_remote_account_service_spec.rb index d0eab2310..d0bb6a137 100644 --- a/spec/services/resolve_remote_account_service_spec.rb +++ b/spec/services/resolve_remote_account_service_spec.rb @@ -72,6 +72,39 @@ RSpec.describe ResolveRemoteAccountService do end context 'with an ActivityPub account' do + before do + stub_request(:get, "https://ap.example.com/.well-known/webfinger?resource=acct:foo@ap.example.com").to_return(request_fixture('activitypub-webfinger.txt')) + stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor.txt')) + stub_request(:get, "https://ap.example.com/users/foo.atom").to_return(request_fixture('activitypub-feed.txt')) + stub_request(:get, %r{https://ap.example.com/users/foo/\w+}).to_return(status: 404) + end + + it 'fallback to OStatus if actor json could not be fetched' do + stub_request(:get, "https://ap.example.com/users/foo").to_return(status: 404) + + account = subject.call('foo@ap.example.com') + + expect(account.ostatus?).to eq true + expect(account.remote_url).to eq 'https://ap.example.com/users/foo.atom' + end + + it 'fallback to OStatus if actor json did not have inbox_url' do + stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor-noinbox.txt')) + + account = subject.call('foo@ap.example.com') + + expect(account.ostatus?).to eq true + expect(account.remote_url).to eq 'https://ap.example.com/users/foo.atom' + end + + it 'returns new remote account' do + account = subject.call('foo@ap.example.com') + + expect(account.activitypub?).to eq true + expect(account.domain).to eq 'ap.example.com' + expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' + end + pending end -- cgit