about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-08-23 01:30:15 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-08-22 18:30:15 +0200
commitd63de55ef84eea883b72a121d680b8841af8e2c0 (patch)
treeb14c60fb4827f5cffa84cd9c54397e019023a717 /spec/services
parent72bb3e03fdf4d8c886d41f3459000b336a3a362b (diff)
Fix bugs which OStatus accounts may detected as ActivityPub ready (#4662)
* Fallback to OStatus in FetchAtomService

* Skip activity+json link if that activity is Person without inbox
* If unsupported activity was detected and all other URLs failed, retry with ActivityPub-less Accept header

* Allow mention to OStatus account in ActivityPub

* Don't update profile with inbox-less Person object
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/activitypub/fetch_remote_account_service_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/activitypub/fetch_remote_account_service_spec.rb b/spec/services/activitypub/fetch_remote_account_service_spec.rb
index 786d7f7f2..391d051c1 100644
--- a/spec/services/activitypub/fetch_remote_account_service_spec.rb
+++ b/spec/services/activitypub/fetch_remote_account_service_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
       preferredUsername: 'alice',
       name: 'Alice',
       summary: 'Foo bar',
+      inbox: 'http://example.com/alice/inbox',
     }
   end
 
@@ -35,6 +36,32 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
       end
     end
 
+    context 'when the account does not have a inbox' do
+      let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }
+
+      before do
+        actor[:inbox] = nil
+        
+        stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
+        stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
+      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
+        expect(account).to be_nil
+      end
+
+    end
+
     context 'when URI and WebFinger share the same host' do
       let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }