ruby-openid 1.1.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/INSTALL +0 -9
- data/README +21 -22
- data/UPGRADE +117 -0
- data/admin/runtests.rb +36 -0
- data/examples/README +13 -21
- data/examples/active_record_openid_store/README +8 -3
- data/examples/active_record_openid_store/XXX_add_open_id_store_to_db.rb +4 -8
- data/examples/active_record_openid_store/XXX_upgrade_open_id_store.rb +26 -0
- data/examples/active_record_openid_store/lib/association.rb +2 -0
- data/examples/active_record_openid_store/lib/openid_ar_store.rb +22 -47
- data/examples/active_record_openid_store/test/store_test.rb +78 -48
- data/examples/discover +46 -0
- data/examples/{rails_server → rails_openid}/README +0 -0
- data/examples/{rails_server → rails_openid}/Rakefile +0 -0
- data/examples/{rails_server → rails_openid}/app/controllers/application.rb +0 -0
- data/examples/rails_openid/app/controllers/consumer_controller.rb +115 -0
- data/examples/{rails_server → rails_openid}/app/controllers/login_controller.rb +10 -2
- data/examples/rails_openid/app/controllers/server_controller.rb +265 -0
- data/examples/{rails_server → rails_openid}/app/helpers/application_helper.rb +0 -0
- data/examples/{rails_server → rails_openid}/app/helpers/login_helper.rb +0 -0
- data/examples/{rails_server → rails_openid}/app/helpers/server_helper.rb +0 -0
- data/examples/rails_openid/app/views/consumer/index.rhtml +81 -0
- data/examples/rails_openid/app/views/consumer/start.rhtml +8 -0
- data/examples/{rails_server → rails_openid}/app/views/layouts/server.rhtml +0 -0
- data/examples/{rails_server → rails_openid}/app/views/login/index.rhtml +1 -1
- data/examples/rails_openid/app/views/server/decide.rhtml +26 -0
- data/examples/{rails_server → rails_openid}/config/boot.rb +0 -0
- data/examples/{rails_server → rails_openid}/config/database.yml +0 -0
- data/examples/{rails_server → rails_openid}/config/environment.rb +0 -0
- data/examples/{rails_server → rails_openid}/config/environments/development.rb +0 -0
- data/examples/{rails_server → rails_openid}/config/environments/production.rb +0 -0
- data/examples/{rails_server → rails_openid}/config/environments/test.rb +0 -0
- data/examples/{rails_server → rails_openid}/config/routes.rb +2 -1
- data/examples/{rails_server → rails_openid}/doc/README_FOR_APP +0 -0
- data/examples/{rails_server → rails_openid}/public/404.html +0 -0
- data/examples/{rails_server → rails_openid}/public/500.html +0 -0
- data/examples/{rails_server → rails_openid}/public/dispatch.cgi +0 -0
- data/examples/{rails_server → rails_openid}/public/dispatch.fcgi +0 -0
- data/examples/{rails_server → rails_openid}/public/dispatch.rb +0 -0
- data/examples/{rails_server → rails_openid}/public/favicon.ico +0 -0
- data/examples/rails_openid/public/images/openid_login_bg.gif +0 -0
- data/examples/{rails_server → rails_openid}/public/javascripts/controls.js +0 -0
- data/examples/{rails_server → rails_openid}/public/javascripts/dragdrop.js +0 -0
- data/examples/{rails_server → rails_openid}/public/javascripts/effects.js +0 -0
- data/examples/{rails_server → rails_openid}/public/javascripts/prototype.js +0 -0
- data/examples/{rails_server → rails_openid}/public/robots.txt +0 -0
- data/examples/{rails_server → rails_openid}/script/about +0 -0
- data/examples/{rails_server → rails_openid}/script/breakpointer +0 -0
- data/examples/{rails_server → rails_openid}/script/console +0 -0
- data/examples/{rails_server → rails_openid}/script/destroy +0 -0
- data/examples/{rails_server → rails_openid}/script/generate +0 -0
- data/examples/{rails_server → rails_openid}/script/performance/benchmarker +0 -0
- data/examples/{rails_server → rails_openid}/script/performance/profiler +0 -0
- data/examples/{rails_server → rails_openid}/script/plugin +0 -0
- data/examples/{rails_server → rails_openid}/script/process/reaper +0 -0
- data/examples/{rails_server → rails_openid}/script/process/spawner +0 -0
- data/examples/{rails_server → rails_openid}/script/process/spinner +0 -0
- data/examples/{rails_server → rails_openid}/script/runner +0 -0
- data/examples/{rails_server → rails_openid}/script/server +0 -0
- data/examples/{rails_server → rails_openid}/test/functional/login_controller_test.rb +0 -0
- data/examples/{rails_server → rails_openid}/test/functional/server_controller_test.rb +0 -0
- data/examples/{rails_server → rails_openid}/test/test_helper.rb +0 -0
- data/lib/{hmac.rb → hmac/hmac.rb} +0 -0
- data/lib/{hmac-sha1.rb → hmac/sha1.rb} +1 -1
- data/lib/{hmac-sha2.rb → hmac/sha2.rb} +1 -1
- data/lib/openid/association.rb +213 -73
- data/lib/openid/consumer/associationmanager.rb +338 -0
- data/lib/openid/consumer/checkid_request.rb +175 -0
- data/lib/openid/consumer/discovery.rb +480 -0
- data/lib/openid/consumer/discovery_manager.rb +123 -0
- data/lib/openid/consumer/html_parse.rb +136 -0
- data/lib/openid/consumer/idres.rb +525 -0
- data/lib/openid/consumer/responses.rb +133 -0
- data/lib/openid/consumer.rb +280 -807
- data/lib/openid/cryptutil.rb +85 -0
- data/lib/openid/dh.rb +60 -23
- data/lib/openid/extension.rb +31 -0
- data/lib/openid/extensions/ax.rb +506 -0
- data/lib/openid/extensions/pape.rb +182 -0
- data/lib/openid/extensions/sreg.rb +275 -0
- data/lib/openid/extras.rb +11 -0
- data/lib/openid/fetchers.rb +132 -93
- data/lib/openid/kvform.rb +133 -0
- data/lib/openid/kvpost.rb +56 -0
- data/lib/openid/message.rb +534 -0
- data/lib/openid/protocolerror.rb +6 -0
- data/lib/openid/server.rb +1215 -666
- data/lib/openid/store/filesystem.rb +271 -0
- data/lib/openid/store/interface.rb +75 -0
- data/lib/openid/store/memory.rb +84 -0
- data/lib/openid/store/nonce.rb +68 -0
- data/lib/openid/trustroot.rb +314 -87
- data/lib/openid/urinorm.rb +37 -34
- data/lib/openid/util.rb +42 -220
- 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/{htmltokenizer.rb → yadis/htmltokenizer.rb} +1 -54
- data/lib/openid/yadis/parsehtml.rb +36 -0
- data/lib/openid/yadis/services.rb +42 -0
- data/lib/openid/yadis/xrds.rb +171 -0
- data/lib/openid/yadis/xri.rb +90 -0
- data/lib/openid/yadis/xrires.rb +106 -0
- data/lib/openid.rb +1 -4
- 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 +128 -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/valid-populated-xrds.xml +39 -0
- data/test/data/trustroot.txt +147 -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 +899 -0
- data/test/test_ax.rb +587 -0
- data/test/test_checkid_request.rb +297 -0
- data/test/test_consumer.rb +257 -0
- data/test/test_cryptutil.rb +117 -0
- data/test/test_dh.rb +86 -0
- data/test/test_discover.rb +772 -0
- data/test/test_discovery_manager.rb +262 -0
- data/test/test_extras.rb +35 -0
- data/test/test_fetchers.rb +472 -0
- data/test/test_filters.rb +270 -0
- data/test/test_idres.rb +816 -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 +1058 -0
- data/test/test_nonce.rb +89 -0
- data/test/test_openid_yadis.rb +178 -0
- data/test/test_pape.rb +233 -0
- data/test/test_parsehtml.rb +80 -0
- data/test/test_responses.rb +63 -0
- data/test/test_server.rb +2270 -0
- data/test/test_sreg.rb +479 -0
- data/test/test_stores.rb +269 -0
- data/test/test_trustroot.rb +112 -0
- data/test/{urinorm.rb → test_urinorm.rb} +6 -3
- data/test/test_util.rb +144 -0
- data/test/test_xrds.rb +160 -0
- data/test/test_xri.rb +48 -0
- data/test/test_xrires.rb +63 -0
- data/test/test_yadis_discovery.rb +207 -0
- data/test/testutil.rb +116 -0
- data/test/util.rb +47 -50
- metadata +233 -143
- data/examples/consumer.rb +0 -290
- data/examples/rails_openid_login_generator/openid_login_generator-0.1.gem +0 -0
- data/examples/rails_server/app/controllers/server_controller.rb +0 -190
- data/examples/rails_server/app/views/server/decide.rhtml +0 -11
- data/examples/rails_server/public/images/rails.png +0 -0
- data/lib/hmac-md5.rb +0 -11
- data/lib/hmac-rmd160.rb +0 -11
- data/lib/openid/discovery.rb +0 -122
- data/lib/openid/filestore.rb +0 -315
- data/lib/openid/parse.rb +0 -23
- data/lib/openid/service.rb +0 -147
- data/lib/openid/stores.rb +0 -178
- data/test/assoc.rb +0 -38
- data/test/consumer.rb +0 -376
- data/test/data/brian.xrds +0 -16
- data/test/data/brianellin.mylid.xrds +0 -42
- data/test/dh.rb +0 -20
- data/test/extensions.rb +0 -30
- data/test/linkparse.rb +0 -305
- data/test/runtests.rb +0 -22
- data/test/server2.rb +0 -1053
- data/test/service.rb +0 -47
- data/test/storetestcase.rb +0 -172
- data/test/teststore.rb +0 -47
- data/test/trustroot.rb +0 -117
data/test/service.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require "openid/service"
|
|
3
|
-
|
|
4
|
-
class FakeYadis
|
|
5
|
-
|
|
6
|
-
def uri
|
|
7
|
-
return ''
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def xrds_uri
|
|
11
|
-
''
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
class OpenIDServiceEndpointTestCase < Test::Unit::TestCase
|
|
17
|
-
|
|
18
|
-
def test_parse
|
|
19
|
-
File.open('data/brian.xrds') do |f|
|
|
20
|
-
xrds = XRDS.new(f.read)
|
|
21
|
-
assert_not_nil(xrds)
|
|
22
|
-
assert_equal(xrds.services.length, 1)
|
|
23
|
-
|
|
24
|
-
service = xrds.services[0]
|
|
25
|
-
service.yadis = FakeYadis.new
|
|
26
|
-
|
|
27
|
-
openid_service = OpenID::OpenIDServiceEndpoint.from_endpoint(service)
|
|
28
|
-
assert_not_nil(openid_service)
|
|
29
|
-
assert_equal(openid_service.server_url, 'http://www.myopenid.com/server')
|
|
30
|
-
end
|
|
31
|
-
File.open('data/brianellin.mylid.xrds') do |f|
|
|
32
|
-
xrds = XRDS.new(f.read)
|
|
33
|
-
assert_not_nil(xrds)
|
|
34
|
-
assert_equal(xrds.services.length, 9)
|
|
35
|
-
|
|
36
|
-
service = xrds.services[8]
|
|
37
|
-
assert_not_nil(service)
|
|
38
|
-
service.yadis = FakeYadis.new
|
|
39
|
-
|
|
40
|
-
openid_service = OpenID::OpenIDServiceEndpoint.from_endpoint(service)
|
|
41
|
-
assert_not_nil(openid_service)
|
|
42
|
-
assert_equal(openid_service.server_url, 'http://mylid.net/brianellin')
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
|
data/test/storetestcase.rb
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
require 'openid/util'
|
|
2
|
-
require 'openid/association'
|
|
3
|
-
|
|
4
|
-
module StoreTestCase
|
|
5
|
-
|
|
6
|
-
@@allowed_handle = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
|
|
7
|
-
@@allowed_nonce = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
8
|
-
|
|
9
|
-
def _gen_nonce
|
|
10
|
-
OpenID::Util.random_string(8, @@allowed_nonce)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def _gen_handle(n)
|
|
14
|
-
OpenID::Util.random_string(n, @@allowed_handle)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def _gen_secret(n, chars=nil)
|
|
18
|
-
OpenID::Util.random_string(n, chars)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def _gen_assoc(issued, lifetime=600)
|
|
22
|
-
secret = _gen_secret(20)
|
|
23
|
-
handle = _gen_handle(128)
|
|
24
|
-
OpenID::Association.new(handle, secret, Time.now.to_i + issued, lifetime,
|
|
25
|
-
'HMAC-SHA1')
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def _check_retrieve(url, handle=nil, expected=nil)
|
|
29
|
-
ret_assoc = @store.get_association(url, handle)
|
|
30
|
-
|
|
31
|
-
if expected.nil? or @store.dumb?
|
|
32
|
-
assert_nil(ret_assoc)
|
|
33
|
-
else
|
|
34
|
-
assert_equal(ret_assoc, expected)
|
|
35
|
-
assert_equal(ret_assoc.handle, expected.handle)
|
|
36
|
-
assert_equal(ret_assoc.secret, expected.secret)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def _check_remove(url, handle, expected)
|
|
41
|
-
present = @store.remove_association(url, handle)
|
|
42
|
-
expected_present = ((not @store.dumb?) and expected)
|
|
43
|
-
assert ((not expected_present and not present) or \
|
|
44
|
-
(expected_present and present))
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_store
|
|
48
|
-
server_url = "http://www.myopenid.com/openid"
|
|
49
|
-
assoc = _gen_assoc(issued=0)
|
|
50
|
-
|
|
51
|
-
# Make sure that a missing association returns no result
|
|
52
|
-
_check_retrieve(server_url)
|
|
53
|
-
|
|
54
|
-
# Check that after storage, getting returns the same result
|
|
55
|
-
@store.store_association(server_url, assoc)
|
|
56
|
-
_check_retrieve(server_url, nil, assoc)
|
|
57
|
-
|
|
58
|
-
# more than once
|
|
59
|
-
_check_retrieve(server_url, nil, assoc)
|
|
60
|
-
|
|
61
|
-
# Storing more than once has no ill effect
|
|
62
|
-
@store.store_association(server_url, assoc)
|
|
63
|
-
_check_retrieve(server_url, nil, assoc)
|
|
64
|
-
|
|
65
|
-
# Removing an association that does not exist returns not present
|
|
66
|
-
_check_remove(server_url, assoc.handle + 'x', false)
|
|
67
|
-
|
|
68
|
-
# Removing an association that does not exist returns not present
|
|
69
|
-
_check_remove(server_url + 'x', assoc.handle, false)
|
|
70
|
-
|
|
71
|
-
# Removing an association that is present returns present
|
|
72
|
-
_check_remove(server_url, assoc.handle, true)
|
|
73
|
-
|
|
74
|
-
# but not present on subsequent calls
|
|
75
|
-
_check_remove(server_url, assoc.handle, false)
|
|
76
|
-
|
|
77
|
-
# Put assoc back in the store
|
|
78
|
-
@store.store_association(server_url, assoc)
|
|
79
|
-
|
|
80
|
-
# More recent and expires after assoc
|
|
81
|
-
assoc2 = _gen_assoc(issued=1)
|
|
82
|
-
@store.store_association(server_url, assoc2)
|
|
83
|
-
|
|
84
|
-
# After storing an association with a different handle, but the
|
|
85
|
-
# same server_url, the handle with the later expiration is returned.
|
|
86
|
-
_check_retrieve(server_url, nil, assoc2)
|
|
87
|
-
|
|
88
|
-
# We can still retrieve the older association
|
|
89
|
-
_check_retrieve(server_url, assoc.handle, assoc)
|
|
90
|
-
|
|
91
|
-
# Plus we can retrieve the association with the later expiration
|
|
92
|
-
# explicitly
|
|
93
|
-
_check_retrieve(server_url, assoc2.handle, assoc2)
|
|
94
|
-
|
|
95
|
-
# More recent, and expires earlier than assoc2 or assoc. Make sure
|
|
96
|
-
# that we're picking the one with the latest issued date and not
|
|
97
|
-
# taking into account the expiration.
|
|
98
|
-
assoc3 = _gen_assoc(issued=2, lifetime=100)
|
|
99
|
-
@store.store_association(server_url, assoc3)
|
|
100
|
-
|
|
101
|
-
_check_retrieve(server_url, nil, assoc3)
|
|
102
|
-
_check_retrieve(server_url, assoc.handle, assoc)
|
|
103
|
-
_check_retrieve(server_url, assoc2.handle, assoc2)
|
|
104
|
-
_check_retrieve(server_url, assoc3.handle, assoc3)
|
|
105
|
-
|
|
106
|
-
_check_remove(server_url, assoc2.handle, true)
|
|
107
|
-
|
|
108
|
-
_check_retrieve(server_url, nil, assoc3)
|
|
109
|
-
_check_retrieve(server_url, assoc.handle, assoc)
|
|
110
|
-
_check_retrieve(server_url, assoc2.handle, nil)
|
|
111
|
-
_check_retrieve(server_url, assoc3.handle, assoc3)
|
|
112
|
-
|
|
113
|
-
_check_remove(server_url, assoc2.handle, false)
|
|
114
|
-
_check_remove(server_url, assoc3.handle, true)
|
|
115
|
-
|
|
116
|
-
_check_retrieve(server_url, nil, assoc)
|
|
117
|
-
_check_retrieve(server_url, assoc.handle, assoc)
|
|
118
|
-
_check_retrieve(server_url, assoc2.handle, nil)
|
|
119
|
-
_check_retrieve(server_url, assoc3.handle, nil)
|
|
120
|
-
|
|
121
|
-
_check_remove(server_url, assoc2.handle, false)
|
|
122
|
-
_check_remove(server_url, assoc.handle, true)
|
|
123
|
-
_check_remove(server_url, assoc3.handle, false)
|
|
124
|
-
|
|
125
|
-
_check_retrieve(server_url, nil, nil)
|
|
126
|
-
_check_retrieve(server_url, assoc.handle, nil)
|
|
127
|
-
_check_retrieve(server_url, assoc2.handle, nil)
|
|
128
|
-
_check_retrieve(server_url, assoc3.handle, nil)
|
|
129
|
-
|
|
130
|
-
_check_remove(server_url, assoc2.handle, false)
|
|
131
|
-
_check_remove(server_url, assoc.handle, false)
|
|
132
|
-
_check_remove(server_url, assoc3.handle, false)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def test_nonce
|
|
136
|
-
nonce1 = _gen_nonce
|
|
137
|
-
|
|
138
|
-
assert_not_nil(nonce1)
|
|
139
|
-
|
|
140
|
-
# a nonce is present by default
|
|
141
|
-
present = @store.use_nonce(nonce1)
|
|
142
|
-
assert_equal(present, false)
|
|
143
|
-
|
|
144
|
-
# Storing once causes use_nonce to return true the first, and only
|
|
145
|
-
# the first, time it is called after the store.
|
|
146
|
-
@store.store_nonce(nonce1)
|
|
147
|
-
present = @store.use_nonce(nonce1)
|
|
148
|
-
assert present
|
|
149
|
-
present = @store.use_nonce(nonce1)
|
|
150
|
-
assert_equal(present, false)
|
|
151
|
-
|
|
152
|
-
# Storing twice has the same effect as storing once.
|
|
153
|
-
@store.store_nonce(nonce1)
|
|
154
|
-
@store.store_nonce(nonce1)
|
|
155
|
-
present = @store.use_nonce(nonce1)
|
|
156
|
-
assert present
|
|
157
|
-
present = @store.use_nonce(nonce1)
|
|
158
|
-
assert_equal(present, false)
|
|
159
|
-
|
|
160
|
-
### Auth key stuff
|
|
161
|
-
|
|
162
|
-
# there is no key to start with, so generate a new key and return it
|
|
163
|
-
key = @store.get_auth_key
|
|
164
|
-
|
|
165
|
-
# the second time we should return the same key as before
|
|
166
|
-
key2 = @store.get_auth_key
|
|
167
|
-
assert key == key2
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
|
data/test/teststore.rb
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
require 'pathname'
|
|
4
|
-
require 'tmpdir'
|
|
5
|
-
|
|
6
|
-
require 'openid/filestore'
|
|
7
|
-
require 'storetestcase'
|
|
8
|
-
|
|
9
|
-
class FileStoreTestCase < Test::Unit::TestCase
|
|
10
|
-
include StoreTestCase
|
|
11
|
-
|
|
12
|
-
@@dir = Pathname.new(Dir.tmpdir).join('filstoretest')
|
|
13
|
-
|
|
14
|
-
def setup
|
|
15
|
-
FileUtils.rm_rf(@@dir)
|
|
16
|
-
@store = OpenID::FilesystemStore.new(@@dir)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def teardown
|
|
20
|
-
FileUtils.rm_rf(@@dir)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class DumbStoreTestCase < Test::Unit::TestCase
|
|
25
|
-
include StoreTestCase
|
|
26
|
-
|
|
27
|
-
def setup
|
|
28
|
-
@store = OpenID::DumbStore.new('unit-test')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_nonce
|
|
32
|
-
assert_equal(true, @store.use_nonce('anything'))
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class MemoryStoreTestCase < Test::Unit::TestCase
|
|
38
|
-
include StoreTestCase
|
|
39
|
-
|
|
40
|
-
@@dir = Pathname.new(Dir.tmpdir).join('filstoretest')
|
|
41
|
-
|
|
42
|
-
def setup
|
|
43
|
-
@store = OpenID::MemoryStore.new
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
end
|
|
47
|
-
|
data/test/trustroot.rb
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'openid/trustroot'
|
|
3
|
-
|
|
4
|
-
class TrustRootTestCase < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
def test_parse_bad
|
|
7
|
-
|
|
8
|
-
def assert_bad(s)
|
|
9
|
-
tr = OpenID::TrustRoot.parse(s)
|
|
10
|
-
assert_nil(tr)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
assert_bad('baz.org')
|
|
14
|
-
assert_bad('*.foo.com')
|
|
15
|
-
assert_bad('http://*.schtuff.*/')
|
|
16
|
-
assert_bad('ftp://foo.com')
|
|
17
|
-
assert_bad('ftp://*.foo.com')
|
|
18
|
-
assert_bad('http://*.foo.com:80:90/')
|
|
19
|
-
assert_bad('foo.*.com')
|
|
20
|
-
assert_bad('http://foo.*.com')
|
|
21
|
-
assert_bad('http://www.*')
|
|
22
|
-
assert_bad('')
|
|
23
|
-
assert_bad(' ')
|
|
24
|
-
assert_bad(' \t\n ')
|
|
25
|
-
assert_bad(nil)
|
|
26
|
-
assert_bad(5)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_parse_good
|
|
30
|
-
|
|
31
|
-
def assert_good(s)
|
|
32
|
-
tr = OpenID::TrustRoot.parse(s)
|
|
33
|
-
assert_not_nil(tr)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
assert_good('http://*/')
|
|
37
|
-
assert_good('https://*/')
|
|
38
|
-
assert_good('http://*.schtuff.com/')
|
|
39
|
-
assert_good('http://*.schtuff.com')
|
|
40
|
-
assert_good('http://www.schtuff.com/')
|
|
41
|
-
assert_good('http://www.schtuff.com')
|
|
42
|
-
assert_good('http://*.this.that.schtuff.com/')
|
|
43
|
-
assert_good('http://*.com/')
|
|
44
|
-
assert_good('http://*.com')
|
|
45
|
-
assert_good('http://*.foo.com/path')
|
|
46
|
-
assert_good('http://x.foo.com/path?action=foo2')
|
|
47
|
-
assert_good('http://*.foo.com/path?action=foo2')
|
|
48
|
-
assert_good('http://localhost:8081/')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def test_sane
|
|
52
|
-
|
|
53
|
-
def assert_sane(s, expected)
|
|
54
|
-
tr = OpenID::TrustRoot.parse(s)
|
|
55
|
-
assert_not_nil(tr)
|
|
56
|
-
assert_equal(tr.sane?, expected, s)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
assert_sane('http://*/', false)
|
|
60
|
-
assert_sane('https://*/', false)
|
|
61
|
-
assert_sane('http://*.schtuff.com/', true)
|
|
62
|
-
assert_sane('http://*.foo.schtuff.com/', true)
|
|
63
|
-
assert_sane('http://*.com/', false)
|
|
64
|
-
assert_sane('http://*.com.au/', false)
|
|
65
|
-
assert_sane('http://*.co.uk/', false)
|
|
66
|
-
assert_sane('http://localhost:8082/?action=openid', true)
|
|
67
|
-
assert_sane('http://*.foo.notatld', false)
|
|
68
|
-
assert_sane('http://*.museum/', false)
|
|
69
|
-
assert_sane('http://kink.fm/', true)
|
|
70
|
-
assert_sane('http://beta.lingu.no/', true)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def test_validate
|
|
74
|
-
|
|
75
|
-
def assert_valid(s, url, expected)
|
|
76
|
-
tr = OpenID::TrustRoot.parse(s)
|
|
77
|
-
assert_not_nil(tr)
|
|
78
|
-
assert_equal(tr.sane?, true)
|
|
79
|
-
assert_equal(tr.validate_url(url), expected)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
assert_valid('http://*.foo.com', 'http://foo.com', true)
|
|
83
|
-
assert_valid('http://*.foo.com/', 'http://foo.com/', true)
|
|
84
|
-
assert_valid('http://*.foo.com', 'http://b.foo.com', true)
|
|
85
|
-
assert_valid('http://*.foo.com', 'http://b.foo.com/', true)
|
|
86
|
-
assert_valid('http://*.foo.com', 'http://b.foo.com/', true)
|
|
87
|
-
assert_valid('http://*.foo.com', 'http://b.foo.com', true)
|
|
88
|
-
assert_valid('http://*.b.foo.com', 'http://b.foo.com', true)
|
|
89
|
-
assert_valid('http://*.b.foo.com', 'http://x.b.foo.com', true)
|
|
90
|
-
assert_valid('http://*.bar.co.uk', 'http://www.bar.co.uk', true)
|
|
91
|
-
assert_valid('http://*.uoregon.edu', 'http://x.cs.uoregon.edu', true)
|
|
92
|
-
|
|
93
|
-
assert_valid('http://*.cs.uoregon.edu', 'http://x.uoregon.edu', false)
|
|
94
|
-
assert_valid('http://*.foo.com', 'http://bar.com', false)
|
|
95
|
-
assert_valid('http://*.foo.com', 'http://www.bar.com', false)
|
|
96
|
-
assert_valid('http://*.bar.co.uk', 'http://xxx.co.uk', false)
|
|
97
|
-
|
|
98
|
-
# path validity
|
|
99
|
-
assert_valid('http://x.com/abc', 'http://x.com/', false)
|
|
100
|
-
assert_valid('http://x.com/abc', 'http://x.com/a', false)
|
|
101
|
-
assert_valid('http://*.x.com/abc', 'http://foo.x.com/abc', true)
|
|
102
|
-
assert_valid('http://*.x.com/abc', 'http://foo.x.com', false)
|
|
103
|
-
assert_valid('http://*.x.com', 'http://foo.x.com/gallery', true)
|
|
104
|
-
assert_valid('http://foo.x.com', 'http://foo.x.com/gallery', true)
|
|
105
|
-
assert_valid('http://foo.x.com/gallery', 'http://foo.x.com/gallery/xxx', true)
|
|
106
|
-
assert_valid('http://localhost:8081/x?action=openid',
|
|
107
|
-
'http://localhost:8081/x?action=openid', true)
|
|
108
|
-
assert_valid('http://*.x.com/gallery', 'http://foo.x.com/gallery', true)
|
|
109
|
-
|
|
110
|
-
assert_valid('http://localhost:8082/?action=openid',
|
|
111
|
-
'http://localhost:8082/?action=openid', true)
|
|
112
|
-
assert_valid('http://goathack.livejournal.org:8020/',
|
|
113
|
-
'http://goathack.livejournal.org:8020/openid/login.bml', true)
|
|
114
|
-
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
end
|