openid_couch_rest_model_store 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.9.2-p290@openid_couch_rest_model_store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', '3.1.0'
3
+ gem 'ruby-openid'
4
+ gem 'openlogic-couchrest_model', '~> 1.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.0)
5
+ actionpack (= 3.1.0)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.0)
8
+ activemodel (= 3.1.0)
9
+ activesupport (= 3.1.0)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.2)
14
+ rack-cache (~> 1.0.3)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.0)
18
+ activemodel (3.1.0)
19
+ activesupport (= 3.1.0)
20
+ bcrypt-ruby (~> 3.0.0)
21
+ builder (~> 3.0.0)
22
+ i18n (~> 0.6)
23
+ activerecord (3.1.0)
24
+ activemodel (= 3.1.0)
25
+ activesupport (= 3.1.0)
26
+ arel (~> 2.2.1)
27
+ tzinfo (~> 0.3.29)
28
+ activeresource (3.1.0)
29
+ activemodel (= 3.1.0)
30
+ activesupport (= 3.1.0)
31
+ activesupport (3.1.0)
32
+ multi_json (~> 1.0)
33
+ arel (2.2.3)
34
+ bcrypt-ruby (3.0.1)
35
+ builder (3.0.0)
36
+ couchrest (1.1.2)
37
+ mime-types (~> 1.15)
38
+ multi_json (~> 1.0.0)
39
+ rest-client (~> 1.6.1)
40
+ erubis (2.7.0)
41
+ hike (1.2.1)
42
+ i18n (0.6.0)
43
+ json (1.6.5)
44
+ mail (2.3.3)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.17.2)
49
+ multi_json (1.0.4)
50
+ openlogic-couchrest_model (1.0.0)
51
+ activemodel (~> 3.0)
52
+ couchrest (~> 1.1.2)
53
+ mime-types (~> 1.15)
54
+ tzinfo (~> 0.3.22)
55
+ polyglot (0.3.3)
56
+ rack (1.3.6)
57
+ rack-cache (1.0.3)
58
+ rack (>= 0.4)
59
+ rack-mount (0.8.3)
60
+ rack (>= 1.0.0)
61
+ rack-ssl (1.3.2)
62
+ rack
63
+ rack-test (0.6.1)
64
+ rack (>= 1.0)
65
+ rails (3.1.0)
66
+ actionmailer (= 3.1.0)
67
+ actionpack (= 3.1.0)
68
+ activerecord (= 3.1.0)
69
+ activeresource (= 3.1.0)
70
+ activesupport (= 3.1.0)
71
+ bundler (~> 1.0)
72
+ railties (= 3.1.0)
73
+ railties (3.1.0)
74
+ actionpack (= 3.1.0)
75
+ activesupport (= 3.1.0)
76
+ rack-ssl (~> 1.3.2)
77
+ rake (>= 0.8.7)
78
+ rdoc (~> 3.4)
79
+ thor (~> 0.14.6)
80
+ rake (0.9.2.2)
81
+ rdoc (3.12)
82
+ json (~> 1.4)
83
+ rest-client (1.6.7)
84
+ mime-types (>= 1.16)
85
+ ruby-openid (2.1.8)
86
+ sprockets (2.0.3)
87
+ hike (~> 1.2)
88
+ rack (~> 1.0)
89
+ tilt (~> 1.1, != 1.3.0)
90
+ thor (0.14.6)
91
+ tilt (1.3.3)
92
+ treetop (1.4.10)
93
+ polyglot
94
+ polyglot (>= 0.3.1)
95
+ tzinfo (0.3.32)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ openlogic-couchrest_model (~> 1.0)
102
+ rails (= 3.1.0)
103
+ ruby-openid
data/README.rdoc ADDED
@@ -0,0 +1,63 @@
1
+ = openid_active_record_store
2
+
3
+ http://rubygems.org/gems/openid_active_record_store
4
+ {Project}[http://rubygems.org/gems/openid_active_record_store]
5
+ {Wiki}[http://wiki.github.com/raggi/openid_active_record_store/]
6
+ {Source Code}[http://github.com/raggi/openid_active_record_store/]
7
+ {Issues}[http://github.com/raggi/openid_active_record_store/issues]
8
+
9
+ == DESCRIPTION:
10
+
11
+ A rails engine for OpenID/Omniauth that writes to ActiveRecord for the OpenID data. Forked from an old project by Kazuyoshi Tlacaelel.
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * Simple
16
+ * Lowish test coverage
17
+ * Binary column may not work well with some adapters
18
+
19
+ == SYNOPSIS:
20
+
21
+ rake openid_active_record_store:install:migrations
22
+ rake db:migrate
23
+
24
+ # Omniauth example:
25
+ Rails.application.config.middleware.use(
26
+ OmniAuth::Strategies::GoogleApps,
27
+ OpenID::Store::ActiveRecord.new,
28
+ { :name => 'example', :domain => 'example.org' }
29
+ )
30
+
31
+ == REQUIREMENTS:
32
+
33
+ * Rails 3+
34
+ * OpenID
35
+
36
+ == INSTALL:
37
+
38
+ * gem install openid_active_record_store
39
+
40
+ == LICENSE:
41
+
42
+ (The MIT License)
43
+
44
+ Copyright (c) 2011 Kazuyoshi Tlacaelel, James Tucker, Wildfire Interactive Inc
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining
47
+ a copy of this software and associated documentation files (the
48
+ 'Software'), to deal in the Software without restriction, including
49
+ without limitation the rights to use, copy, modify, merge, publish,
50
+ distribute, sublicense, and/or sell copies of the Software, and to
51
+ permit persons to whom the Software is furnished to do so, subject to
52
+ the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be
55
+ included in all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
58
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
60
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
61
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
62
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
63
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+
2
+ require 'rake/testtask'
3
+ #require 'rdoc/task'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.ruby_opts << '-rubygems'
11
+ t.libs += %w[test]
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ t.warning = true
15
+ end
16
+
17
+ # desc 'Generate documentation for the plugin.'
18
+ # RDoc::Task.new(:rdoc) do |rdoc|
19
+ # rdoc.rdoc_dir = 'rdoc'
20
+ # rdoc.title = 'OpenidCouchRestModelStore'
21
+ # rdoc.options << '--line-numbers' << '--inline-source'
22
+ # rdoc.rdoc_files.include('README')
23
+ # rdoc.rdoc_files.include('lib/**/*.rb')
24
+ # end
25
+
26
+ desc "build gem"
27
+ task :gem do
28
+ sh "gem build openid_couch_rest_model_store.gemspec"
29
+ end
@@ -0,0 +1,17 @@
1
+ class OpenidAssociation < CouchRest::Model::Base
2
+ property :issued_at, Time
3
+ property :lifetime, Integer
4
+ property :assoc_type, String
5
+ property :handle, String
6
+ property :secret, TrueClass
7
+ property :target, String
8
+ property :server_url, String
9
+ timestamps!
10
+
11
+ design do
12
+ view :by_target
13
+ end
14
+
15
+ save_design_doc!
16
+
17
+ end
@@ -0,0 +1,18 @@
1
+ class OpenidNonce < CouchRest::Model::Base
2
+ property :timestamp, Integer
3
+ property :salt, String
4
+ property :target, String
5
+ property :server_url, String
6
+ timestamps!
7
+
8
+ design do
9
+ view :by_target
10
+ end
11
+
12
+ save_design_doc!
13
+
14
+ def self.exists_by_target?(timestamp, salt, target)
15
+ by_target(key: target).any?{|nonce| nonce.timestamp == timestamp}
16
+ end
17
+
18
+ end
@@ -0,0 +1,120 @@
1
+ require 'openid/util'
2
+ require 'openid/store/interface'
3
+ require 'openid/association'
4
+ require 'openssl'
5
+
6
+ module OpenID
7
+ module Store
8
+ class CouchRestModel < Interface
9
+
10
+ # Put a Association object into storage.
11
+ # When implementing a store, don't assume that there are any limitations
12
+ # on the character set of the server_url. In particular, expect to see
13
+ # unescaped non-url-safe characters in the server_url field.
14
+ def store_association(server_url, association)
15
+ OpenidAssociation.create!(
16
+ :server_url => server_url,
17
+ :target => targetize(server_url),
18
+ :handle => association.handle,
19
+ :secret => association.secret,
20
+ :issued_at => association.issued,
21
+ :lifetime => association.lifetime,
22
+ :assoc_type => association.assoc_type
23
+ )
24
+ true
25
+ end
26
+
27
+ # Returns a Association object from storage that matches
28
+ # the server_url. Returns nil if no such association is found or if
29
+ # the one matching association is expired. (Is allowed to GC expired
30
+ # associations when found.)
31
+ def get_association(server_url, handle=nil)
32
+ oas = OpenidAssociation.by_target(key: targetize(server_url))
33
+ return nil if oas.empty?
34
+ unless handle.nil?
35
+ return nil unless oas.collect(&:handle).include? handle
36
+ return build_association(oas.find { |oa| oa.handle == handle })
37
+ end
38
+ oas.sort_by(&:issued_at).collect { |oa| build_association(oa) }.last
39
+ end
40
+
41
+ # If there is a matching association, remove it from the store and
42
+ # return true, otherwise return false.
43
+ def remove_association(server_url, handle)
44
+ oas = OpenidAssociation.by_target(key: targetize(server_url)).all
45
+ return false unless oas.collect(&:handle).include? handle
46
+ oas.select { |oa| oa.handle == handle }.each(&:destroy).any?{|tf| tf }
47
+ end
48
+
49
+ # Return true if the nonce has not been used before, and store it
50
+ # for a while to make sure someone doesn't try to use the same value
51
+ # again. Return false if the nonce has already been used or if the
52
+ # timestamp is not current.
53
+ # You can use OpenID::Store::Nonce::SKEW for your timestamp window.
54
+ # server_url: URL of the server from which the nonce originated
55
+ # timestamp: time the nonce was created in seconds since unix epoch
56
+ # salt: A random string that makes two nonces issued by a server in
57
+ # the same second unique
58
+ def use_nonce(server_url, timestamp, salt)
59
+ return false if (timestamp - Time.now.to_i).abs > Nonce.skew
60
+ params = [timestamp, salt, targetize(server_url)]
61
+ return false if OpenidNonce.exists_by_target?(*params)
62
+ return create_nonce(server_url, timestamp, salt)
63
+ end
64
+
65
+ # Remove expired nonces and associations from the store
66
+ # Not called during normal library operation, this method is for store
67
+ # admins to keep their storage from filling up with expired data
68
+ def cleanup
69
+ cleanup_nonces
70
+ cleanup_associations
71
+ end
72
+
73
+ # Remove expired associations from the store
74
+ # Not called during normal library operation, this method is for store
75
+ # admins to keep their storage from filling up with expired data
76
+ def cleanup_associations
77
+ oas = OpenidAssociation.all.all.collect do |oa|
78
+ oa if build_association(oa).expires_in == 0
79
+ end
80
+ oas.compact.map(&:destroy)
81
+ end
82
+
83
+ # Remove expired nonces from the store
84
+ # Discards any nonce that is old enough that it wouldn't pass use_nonce
85
+ # Not called during normal library operation, this method is for store
86
+ # admins to keep their storage from filling up with expired data
87
+ def cleanup_nonces
88
+ now = Time.now.to_i
89
+ nonces = OpenidNonce.all.all.collect { |n| n if (n.timestamp - now).abs > Nonce.skew }.compact
90
+ nonces.map(&:destroy)
91
+ end
92
+
93
+ private
94
+
95
+ def targetize(server_url)
96
+ OpenSSL::Digest::MD5.hexdigest(server_url)
97
+ end
98
+
99
+ def build_association(open_id_association)
100
+ OpenID::Association.new(
101
+ open_id_association.handle,
102
+ open_id_association.secret,
103
+ open_id_association.issued_at,
104
+ open_id_association.lifetime,
105
+ open_id_association.assoc_type
106
+ )
107
+ end
108
+
109
+ def create_nonce(server_url, timestamp, salt)
110
+ OpenidNonce.create!(
111
+ :target => targetize(server_url),
112
+ :server_url => server_url,
113
+ :timestamp => timestamp
114
+ )
115
+ true
116
+ end
117
+
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails/engine'
2
+
3
+ module OpenidCouchRestModelStore
4
+ class Engine < Rails::Engine
5
+ config.eager_load_paths << File.expand_path("../../app/models", __FILE__)
6
+ end
7
+ class Railtie < Rails::Railtie
8
+ # nothin'
9
+ end
10
+ end
@@ -0,0 +1,236 @@
1
+ require 'test_helper'
2
+
3
+ class OpenidStoreCouchRestModelTest < ActiveSupport::TestCase
4
+
5
+ # ============================================================================
6
+ # TESTING SCENARIO
7
+ # ============================================================================
8
+
9
+ setup :prepare_scenario, :clean_tables
10
+ teardown :destroy_scenario
11
+
12
+ def prepare_scenario
13
+ @store = OpenID::Store::CouchRestModel.new
14
+ @@allowed_nonce = '0123456789abcdefghijklmnopqrst' +
15
+ 'uvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
16
+ @@allowed_handle = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ' +
17
+ 'RSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
18
+ end
19
+
20
+ def clean_tables
21
+ # super duper make sure talbes are empty
22
+ OpenidAssociation.all.each { |ao| ao.destroy }
23
+ OpenidNonce.all.each { |nonce| nonce.destroy }
24
+ end
25
+
26
+ def destroy_scenario
27
+ @@allowed_handle = @@allowed_nonce = @store = nil
28
+ end
29
+
30
+ # ============================================================================
31
+ # TESTS BELOW BROUGHT FROM THE ORIGINAL 'ruby-openid' (store) test suite
32
+ # these methods test the association interactivity with a store object
33
+ # ============================================================================
34
+
35
+ def _gen_secret(n, chars=nil)
36
+ OpenID::CryptUtil.random_string(n, chars)
37
+ end
38
+
39
+ def _gen_handle(n)
40
+ OpenID::CryptUtil.random_string(n, @@allowed_handle)
41
+ end
42
+
43
+ def _gen_assoc(issued_at, lifetime=600)
44
+ secret = _gen_secret(20, @@allowed_handle)
45
+ handle = _gen_handle(128)
46
+ OpenID::Association.new(handle, secret, Time.now + issued_at, lifetime,
47
+ 'HMAC-SHA1')
48
+ end
49
+
50
+ def _check_retrieve(url, handle=nil, expected=nil)
51
+ ret_assoc = @store.get_association(url, handle)
52
+
53
+ if expected.nil?
54
+ assert_nil(ret_assoc)
55
+ else
56
+ %w[assoc_type handle issued lifetime secret].each do |prop|
57
+ ex, actual = expected.send(prop), ret_assoc.send(prop)
58
+ if ex.kind_of?(Time)
59
+ ex, actual = ex.to_i, actual.to_i
60
+ end
61
+ assert_equal ex, actual, "#{prop} doesn't match"
62
+ end
63
+ end
64
+ end
65
+
66
+ def _check_remove(url, handle, expected)
67
+ present = @store.remove_association(url, handle)
68
+ assert_equal(expected, present)
69
+ end
70
+
71
+ def test_store
72
+ server_url = "http://www.myopenid.com/openid"
73
+ assoc = _gen_assoc(issued_at=0)
74
+
75
+ # Make sure that a missing association returns no result
76
+ _check_retrieve(server_url)
77
+
78
+ # Check that after storage, getting returns the same result
79
+ @store.store_association(server_url, assoc)
80
+ _check_retrieve(server_url, nil, assoc)
81
+
82
+ # more than once
83
+ _check_retrieve(server_url, nil, assoc)
84
+
85
+ # Storing more than once has no ill effect
86
+ @store.store_association(server_url, assoc)
87
+ _check_retrieve(server_url, nil, assoc)
88
+
89
+ # Removing an association that does not exist returns not present
90
+ _check_remove(server_url, assoc.handle + 'x', false)
91
+
92
+ # Removing an association that does not exist returns not present
93
+ _check_remove(server_url + 'x', assoc.handle, false)
94
+
95
+ # Removing an association that is present returns present
96
+ _check_remove(server_url, assoc.handle, true)
97
+
98
+ # but not present on subsequent calls
99
+ _check_remove(server_url, assoc.handle, false)
100
+
101
+ # Put assoc back in the store
102
+ @store.store_association(server_url, assoc)
103
+
104
+ # More recent and expires after assoc
105
+ assoc2 = _gen_assoc(issued_at=1)
106
+ @store.store_association(server_url, assoc2)
107
+
108
+ # After storing an association with a different handle, but the
109
+ # same server_url, the handle with the later expiration is returned.
110
+ _check_retrieve(server_url, nil, assoc2)
111
+
112
+ # We can still retrieve the older association
113
+ _check_retrieve(server_url, assoc.handle, assoc)
114
+
115
+ # Plus we can retrieve the association with the later expiration
116
+ # explicitly
117
+ _check_retrieve(server_url, assoc2.handle, assoc2)
118
+
119
+ # More recent, and expires earlier than assoc2 or assoc. Make sure
120
+ # that we're picking the one with the latest issued date and not
121
+ # taking into account the expiration.
122
+ assoc3 = _gen_assoc(issued_at=2, lifetime=100)
123
+ @store.store_association(server_url, assoc3)
124
+
125
+ _check_retrieve(server_url, nil, assoc3)
126
+ _check_retrieve(server_url, assoc.handle, assoc)
127
+ _check_retrieve(server_url, assoc2.handle, assoc2)
128
+ _check_retrieve(server_url, assoc3.handle, assoc3)
129
+
130
+ _check_remove(server_url, assoc2.handle, true)
131
+
132
+ _check_retrieve(server_url, nil, assoc3)
133
+ _check_retrieve(server_url, assoc.handle, assoc)
134
+ _check_retrieve(server_url, assoc2.handle, nil)
135
+ _check_retrieve(server_url, assoc3.handle, assoc3)
136
+
137
+ _check_remove(server_url, assoc2.handle, false)
138
+ _check_remove(server_url, assoc3.handle, true)
139
+
140
+ _check_retrieve(server_url, nil, assoc)
141
+ _check_retrieve(server_url, assoc.handle, assoc)
142
+ _check_retrieve(server_url, assoc2.handle, nil)
143
+ _check_retrieve(server_url, assoc3.handle, nil)
144
+
145
+ _check_remove(server_url, assoc2.handle, false)
146
+ _check_remove(server_url, assoc.handle, true)
147
+ _check_remove(server_url, assoc3.handle, false)
148
+
149
+ _check_retrieve(server_url, nil, nil)
150
+ _check_retrieve(server_url, assoc.handle, nil)
151
+ _check_retrieve(server_url, assoc2.handle, nil)
152
+ _check_retrieve(server_url, assoc3.handle, nil)
153
+
154
+ _check_remove(server_url, assoc2.handle, false)
155
+ _check_remove(server_url, assoc.handle, false)
156
+ _check_remove(server_url, assoc3.handle, false)
157
+
158
+ assocValid1 = _gen_assoc(-3600, 7200)
159
+ assocValid2 = _gen_assoc(-5)
160
+ assocExpired1 = _gen_assoc(-7200, 3600)
161
+ assocExpired2 = _gen_assoc(-7200, 3600)
162
+
163
+ @store.cleanup_associations
164
+ @store.store_association(server_url + '1', assocValid1)
165
+ @store.store_association(server_url + '1', assocExpired1)
166
+ @store.store_association(server_url + '2', assocExpired2)
167
+ @store.store_association(server_url + '3', assocValid2)
168
+
169
+ cleaned = @store.cleanup_associations().select{|n|n}.size
170
+ assert_equal(2, cleaned, "cleaned up associations")
171
+ end
172
+
173
+ # ============================================================================
174
+ # am including open id here because the nonce module is not being mocked
175
+ # ============================================================================
176
+ include OpenID
177
+
178
+ # ============================================================================
179
+ # TESTS BELOW BROUGHT FROM THE ORIGINAL 'ruby-openid' (store) test suite
180
+ # these methods test the nonce interactivity with a store object
181
+ # ============================================================================
182
+
183
+ def _check_use_nonce(nonce, expected, server_url, msg='')
184
+ stamp, salt = Nonce::split_nonce(nonce)
185
+ actual = @store.use_nonce(server_url, stamp, salt)
186
+ assert_equal(expected, actual, msg)
187
+ end
188
+
189
+ def test_nonce
190
+ server_url = "http://www.myopenid.com/openid"
191
+ [server_url, ''].each{|url|
192
+ nonce1 = Nonce::mk_nonce
193
+
194
+ _check_use_nonce(nonce1, true, url, "#{url}: nonce allowed by default")
195
+ _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed twice")
196
+ _check_use_nonce(nonce1, false, url, "#{url}: nonce not allowed third time")
197
+
198
+ # old nonces shouldn't pass
199
+ old_nonce = Nonce::mk_nonce(3600)
200
+ _check_use_nonce(old_nonce, false, url, "Old nonce #{old_nonce.inspect} passed")
201
+
202
+ }
203
+
204
+ now = Time.now.to_i
205
+ old_nonce1 = Nonce::mk_nonce(now - 20000)
206
+ old_nonce2 = Nonce::mk_nonce(now - 10000)
207
+ recent_nonce = Nonce::mk_nonce(now - 600)
208
+
209
+ orig_skew = Nonce.skew
210
+ Nonce.skew = 0
211
+ count = @store.cleanup_nonces
212
+ Nonce.skew = 1000000
213
+ ts, salt = Nonce::split_nonce(old_nonce1)
214
+ assert(@store.use_nonce(server_url, ts, salt), "oldnonce1")
215
+ ts, salt = Nonce::split_nonce(old_nonce2)
216
+ assert(@store.use_nonce(server_url, ts, salt), "oldnonce2")
217
+ ts, salt = Nonce::split_nonce(recent_nonce)
218
+ assert(@store.use_nonce(server_url, ts, salt), "recent_nonce")
219
+
220
+
221
+ Nonce.skew = 1000
222
+ cleaned = @store.cleanup_nonces.select{|n|n}.size
223
+ assert_equal(2, cleaned, "Cleaned #{cleaned} nonces")
224
+
225
+ Nonce.skew = 100000
226
+ ts, salt = Nonce::split_nonce(old_nonce1)
227
+ assert(@store.use_nonce(server_url, ts, salt), "oldnonce1 after cleanup")
228
+ ts, salt = Nonce::split_nonce(old_nonce2)
229
+ assert(@store.use_nonce(server_url, ts, salt), "oldnonce2 after cleanup")
230
+ ts, salt = Nonce::split_nonce(recent_nonce)
231
+ assert(!@store.use_nonce(server_url, ts, salt), "recent_nonce after cleanup")
232
+
233
+ Nonce.skew = orig_skew
234
+ end
235
+
236
+ end
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'active_support'
3
+ require 'couchrest_model'
4
+ require 'openid/store/couch_rest_model'
5
+ require 'openid/store/nonce'
6
+
7
+ # CouchRest::Model::Base.configure do |conf|
8
+ # conf.connection[:name] = 'openidcouchrestmodelstoretest'
9
+ # end
10
+
11
+ Dir['app/models/*.rb'].each do |model|
12
+ require File.expand_path(model)
13
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openid_couch_rest_model_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James Tucker
9
+ - Kazuyoshi Tlacaelel
10
+ - Jeff Gran
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-03-20 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ requirement: &2156431940 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '3'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *2156431940
27
+ description: A CouchRestModel store for OpenID, forked from a very similar ActiveRecord
28
+ store written by James Tucker and Kazuyoshi Tlacaelel
29
+ email: info@wildfireapp.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .rvmrc
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - README.rdoc
38
+ - Rakefile
39
+ - app/models/openid_association.rb
40
+ - app/models/openid_nonce.rb
41
+ - lib/openid/store/couch_rest_model.rb
42
+ - lib/openid_couch_rest_model_store.rb
43
+ - test/openid_store_couch_rest_model_test.rb
44
+ - test/test_helper.rb
45
+ homepage: http://github.com/jeffgran/openid_couch_rest_model_store
46
+ licenses:
47
+ - MIT
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.16
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: A CouchRestModel store for OpenID
70
+ test_files: []