about summary refs log tree commit diff
path: root/spec/services/process_interaction_service_spec.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2017-05-03 20:40:14 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-05-03 20:40:14 +0200
commit8d4e7504b16a4a33ec7ba5fa5edf3dcaf7669318 (patch)
tree877b05c5280341beb5e26e6661a7be03ff07835c /spec/services/process_interaction_service_spec.rb
parentaa6a26a2d5afb38ebd7774b8c61e247c27be1a0d (diff)
Additional specs for URI handling (#2759)
Diffstat (limited to 'spec/services/process_interaction_service_spec.rb')
-rw-r--r--spec/services/process_interaction_service_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/process_interaction_service_spec.rb b/spec/services/process_interaction_service_spec.rb
index 0845e09ed..f589f690d 100644
--- a/spec/services/process_interaction_service_spec.rb
+++ b/spec/services/process_interaction_service_spec.rb
@@ -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)