Stop stubbing signature verification unless it's necessary
This commit is contained in:
parent
ffa467b795
commit
b404346c40
4 changed files with 18 additions and 20 deletions
|
|
@ -97,6 +97,10 @@ describe Comment do
|
||||||
user.receive comment.to_diaspora_xml, user2.person
|
user.receive comment.to_diaspora_xml, user2.person
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'posts from a remote person' do
|
||||||
|
before(:all) do
|
||||||
|
stub_comment_signature_verification
|
||||||
|
end
|
||||||
it 'should not send a comment a person made on his own post to anyone' do
|
it 'should not send a comment a person made on his own post to anyone' do
|
||||||
User::QUEUE.should_not_receive(:add_post_request)
|
User::QUEUE.should_not_receive(:add_post_request)
|
||||||
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
|
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
|
||||||
|
|
@ -108,6 +112,10 @@ describe Comment do
|
||||||
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)
|
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)
|
||||||
user.receive comment.to_diaspora_xml, @person
|
user.receive comment.to_diaspora_xml, @person
|
||||||
end
|
end
|
||||||
|
after(:all) do
|
||||||
|
unstub_mocha_stubs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should not clear the aspect post array on receiving a comment' do
|
it 'should not clear the aspect post array on receiving a comment' do
|
||||||
aspect.post_ids.include?(@user_status.id).should be true
|
aspect.post_ids.include?(@user_status.id).should be true
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ describe User do
|
||||||
comment_id = comment.id
|
comment_id = comment.id
|
||||||
|
|
||||||
comment.delete
|
comment.delete
|
||||||
|
comment.post_creator_signature = comment.sign_with_key(user.encryption_key)
|
||||||
user3.receive comment.to_diaspora_xml, user.person
|
user3.receive comment.to_diaspora_xml, user.person
|
||||||
user3.reload
|
user3.reload
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,6 @@ RSpec.configure do |config|
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
DatabaseCleaner.orm = "mongo_mapper"
|
DatabaseCleaner.orm = "mongo_mapper"
|
||||||
|
|
||||||
config.before(:suite) do
|
|
||||||
stub_signature_verification
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
stub_sockets
|
stub_sockets
|
||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
|
|
@ -49,10 +45,8 @@ ImageUploader.enable_processing = false
|
||||||
Diaspora::WebSocket.unstub!(:unsubscribe)
|
Diaspora::WebSocket.unstub!(:unsubscribe)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_signature_verification
|
def stub_comment_signature_verification
|
||||||
(get_models.map{|model| model.camelize.constantize} - [User]).each do |model|
|
Comment.any_instance.stubs(:verify_signature).returns(true)
|
||||||
model.any_instance.stubs(:verify_signature).returns(true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def unstub_mocha_stubs
|
def unstub_mocha_stubs
|
||||||
|
|
@ -82,11 +76,12 @@ ImageUploader.enable_processing = false
|
||||||
aspect2.reload
|
aspect2.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_success(address = 'abc@example.com')
|
def stub_success(address = 'abc@example.com', opts = {})
|
||||||
host = address.split('@')[1]
|
host = address.split('@')[1]
|
||||||
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||||
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||||
if host.include?("joindiaspora.com")
|
if opts[:diaspora] || host.include?("diaspora")
|
||||||
|
puts address
|
||||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => finger_xrd)
|
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => finger_xrd)
|
||||||
stub_request(:get, "http://#{host}/hcard/users/4c8eccce34b7da59ff000002").to_return(:status => 200, :body => hcard_response)
|
stub_request(:get, "http://#{host}/hcard/users/4c8eccce34b7da59ff000002").to_return(:status => 200, :body => hcard_response)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe 'user encryption' do
|
describe 'user encryption' do
|
||||||
before do
|
before do
|
||||||
unstub_mocha_stubs
|
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@aspect = @user.aspect(:name => 'dudes')
|
@aspect = @user.aspect(:name => 'dudes')
|
||||||
|
|
||||||
|
|
@ -14,13 +13,6 @@ describe 'user encryption' do
|
||||||
@aspect2 = @user2.aspect(:name => 'dudes')
|
@aspect2 = @user2.aspect(:name => 'dudes')
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
|
||||||
stub_signature_verification
|
|
||||||
#gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__)
|
|
||||||
#ctx = GPGME::Ctx.new
|
|
||||||
#keys = ctx.keys
|
|
||||||
#keys.each{|k| ctx.delete_key(k, true)}
|
|
||||||
end
|
|
||||||
it 'should have a key' do
|
it 'should have a key' do
|
||||||
@user.encryption_key.should_not be nil
|
@user.encryption_key.should_not be nil
|
||||||
end
|
end
|
||||||
|
|
@ -34,6 +26,8 @@ describe 'user encryption' do
|
||||||
it 'should receive and marshal a public key from a request' do
|
it 'should receive and marshal a public key from a request' do
|
||||||
remote_user = Factory.build(:user)
|
remote_user = Factory.build(:user)
|
||||||
remote_user.encryption_key.nil?.should== false
|
remote_user.encryption_key.nil?.should== false
|
||||||
|
|
||||||
|
Person.should_receive(:by_webfinger).and_return(remote_user.person)
|
||||||
#should move this to friend request, but i found it here
|
#should move this to friend request, but i found it here
|
||||||
id = remote_user.person.id
|
id = remote_user.person.id
|
||||||
original_key = remote_user.exported_key
|
original_key = remote_user.exported_key
|
||||||
|
|
@ -41,13 +35,13 @@ describe 'user encryption' do
|
||||||
request = remote_user.send_friend_request_to(
|
request = remote_user.send_friend_request_to(
|
||||||
@user.person, remote_user.aspect(:name => "temp"))
|
@user.person, remote_user.aspect(:name => "temp"))
|
||||||
|
|
||||||
xml = request.to_diaspora_xml
|
xml = remote_user.salmon(request).xml_for(@user)
|
||||||
|
|
||||||
remote_user.person.delete
|
remote_user.person.delete
|
||||||
remote_user.delete
|
remote_user.delete
|
||||||
|
|
||||||
person_count = Person.all.count
|
person_count = Person.all.count
|
||||||
@user.receive xml, remote_user.person
|
@user.receive_salmon xml
|
||||||
|
|
||||||
Person.all.count.should == person_count + 1
|
Person.all.count.should == person_count + 1
|
||||||
new_person = Person.first(:id => id)
|
new_person = Person.first(:id => id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue