Skip to content
Extraits de code Groupes Projets
Valider f680c4b7 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

RS, IZ; Signature Verification now stubbed out outside of encryption specs, green

parent 4a0bd5fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -46,7 +46,7 @@ class Post
#ENCRYPTION
before_validation :sign_if_mine
#validates_true_for :owner_signature, :logic => lambda {self.verify_signature}
validates_true_for :owner_signature, :logic => lambda {self.verify_signature}
key :owner_signature, String
......
......@@ -12,7 +12,7 @@ include Devise::TestHelpers
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
RSpec.configure do |config|
config.mock_with :mocha
config.mock_with :rspec
DatabaseCleaner.strategy = :truncation
......@@ -20,11 +20,12 @@ RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
stub_signature_verification
end
config.before(:each) do
DatabaseCleaner.start
stub_sockets_controller
stub_sockets_controller
end
config.after(:each) do
......@@ -39,3 +40,15 @@ end
mock_sockets_controller.stub!(:delete_subscriber).and_return(true)
SocketsController.stub!(:new).and_return(mock_sockets_controller)
end
def stub_signature_verification
Post.any_instance.stubs(:verify_signature).returns(true)
StatusMessage.any_instance.stubs(:verify_signature).returns(true)
Blog.any_instance.stubs(:verify_signature).returns(true)
Bookmark.any_instance.stubs(:verify_signature).returns(true)
end
def unstub_mocha_stubs
Mocha::Mockery.instance.stubba.unstub_all
end
......@@ -9,6 +9,7 @@ describe 'user encryption' do
end
before do
unstub_mocha_stubs
@u = Factory.create(:user)
@u.send(:assign_key)
@u.save
......@@ -22,12 +23,13 @@ describe 'user encryption' do
end
# after :all do
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
end
it 'should remove the key from the keyring on person destroy' do
pending "We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of"
......@@ -79,9 +81,9 @@ describe 'user encryption' do
end
describe 'signing and verifying' do
it 'should sign a message on create' do
message = Factory.create(:status_message, :person => @u)
puts message.owner_signature
message.verify_signature.should be true
end
......@@ -126,8 +128,6 @@ describe 'user encryption' do
xml.include?(message.owner_signature).should be true
end
it 'the signature should be verified on marshaling' do
pending "We're going to work on embeded profile"
message = Factory.build(:status_message, :person => @person)
message.owner_signature = GPGME.sign(message.signable_string, nil,
{:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@u.key]})
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter