pelle-ruby-openid 2.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +215 -0
- data/CHANGES-2.1.0 +36 -0
- data/INSTALL +47 -0
- data/LICENSE +210 -0
- data/NOTICE +2 -0
- data/README +82 -0
- data/UPGRADE +127 -0
- data/VERSION +1 -0
- data/examples/README +32 -0
- data/examples/active_record_openid_store/README +58 -0
- data/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb +24 -0
- data/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb +26 -0
- data/examples/active_record_openid_store/init.rb +8 -0
- data/examples/active_record_openid_store/lib/association.rb +10 -0
- data/examples/active_record_openid_store/lib/nonce.rb +3 -0
- data/examples/active_record_openid_store/lib/open_id_setting.rb +4 -0
- data/examples/active_record_openid_store/lib/openid_ar_store.rb +57 -0
- data/examples/active_record_openid_store/test/store_test.rb +212 -0
- data/examples/discover +49 -0
- data/examples/rails_openid/README +153 -0
- data/examples/rails_openid/Rakefile +10 -0
- data/examples/rails_openid/app/controllers/application.rb +4 -0
- data/examples/rails_openid/app/controllers/consumer_controller.rb +122 -0
- data/examples/rails_openid/app/controllers/login_controller.rb +45 -0
- data/examples/rails_openid/app/controllers/server_controller.rb +265 -0
- data/examples/rails_openid/app/helpers/application_helper.rb +3 -0
- data/examples/rails_openid/app/helpers/login_helper.rb +2 -0
- data/examples/rails_openid/app/helpers/server_helper.rb +9 -0
- data/examples/rails_openid/app/views/consumer/index.rhtml +81 -0
- data/examples/rails_openid/app/views/layouts/server.rhtml +68 -0
- data/examples/rails_openid/app/views/login/index.rhtml +56 -0
- data/examples/rails_openid/app/views/server/decide.rhtml +26 -0
- data/examples/rails_openid/config/boot.rb +19 -0
- data/examples/rails_openid/config/database.yml +74 -0
- data/examples/rails_openid/config/environment.rb +54 -0
- data/examples/rails_openid/config/environments/development.rb +19 -0
- data/examples/rails_openid/config/environments/production.rb +19 -0
- data/examples/rails_openid/config/environments/test.rb +19 -0
- data/examples/rails_openid/config/routes.rb +24 -0
- data/examples/rails_openid/doc/README_FOR_APP +2 -0
- data/examples/rails_openid/public/.htaccess +40 -0
- data/examples/rails_openid/public/404.html +8 -0
- data/examples/rails_openid/public/500.html +8 -0
- data/examples/rails_openid/public/dispatch.cgi +12 -0
- data/examples/rails_openid/public/dispatch.fcgi +26 -0
- data/examples/rails_openid/public/dispatch.rb +12 -0
- data/examples/rails_openid/public/favicon.ico +0 -0
- data/examples/rails_openid/public/images/openid_login_bg.gif +0 -0
- data/examples/rails_openid/public/javascripts/controls.js +750 -0
- data/examples/rails_openid/public/javascripts/dragdrop.js +584 -0
- data/examples/rails_openid/public/javascripts/effects.js +854 -0
- data/examples/rails_openid/public/javascripts/prototype.js +1785 -0
- data/examples/rails_openid/public/robots.txt +1 -0
- data/examples/rails_openid/script/about +3 -0
- data/examples/rails_openid/script/breakpointer +3 -0
- data/examples/rails_openid/script/console +3 -0
- data/examples/rails_openid/script/destroy +3 -0
- data/examples/rails_openid/script/generate +3 -0
- data/examples/rails_openid/script/performance/benchmarker +3 -0
- data/examples/rails_openid/script/performance/profiler +3 -0
- data/examples/rails_openid/script/plugin +3 -0
- data/examples/rails_openid/script/process/reaper +3 -0
- data/examples/rails_openid/script/process/spawner +3 -0
- data/examples/rails_openid/script/process/spinner +3 -0
- data/examples/rails_openid/script/runner +3 -0
- data/examples/rails_openid/script/server +3 -0
- data/examples/rails_openid/test/functional/login_controller_test.rb +18 -0
- data/examples/rails_openid/test/functional/server_controller_test.rb +18 -0
- data/examples/rails_openid/test/test_helper.rb +28 -0
- data/lib/hmac/hmac.rb +112 -0
- data/lib/hmac/sha1.rb +11 -0
- data/lib/hmac/sha2.rb +25 -0
- data/lib/openid/association.rb +249 -0
- data/lib/openid/consumer/associationmanager.rb +344 -0
- data/lib/openid/consumer/checkid_request.rb +186 -0
- data/lib/openid/consumer/discovery.rb +498 -0
- data/lib/openid/consumer/discovery_manager.rb +123 -0
- data/lib/openid/consumer/html_parse.rb +134 -0
- data/lib/openid/consumer/idres.rb +523 -0
- data/lib/openid/consumer/responses.rb +148 -0
- data/lib/openid/consumer.rb +395 -0
- data/lib/openid/cryptutil.rb +97 -0
- data/lib/openid/dh.rb +89 -0
- data/lib/openid/extension.rb +39 -0
- data/lib/openid/extensions/ax.rb +516 -0
- data/lib/openid/extensions/oauth.rb +91 -0
- data/lib/openid/extensions/pape.rb +179 -0
- data/lib/openid/extensions/sreg.rb +277 -0
- data/lib/openid/extras.rb +11 -0
- data/lib/openid/fetchers.rb +238 -0
- data/lib/openid/kvform.rb +136 -0
- data/lib/openid/kvpost.rb +58 -0
- data/lib/openid/message.rb +553 -0
- data/lib/openid/protocolerror.rb +8 -0
- data/lib/openid/server.rb +1544 -0
- data/lib/openid/store/filesystem.rb +271 -0
- data/lib/openid/store/interface.rb +75 -0
- data/lib/openid/store/memcache.rb +107 -0
- data/lib/openid/store/memory.rb +84 -0
- data/lib/openid/store/nonce.rb +68 -0
- data/lib/openid/trustroot.rb +349 -0
- data/lib/openid/urinorm.rb +75 -0
- data/lib/openid/util.rb +110 -0
- data/lib/openid/yadis/accept.rb +148 -0
- data/lib/openid/yadis/constants.rb +21 -0
- data/lib/openid/yadis/discovery.rb +153 -0
- data/lib/openid/yadis/filters.rb +205 -0
- data/lib/openid/yadis/htmltokenizer.rb +305 -0
- data/lib/openid/yadis/parsehtml.rb +45 -0
- data/lib/openid/yadis/services.rb +42 -0
- data/lib/openid/yadis/xrds.rb +155 -0
- data/lib/openid/yadis/xri.rb +90 -0
- data/lib/openid/yadis/xrires.rb +106 -0
- data/lib/openid.rb +20 -0
- data/setup.rb +1551 -0
- data/test/data/accept.txt +124 -0
- data/test/data/dh.txt +29 -0
- data/test/data/example-xrds.xml +14 -0
- data/test/data/linkparse.txt +587 -0
- data/test/data/n2b64 +650 -0
- data/test/data/test1-discover.txt +137 -0
- data/test/data/test1-parsehtml.txt +152 -0
- data/test/data/test_discover/malformed_meta_tag.html +19 -0
- data/test/data/test_discover/openid.html +11 -0
- data/test/data/test_discover/openid2.html +11 -0
- data/test/data/test_discover/openid2_xrds.xml +12 -0
- data/test/data/test_discover/openid2_xrds_no_local_id.xml +11 -0
- data/test/data/test_discover/openid_1_and_2.html +11 -0
- data/test/data/test_discover/openid_1_and_2_xrds.xml +16 -0
- data/test/data/test_discover/openid_1_and_2_xrds_bad_delegate.xml +17 -0
- data/test/data/test_discover/openid_and_yadis.html +12 -0
- data/test/data/test_discover/openid_no_delegate.html +10 -0
- data/test/data/test_discover/yadis_0entries.xml +12 -0
- data/test/data/test_discover/yadis_2_bad_local_id.xml +15 -0
- data/test/data/test_discover/yadis_2entries_delegate.xml +22 -0
- data/test/data/test_discover/yadis_2entries_idp.xml +21 -0
- data/test/data/test_discover/yadis_another_delegate.xml +14 -0
- data/test/data/test_discover/yadis_idp.xml +12 -0
- data/test/data/test_discover/yadis_idp_delegate.xml +13 -0
- data/test/data/test_discover/yadis_no_delegate.xml +11 -0
- data/test/data/test_xrds/=j3h.2007.11.14.xrds +25 -0
- data/test/data/test_xrds/README +12 -0
- data/test/data/test_xrds/delegated-20060809-r1.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809-r2.xrds +34 -0
- data/test/data/test_xrds/delegated-20060809.xrds +34 -0
- data/test/data/test_xrds/no-xrd.xml +7 -0
- data/test/data/test_xrds/not-xrds.xml +2 -0
- data/test/data/test_xrds/prefixsometimes.xrds +34 -0
- data/test/data/test_xrds/ref.xrds +109 -0
- data/test/data/test_xrds/sometimesprefix.xrds +34 -0
- data/test/data/test_xrds/spoof1.xrds +25 -0
- data/test/data/test_xrds/spoof2.xrds +25 -0
- data/test/data/test_xrds/spoof3.xrds +37 -0
- data/test/data/test_xrds/status222.xrds +9 -0
- data/test/data/test_xrds/subsegments.xrds +58 -0
- data/test/data/test_xrds/valid-populated-xrds.xml +39 -0
- data/test/data/trustroot.txt +153 -0
- data/test/data/urinorm.txt +79 -0
- data/test/discoverdata.rb +131 -0
- data/test/test_accept.rb +170 -0
- data/test/test_association.rb +266 -0
- data/test/test_associationmanager.rb +917 -0
- data/test/test_ax.rb +648 -0
- data/test/test_checkid_request.rb +294 -0
- data/test/test_consumer.rb +257 -0
- data/test/test_cryptutil.rb +119 -0
- data/test/test_dh.rb +86 -0
- data/test/test_discover.rb +838 -0
- data/test/test_discovery_manager.rb +262 -0
- data/test/test_extension.rb +46 -0
- data/test/test_extras.rb +35 -0
- data/test/test_fetchers.rb +538 -0
- data/test/test_filters.rb +270 -0
- data/test/test_idres.rb +963 -0
- data/test/test_kvform.rb +165 -0
- data/test/test_kvpost.rb +65 -0
- data/test/test_linkparse.rb +101 -0
- data/test/test_message.rb +1116 -0
- data/test/test_nonce.rb +89 -0
- data/test/test_oauth.rb +175 -0
- data/test/test_openid_yadis.rb +178 -0
- data/test/test_pape.rb +247 -0
- data/test/test_parsehtml.rb +80 -0
- data/test/test_responses.rb +63 -0
- data/test/test_server.rb +2457 -0
- data/test/test_sreg.rb +479 -0
- data/test/test_stores.rb +298 -0
- data/test/test_trustroot.rb +113 -0
- data/test/test_urinorm.rb +35 -0
- data/test/test_util.rb +145 -0
- data/test/test_xrds.rb +169 -0
- data/test/test_xri.rb +48 -0
- data/test/test_xrires.rb +63 -0
- data/test/test_yadis_discovery.rb +220 -0
- data/test/testutil.rb +127 -0
- data/test/util.rb +53 -0
- metadata +316 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require "openid/yadis/parsehtml"
|
3
|
+
require "testutil"
|
4
|
+
|
5
|
+
module OpenID
|
6
|
+
class ParseHTMLTestCase < Test::Unit::TestCase
|
7
|
+
include OpenID::TestDataMixin
|
8
|
+
|
9
|
+
def test_parsehtml
|
10
|
+
reserved_values = ['None', 'EOF']
|
11
|
+
chunks = read_data_file('test1-parsehtml.txt', false).split("\f\n")
|
12
|
+
test_num = 1
|
13
|
+
|
14
|
+
chunks.each{|c|
|
15
|
+
expected, html = c.split("\n", 2)
|
16
|
+
found = Yadis::html_yadis_location(html)
|
17
|
+
|
18
|
+
assert(!reserved_values.member?(found))
|
19
|
+
|
20
|
+
# this case is a little hard to detect and the distinction
|
21
|
+
# seems unimportant
|
22
|
+
expected = "None" if expected == "EOF"
|
23
|
+
|
24
|
+
found = "None" if found.nil?
|
25
|
+
assert_equal(expected, found, html.split("\n",2)[0])
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# the HTML tokenizer test
|
31
|
+
class TC_TestHTMLTokenizer < Test::Unit::TestCase
|
32
|
+
def test_bad_link
|
33
|
+
toke = HTMLTokenizer.new("<p><a href=http://bad.com/link>foo</a></p>")
|
34
|
+
assert("http://bad.com/link" == toke.getTag("a").attr_hash['href'])
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_namespace
|
38
|
+
toke = HTMLTokenizer.new("<f:table xmlns:f=\"http://www.com/foo\">")
|
39
|
+
assert("http://www.com/foo" == toke.getTag("f:table").attr_hash['xmlns:f'])
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_comment
|
43
|
+
toke = HTMLTokenizer.new("<!-- comment on me -->")
|
44
|
+
t = toke.getNextToken
|
45
|
+
assert(HTMLComment == t.class)
|
46
|
+
assert("comment on me" == t.contents)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_full
|
50
|
+
page = "<HTML>
|
51
|
+
<HEAD>
|
52
|
+
<TITLE>This is the title</TITLE>
|
53
|
+
</HEAD>
|
54
|
+
<!-- Here comes the <a href=\"missing.link\">blah</a>
|
55
|
+
comment body
|
56
|
+
-->
|
57
|
+
<BODY>
|
58
|
+
<H1>This is the header</H1>
|
59
|
+
<P>
|
60
|
+
This is the paragraph, it contains
|
61
|
+
<a href=\"link.html\">links</a>,
|
62
|
+
<img src=\"blah.gif\" optional alt='images
|
63
|
+
are
|
64
|
+
really cool'>. Ok, here is some more text and
|
65
|
+
<A href=\"http://another.link.com/\" target=\"_blank\">another link</A>.
|
66
|
+
</P>
|
67
|
+
</body>
|
68
|
+
</HTML>
|
69
|
+
"
|
70
|
+
toke = HTMLTokenizer.new(page)
|
71
|
+
|
72
|
+
assert("<h1>" == toke.getTag("h1", "h2", "h3").to_s.downcase)
|
73
|
+
assert(HTMLTag.new("<a href=\"link.html\">") == toke.getTag("IMG", "A"))
|
74
|
+
assert("links" == toke.getTrimmedText)
|
75
|
+
assert(toke.getTag("IMG", "A").attr_hash['optional'])
|
76
|
+
assert("_blank" == toke.getTag("IMG", "A").attr_hash['target'])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "openid/consumer/discovery"
|
3
|
+
require "openid/consumer/responses"
|
4
|
+
|
5
|
+
module OpenID
|
6
|
+
class Consumer
|
7
|
+
module TestResponses
|
8
|
+
class TestSuccessResponse < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@endpoint = OpenIDServiceEndpoint.new
|
11
|
+
@endpoint.claimed_id = 'identity_url'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_extension_response
|
15
|
+
q = {
|
16
|
+
'ns.sreg' => 'urn:sreg',
|
17
|
+
'ns.unittest' => 'urn:unittest',
|
18
|
+
'unittest.one' => '1',
|
19
|
+
'unittest.two' => '2',
|
20
|
+
'sreg.nickname' => 'j3h',
|
21
|
+
'return_to' => 'return_to',
|
22
|
+
}
|
23
|
+
signed_list = q.keys.map { |k| 'openid.' + k }
|
24
|
+
msg = Message.from_openid_args(q)
|
25
|
+
resp = SuccessResponse.new(@endpoint, msg, signed_list)
|
26
|
+
utargs = resp.extension_response('urn:unittest', false)
|
27
|
+
assert_equal(utargs, {'one' => '1', 'two' => '2'})
|
28
|
+
sregargs = resp.extension_response('urn:sreg', false)
|
29
|
+
assert_equal(sregargs, {'nickname' => 'j3h'})
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_extension_response_signed
|
33
|
+
args = {
|
34
|
+
'ns.sreg' => 'urn:sreg',
|
35
|
+
'ns.unittest' => 'urn:unittest',
|
36
|
+
'unittest.one' => '1',
|
37
|
+
'unittest.two' => '2',
|
38
|
+
'sreg.nickname' => 'j3h',
|
39
|
+
'sreg.dob' => 'yesterday',
|
40
|
+
'return_to' => 'return_to',
|
41
|
+
'signed' => 'sreg.nickname,unittest.one,sreg.dob',
|
42
|
+
}
|
43
|
+
|
44
|
+
signed_list = ['openid.sreg.nickname',
|
45
|
+
'openid.unittest.one',
|
46
|
+
'openid.sreg.dob',]
|
47
|
+
|
48
|
+
msg = Message.from_openid_args(args)
|
49
|
+
resp = SuccessResponse.new(@endpoint, msg, signed_list)
|
50
|
+
|
51
|
+
# All args in this NS are signed, so expect all.
|
52
|
+
sregargs = resp.extension_response('urn:sreg', true)
|
53
|
+
assert_equal(sregargs, {'nickname' => 'j3h', 'dob' => 'yesterday'})
|
54
|
+
|
55
|
+
# Not all args in this NS are signed, so expect nil when
|
56
|
+
# asking for them.
|
57
|
+
utargs = resp.extension_response('urn:unittest', true)
|
58
|
+
assert_equal(nil, utargs)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|