Skip to content
Extraits de code Groupes Projets
Valider 7c32649d rédigé par maxwell's avatar maxwell
Parcourir les fichiers

rebasing master

parent 6d139ab9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,7 @@ class EMWebfinger
raise "Identifier is invalid" if(@account.strip.match(/\:\d+$/))
# Raise an error if identifier is not a valid email (generous regexp)
raise "Identifier is invalid" if !(@account=~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)
end
def fetch
raise 'you need to set a callback before calling fetch' if @callbacks.empty?
person = Person.by_account_identifier(@account)
......@@ -27,10 +27,10 @@ class EMWebfinger
end
private
def get_xrd
http = EventMachine::HttpRequest.new(xrd_url).get :timeout => TIMEOUT
http.callback { get_webfinger_profile(webfinger_profile_url(http.response)) }
http.callback {
get_webfinger_profile(webfinger_profile_url(http.response)) }
http.errback { process_callbacks "there was an error getting the xrd at #{xrd_url}" }
end
......@@ -64,6 +64,13 @@ class EMWebfinger
##helpers
private
def check_nil_response(html)
end
def webfinger_profile_url(xrd_response)
doc = Nokogiri::XML::Document.parse(xrd_response)
swizzle doc.at('Link[rel=lrdd]').attribute('template').value
......
......@@ -59,6 +59,18 @@ describe EMWebfinger do
n.on_person{|person| puts "foo"}
n.instance_variable_get(:@callbacks).count.should be 1
it 'should not blow up if the returned xrd is nil' do
http = FakeHttpRequest.new(:success)
http.callbacks = ['']
EventMachine::HttpRequest.should_receive(:new).and_return(http)
n = EMWebfinger.new("foo@example.com")
n.on_person{|person|
person = "sad"
}
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