Skip to content

Commit

Permalink
Fix bug in MockFetcherForXRIProxy that was breaking unit test. Also r…
Browse files Browse the repository at this point in the history
…efactor test iname into constant.
  • Loading branch information
Joseph Chen committed Mar 27, 2012
1 parent 57ecdc8 commit 898963d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/test_discover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def fetch(url, body=nil, headers=nil, limit=nil)
end

begin
ctype, body = @documents.fetch(xri)
ctype, body = @documents.fetch(URI::unescape(xri))
rescue IndexError
status = 404
ctype = 'text/plain'
Expand All @@ -548,19 +548,21 @@ class TestXRIDiscovery < BaseTestDiscovery
include TestDataMixin
include TestUtil

TEST_INAME = "=smoker"

def initialize(*args)
super(*args)

@fetcher_class = MockFetcherForXRIProxy

@documents = {'=smoker' => ['application/xrds+xml',
@documents = {TEST_INAME => ['application/xrds+xml',
read_data_file('test_discover/yadis_2entries_delegate.xml', false)],
'=smoker*bad' => ['application/xrds+xml',
"#{TEST_INAME}*bad" => ['application/xrds+xml',
read_data_file('test_discover/yadis_another_delegate.xml', false)]}
end

def test_xri
user_xri, services = OpenID.discover_xri('=smoker')
user_xri, services = OpenID.discover_xri(TEST_INAME)

_checkService(services[0],
"http://www.myopenid.com/server",
Expand All @@ -569,7 +571,7 @@ def test_xri
Yadis::XRI.make_xri("=!1000"),
['1.0'],
true,
'=smoker')
TEST_INAME)

_checkService(services[1],
"http://www.livejournal.com/openid/server.bml",
Expand All @@ -578,11 +580,11 @@ def test_xri
Yadis::XRI.make_xri("=!1000"),
['1.0'],
true,
'=smoker')
TEST_INAME)
end

def test_xri_normalize
user_xri, services = OpenID.discover_xri('xri://=smoker')
user_xri, services = OpenID.discover_xri("xri://#{TEST_INAME}")

_checkService(services[0],
"http://www.myopenid.com/server",
Expand All @@ -591,7 +593,7 @@ def test_xri_normalize
Yadis::XRI.make_xri("=!1000"),
['1.0'],
true,
'=smoker')
TEST_INAME)

_checkService(services[1],
"http://www.livejournal.com/openid/server.bml",
Expand All @@ -600,12 +602,12 @@ def test_xri_normalize
Yadis::XRI.make_xri("=!1000"),
['1.0'],
true,
'=smoker')
TEST_INAME)
end

def test_xriNoCanonicalID
silence_logging {
user_xri, services = OpenID.discover_xri('=smoker*bad')
user_xri, services = OpenID.discover_xri("#{TEST_INAME}*bad")
assert(services.empty?)
}
end
Expand All @@ -623,17 +625,19 @@ def test_useCanonicalID
class TestXRIDiscoveryIDP < BaseTestDiscovery
include TestDataMixin

TEST_INAME = "=smoker"

def initialize(*args)
super(*args)

@fetcher_class = MockFetcherForXRIProxy

@documents = {'=smoker' => ['application/xrds+xml',
@documents = {TEST_INAME => ['application/xrds+xml',
read_data_file('test_discover/yadis_2entries_idp.xml', false)] }
end

def test_xri
user_xri, services = OpenID.discover_xri('=smoker')
user_xri, services = OpenID.discover_xri(TEST_INAME)
assert(!services.empty?, "Expected services, got zero")
assert_equal(services[0].server_url,
"http://www.livejournal.com/openid/server.bml")
Expand Down

0 comments on commit 898963d

Please sign in to comment.