Revert "RS IZ Friday night, key_fingerprint serialization weirdness"

This reverts commit c6e16835df9c5d46d0ec5e0f1860da1ef4c0986a.
This commit is contained in:
ilya 2010-07-10 05:29:57 -04:00
parent 8c75761ba1
commit 7eba033c0d
8 changed files with 10 additions and 45 deletions

View file

@ -6,7 +6,6 @@ class Person
xml_accessor :url xml_accessor :url
xml_accessor :profile, :as => Profile xml_accessor :profile, :as => Profile
xml_accessor :_id xml_accessor :_id
xml_accessor :key_fingerprint
key :email, String key :email, String
key :url, String key :url, String
@ -38,9 +37,6 @@ class Person
GPGME::Ctx.new.get_key key_fingerprint GPGME::Ctx.new.get_key key_fingerprint
end end
def export_key
GPGME::export(key_fingerprint, :armor => true)
end
protected protected

View file

@ -8,14 +8,12 @@ class Request
xml_accessor :person, :as => Person xml_accessor :person, :as => Person
xml_accessor :destination_url xml_accessor :destination_url
xml_accessor :callback_url xml_accessor :callback_url
xml_accessor :exported_key
key :destination_url, String key :destination_url, String
key :callback_url, String key :callback_url, String
key :person, Person#_id, ObjectId key :person_id, ObjectId
key :exported_key, String
#belongs_to :person belongs_to :person
validates_presence_of :destination_url, :callback_url validates_presence_of :destination_url, :callback_url
@ -24,7 +22,7 @@ class Request
def self.instantiate(options ={}) def self.instantiate(options ={})
person = options[:from] person = options[:from]
self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) self.new(:destination_url => options[:to], :callback_url => person.url, :person => person)
end end
def activate_friend def activate_friend

View file

@ -28,10 +28,10 @@ class User < Person
######### Friend Requesting ######### Friend Requesting
def send_friend_request_to(friend_url) def send_friend_request_to(friend_url)
unless Person.where(:url => friend_url).first unless Person.where(:url => friend_url).first
request = Request.instantiate(:to => friend_url, :from => self) p = Request.instantiate(:to => friend_url, :from => self)
if request.save if p.save
request.push_to_url friend_url p.push_to_url friend_url
request p
end end
end end
end end
@ -41,7 +41,6 @@ class User < Person
request.activate_friend request.activate_friend
request.person = self request.person = self
request.destination_url = request.callback_url request.destination_url = request.callback_url
request.exported_key = self.export_key
request.push_to_url(request.callback_url) request.push_to_url(request.callback_url)
request.destroy request.destroy
end end

Binary file not shown.

View file

@ -17,11 +17,7 @@ module Diaspora
body = parse_body_contents_from_xml(xml) body = parse_body_contents_from_xml(xml)
body.children.each do |post| body.children.each do |post|
begin begin
puts "people: #{Person.count}"
puts "requests: #{Request.count}"
object = post.name.camelize.constantize.from_xml post.to_s object = post.name.camelize.constantize.from_xml post.to_s
puts "people: #{Person.count}"
puts "requests: #{Request.count}"
object.person = parse_owner_from_xml post.to_s if object.respond_to? :person object.person = parse_owner_from_xml post.to_s if object.respond_to? :person
objects << object objects << object
rescue rescue

View file

@ -10,9 +10,8 @@ Factory.define :profile do |p|
end end
Factory.define :person do |p| Factory.define :person do |p|
p.email "bob-person@aol.com" p.email "bob@aol.com"
p.sequence(:url) {|n|"http://google-#{n}.com/"} p.sequence(:url) {|n|"http://google-#{n}.com/"}
p.key_fingerprint GPGME::list_keys("Aditi").first.subkeys.first.fingerprint
p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" )
end end
@ -21,7 +20,6 @@ Factory.define :user do |u|
u.password "bluepin7" u.password "bluepin7"
u.password_confirmation "bluepin7" u.password_confirmation "bluepin7"
u.url "www.example.com/" u.url "www.example.com/"
u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint
u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" )
end end

View file

@ -11,7 +11,7 @@ describe Request do
end end
it 'should generate xml for the User as a Person' do it 'should generate xml for the User as a Person' do
user = Factory.build(:user, :email => "rob@bob.com") user = User.create(:email => "rob@bob.com")
user.profile = Factory.create(:profile) user.profile = Factory.create(:profile)

View file

@ -1,5 +1,4 @@
require File.dirname(__FILE__) + '/spec_helper' require File.dirname(__FILE__) + '/spec_helper'
include ApplicationHelper
describe 'user encryption' do describe 'user encryption' do
before :all do before :all do
@ -29,28 +28,7 @@ describe 'user encryption' do
end end
describe 'key exchange on friending' do describe 'key exchange on friending' do
it 'should send over a public key' do
Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request)
request = @u.send_friend_request_to("http://example.com/")
Request.build_xml_for([request]).include?( @u.export_key).should be true
end
it 'should receive and marshal a public key from a request' do
puts "THIS IS FUCKED UP"
person = Factory.build(:person )
original_key = person.export_key
person.save
request = Request.instantiate(:to =>"http://www.google.com/", :from => person)
xml = Request.build_xml_for [request]
person.destroy
store_objects_from_xml(xml)
new_person = Person.first(:url => request.callback_url)
new_person.export_key.should == original_key
end
end end
describe 'signing and verifying' do describe 'signing and verifying' do