Permalink
Browse files

test against real known webfinger accounts

  • Loading branch information...
josephholsten committed Nov 2, 2012
1 parent da98acb commit b10f87d3f95f63001a5263179ed9ea8ef42ff4f1
Showing with 86 additions and 19 deletions.
  1. +0 −10 TODO
  2. +13 −9 lib/discodactyl/cli/format.rb
  3. +73 −0 test/test_known_accounts.rb
View
10 TODO
@@ -25,16 +25,6 @@ Reference Specs
* link header http://tools.ietf.org/html/rfc5988
* versioning-rels http://tools.ietf.org/html/rfc5829
Interesting webfinger variants
* joseph@josephholsten.com
* romeda@gmail.com
* will@willmeyer.com
* dclinton@gmail.com
* bradfitz@gmail.com
* dclinton@yahoo.com
* beestage@yahoo.com
* gffletch@aol.com
other clients
* webfingerclient-dclinton.appspot.com/
* webfinger.org/lookup/darron@froese.org
@@ -9,8 +9,11 @@ def self.for_rel(rel)
when 'http://schemas.google.com/g/2010#updates-from' then
lambda {|uri, io| Discodactyl::CLI::Format.activities_from_uri(uri, io) }
else
name = Discodactyl::KNOWN_RELS[rel]
lambda {|uri, io| io.puts "#{name}: #{uri}" if uri }
if name = Discodactyl::KNOWN_RELS[rel]
lambda {|uri, io| io.puts "#{name}: #{uri}" if uri }
else
lambda {|uri, io| }
end
end
end
@@ -26,13 +29,14 @@ def self.hcard_adr(adr)
def self.hcard_from_uri(uri, io)
begin
hcards = Prism.find(uri, :hcard)
hcards.each do |hcard|
if hcard
io << "Name: #{hcard.fn.gsub(/\s+/, ' ')}\n" if hcard.properties.include?(:fn)
io << "Title: #{hcard.title}\n" if hcard.properties.include?(:title)
io << "Organization: #{hcard.org}\n" if hcard.properties.include?(:org)
io << "Address: #{format_hcard_adr(hcard.adr)}\n" if hcard.properties.include?(:adr)
if hcards = Prism.find(uri, :hcard)
hcards.each do |hcard|
if hcard
io << "Name: #{hcard.fn.gsub(/\s+/, ' ')}\n" if hcard.properties.include?(:fn)
io << "Title: #{hcard.title}\n" if hcard.properties.include?(:title)
io << "Organization: #{hcard.org}\n" if hcard.properties.include?(:org)
io << "Address: #{hcard_adr(hcard.adr)}\n" if hcard.properties.include?(:adr)
end
end
end
rescue RuntimeError => e
@@ -0,0 +1,73 @@
#!/usr/bin/env ruby -w
libdir = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
require "test/unit"
class TestKnownAccounts < Test::Unit::TestCase
def test_dclinton
expected =<<EOF
OpenID Provider: http://www.google.com/profiles/dclinton
Profile: http://www.google.com/profiles/dclinton
Profile data: http://www-opensocial.googleusercontent.com/api/people/117377434815709898403/
Contacts: http://www-opensocial.googleusercontent.com/api/people/
describedby: http://www.google.com/profiles/dclinton
EOF
assert_equal expected, `bin/webfinger dclinton@gmail.com`
end
def test_romeda
expected =<<EOF
OpenID Provider: http://www.google.com/profiles/romeda
Profile: http://www.google.com/profiles/romeda
Profile data: http://www-opensocial.googleusercontent.com/api/people/113651174506128852447/
Contacts: http://www-opensocial.googleusercontent.com/api/people/
describedby: http://www.google.com/profiles/romeda
EOF
assert_equal expected, `bin/webfinger romeda@gmail.com`
end
def test_bradfitz
expected =<<EOF
OpenID Provider: http://www.google.com/profiles/bradfitz
Profile: http://www.google.com/profiles/bradfitz
Profile data: http://www-opensocial.googleusercontent.com/api/people/115863474911002159675/
Contacts: http://www-opensocial.googleusercontent.com/api/people/
describedby: http://www.google.com/profiles/bradfitz
EOF
assert_equal expected, `bin/webfinger bradfitz@gmail.com`
end
def test_willmeyer
expected =<<EOF
describedby: http://www.google.com/profiles/willmeyer
EOF
assert_equal expected, `bin/webfinger will@willmeyer.com`
end
def test_josephholsten
expected =<<EOF
Name: Joseph Anthony Pasquale Holsten
Address: 5813 East 64th Place Tulsa Oklahoma 74136-2132 USA
OpenID Provider: https://www.myopenid.com/server
Profile: http://josephholsten.com
describedby: http://josephholsten.com
EOF
assert_equal expected, `bin/webfinger joseph@josephholsten.com`
end
# Yahoo webfinger causes my ruby to segfault!
# def test_gffletch
# expected =<<EOF
# assert_equal expected, `bin/webfinger dclinton@yahoo.com`
# assert_equal expected, `bin/webfinger beestage@yahoo.com`
# end
# AOL webfinger now dies at http://www.aol.com/.well-known/host-meta with 503
# RIP
# def test_gffletch
# expected =<<EOF
# assert_equal expected, `bin/webfinger gffletch@aol.com`
# end
end

0 comments on commit b10f87d

Please sign in to comment.