Skip to content
Extraits de code Groupes Projets
Valider 964ee65b rédigé par ilya's avatar ilya
Parcourir les fichiers

rs iz ; the signature of the signable_accessors are now in the xml

parent add9961c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -6,6 +6,7 @@ class Post
include Diaspora::Webhooks
xml_accessor :_id
xml_accessor :owner_signature
xml_accessor :person, :as => Person
key :person_id, ObjectId
......@@ -51,6 +52,7 @@ class Post
accessors = self.class.roxml_attrs.collect{|definition|
definition.accessor}
accessors.delete 'person'
accessors.delete 'owner_signature'
accessors
end
......@@ -62,16 +64,19 @@ class Post
def verify_signature
return false unless owner_signature && person.key_fingerprint
validity = nil
GPGME::verify(owner_signature, signable_string, {:armor => true, :always_trust => true}){ |signature|
validity = signature.status == GPGME::GPG_ERR_NO_ERROR &&
signature.fpr == person.key_fingerprint
GPGME::verify(owner_signature, signable_string,
{:armor => true, :always_trust => true}){ |signature|
puts signature
validity = signature.status == GPGME::GPG_ERR_NO_ERROR &&
signature.fpr == person.key_fingerprint
puts validity
}
return validity
end
protected
def sign_if_mine
if self.person == User.first
if self.person == User.owner
self.owner_signature = GPGME::sign(signable_string,nil,
{:armor=> true, :mode => GPGME::SIG_MODE_DETACH})
end
......
......@@ -24,7 +24,7 @@ Factory.define :user do |u|
u.password "bluepin7"
u.password_confirmation "bluepin7"
u.url "www.example.com/"
u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint
u.key_fingerprint GPGME.list_keys("Smith", true).first.subkeys.first.fingerprint
u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" )
end
......
......@@ -81,6 +81,7 @@ describe 'user encryption' do
end
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
......@@ -115,4 +116,12 @@ describe 'user encryption' do
message.verify_signature.should be false
end
end
describe 'sending and recieving signatures' do
it 'should contain the signature in the xml' do
message = Factory.create(:status_message, :person => @u)
xml = message.to_xml.to_s
xml.include?(message.owner_signature).should be true
end
end
end
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