openid_mongodb_store 0.2.1 → 0.2.2
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/VERSION +1 -1
- data/lib/openid_mongodb_store/store.rb +8 -2
- data/openid_mongodb_store.gemspec +2 -2
- data/test/helper.rb +10 -13
- data/test/test_openid_mongodb_store.rb +10 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -19,14 +19,20 @@ class OpenidMongodbStore::Store < OpenID::Store::Interface
|
|
19
19
|
def store_association(server_url, association)
|
20
20
|
remove_association(server_url, association.handle)
|
21
21
|
|
22
|
+
issued = if association.issued.to_s =~ /\A\d+\Z/
|
23
|
+
association.issued
|
24
|
+
else
|
25
|
+
Time.parse(association.issued).to_i
|
26
|
+
end
|
27
|
+
|
22
28
|
secret = BSON::Binary.new(association.secret)
|
23
29
|
associations.insert('server_url' => server_url,
|
24
30
|
'handle' => association.handle,
|
25
31
|
'secret' => secret,
|
26
|
-
'issued' =>
|
32
|
+
'issued' => issued,
|
27
33
|
'lifetime' => association.lifetime,
|
28
34
|
'assoc_type' => association.assoc_type,
|
29
|
-
'expire_at' => (
|
35
|
+
'expire_at' => (issued + association.lifetime))
|
30
36
|
end
|
31
37
|
|
32
38
|
def get_association(server_url, handle=nil)
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{openid_mongodb_store}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sam Schenkman-Moore"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-01}
|
13
13
|
s.description = %q{Like the ActiveRecord Store, but for Mongo.}
|
14
14
|
s.email = %q{samsm@samsm.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
|
-
require 'mocha'
|
4
3
|
require 'ruby-debug'
|
5
4
|
|
6
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -20,6 +19,10 @@ class Test::Unit::TestCase
|
|
20
19
|
##
|
21
20
|
## Mongo-specific database test configuration here.
|
22
21
|
##
|
22
|
+
def teardown
|
23
|
+
test_database.drop_collection 'openid_mongo_store_associations'
|
24
|
+
test_database.drop_collection 'openid_mongo_store_nonces'
|
25
|
+
end
|
23
26
|
|
24
27
|
def store
|
25
28
|
@store ||= OpenidMongodbStore::Store.new(test_database)
|
@@ -33,17 +36,17 @@ class Test::Unit::TestCase
|
|
33
36
|
'lifetime' => lifetime,
|
34
37
|
'assoc_type' => assoc_type,
|
35
38
|
'expire_at' => (too_old_association_timestamp + lifetime))
|
36
|
-
|
39
|
+
|
37
40
|
end
|
38
|
-
|
41
|
+
|
39
42
|
def find_old_association
|
40
43
|
store.associations.find_one({'issued' => too_old_association_timestamp})
|
41
44
|
end
|
42
|
-
|
45
|
+
|
43
46
|
def insert_old_nonce
|
44
47
|
store.nonces.insert({'server_url' => server_url, 'timestamp' => too_old_nonce_timestamp, 'salt' => salt})
|
45
48
|
end
|
46
|
-
|
49
|
+
|
47
50
|
def find_old_nonce
|
48
51
|
store.nonces.find_one({'server_url'=> server_url, 'timestamp' => too_old_nonce_timestamp, 'salt' => salt})
|
49
52
|
end
|
@@ -60,9 +63,8 @@ class Test::Unit::TestCase
|
|
60
63
|
timestamp - (60*60*24*365) # year old
|
61
64
|
end
|
62
65
|
|
63
|
-
def store_association(
|
64
|
-
association = OpenID::Association.new(handle, secret,
|
65
|
-
opts.each_pair {|k,v| association.send "#{k}=", v}
|
66
|
+
def store_association(issued = timestamp)
|
67
|
+
association = OpenID::Association.new(handle, secret, issued, lifetime, assoc_type)
|
66
68
|
store.store_association(server_url,association)
|
67
69
|
end
|
68
70
|
|
@@ -99,9 +101,4 @@ class Test::Unit::TestCase
|
|
99
101
|
"KuIaaq"
|
100
102
|
end
|
101
103
|
|
102
|
-
def teardown
|
103
|
-
test_database.drop_collection 'openid_mongo_store_associations'
|
104
|
-
test_database.drop_collection 'openid_mongo_store_nonces'
|
105
|
-
end
|
106
|
-
|
107
104
|
end
|
@@ -9,7 +9,16 @@ class TestOpenidMongodbStore < Test::Unit::TestCase
|
|
9
9
|
assert store_association
|
10
10
|
|
11
11
|
# Retrieve the association
|
12
|
-
assert store.get_association(server_url, handle)
|
12
|
+
assert assoc = store.get_association(server_url, handle)
|
13
|
+
|
14
|
+
# Check status of secret
|
15
|
+
assert assoc.secret == secret
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_text_date_association
|
19
|
+
store_association(Time.now.to_s)
|
20
|
+
|
21
|
+
assert assoc = get_association
|
13
22
|
end
|
14
23
|
|
15
24
|
def test_remove_association
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openid_mongodb_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Schenkman-Moore
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-01 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|