Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[project @ whitespace]

Ignore-this: a69795c5131e0cf6f687ccc8dfbba61a
  • Loading branch information...
commit 32b73cf8c206a7ff6bbbbe24e3fb68d8cfe29a2a 1 parent 4c8e6af
tailor authored
Showing with 17 additions and 20 deletions.
  1. +0 −1  admin/runtests.rb
  2. +17 −19 test/test_stores.rb
View
1  admin/runtests.rb
@@ -26,7 +26,6 @@ def main
suite = c.collect(tests_dir)
end
-
result = Test::Unit::UI::Console::TestRunner.run(suite)
result.passed?
ensure
View
36 test/test_stores.rb
@@ -11,7 +11,7 @@ module Store
module StoreTestCase
@@allowed_handle = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
@@allowed_nonce = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
+
def _gen_nonce
OpenID::CryptUtil.random_string(8, @@allowed_nonce)
end
@@ -28,9 +28,9 @@ def _gen_assoc(issued, lifetime=600)
secret = _gen_secret(20)
handle = _gen_handle(128)
OpenID::Association.new(handle, secret, Time.now + issued, lifetime,
- 'HMAC-SHA1')
+ 'HMAC-SHA1')
end
-
+
def _check_retrieve(url, handle=nil, expected=nil)
ret_assoc = @store.get_association(url, handle)
@@ -161,10 +161,10 @@ def test_nonce
[server_url, ''].each{|url|
nonce1 = Nonce::mk_nonce
- _check_use_nonce(nonce1, true, url, "#{url}: nonce allowed by default")
- _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed twice")
+ _check_use_nonce(nonce1, true, url, "#{url}: nonce allowed by default")
+ _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed twice")
_check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed third time")
-
+
# old nonces shouldn't pass
old_nonce = Nonce::mk_nonce(3600)
_check_use_nonce(old_nonce, false, url, "Old nonce #{old_nonce.inspect} passed")
@@ -187,7 +187,6 @@ def test_nonce
ts, salt = Nonce::split_nonce(recent_nonce)
assert(@store.use_nonce(server_url, ts, salt), "recent_nonce")
-
Nonce.skew = 1000
cleaned = @store.cleanup_nonces
assert_equal(2, cleaned, "Cleaned #{cleaned} nonces")
@@ -204,7 +203,7 @@ def test_nonce
end
end
-
+
class FileStoreTestCase < Test::Unit::TestCase
include StoreTestCase
@@ -220,7 +219,7 @@ def teardown
class MemoryStoreTestCase < Test::Unit::TestCase
include StoreTestCase
-
+
def setup
@store = Memory.new
end
@@ -232,38 +231,37 @@ def test_abstract_class
abc = Interface.new()
server_url = "http://server.com/"
association = OpenID::Association.new("foo", "bar", Time.now, Time.now + 10, "dummy")
-
- assert_raise(NotImplementedError) {
+
+ assert_raise(NotImplementedError) {
abc.store_association(server_url, association)
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.get_association(server_url)
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.remove_association(server_url, association.handle)
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.use_nonce(server_url, Time.now.to_i, "foo")
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.cleanup_nonces()
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.cleanup_associations()
}
- assert_raise(NotImplementedError) {
+ assert_raise(NotImplementedError) {
abc.cleanup()
}
-
+
end
end
end
end
-
Please sign in to comment.
Something went wrong with that request. Please try again.