Empact-authlogic 2.1.5 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Empact-authlogic.gemspec +190 -187
- data/Gemfile +10 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +1 -1
- data/README.rdoc +14 -10
- data/Rakefile +5 -5
- data/VERSION.yml +3 -3
- data/lib/authlogic/acts_as_authentic/base.rb +14 -12
- data/lib/authlogic/acts_as_authentic/email.rb +12 -12
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +8 -9
- data/lib/authlogic/acts_as_authentic/login.rb +19 -18
- data/lib/authlogic/acts_as_authentic/password.rb +3 -3
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +15 -15
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +1 -1
- data/lib/authlogic/authenticates_many/base.rb +3 -4
- data/lib/authlogic/controller_adapters/rails_adapter.rb +1 -1
- data/lib/authlogic/random.rb +1 -1
- data/lib/authlogic/session/active_record_trickery.rb +8 -0
- data/lib/authlogic/session/callbacks.rb +2 -2
- data/lib/authlogic/session/cookies.rb +54 -2
- data/lib/authlogic/session/foundation.rb +17 -3
- data/lib/authlogic/session/http_auth.rb +43 -2
- data/lib/authlogic/session/scopes.rb +9 -9
- data/lib/authlogic/test_case/mock_controller.rb +12 -2
- data/lib/generators/authlogic/USAGE +8 -0
- data/lib/generators/authlogic/session_generator.rb +14 -0
- data/lib/generators/authlogic/templates/session.rb +2 -0
- data/test/acts_as_authentic_test/base_test.rb +1 -1
- data/test/acts_as_authentic_test/email_test.rb +29 -21
- data/test/acts_as_authentic_test/logged_in_status_test.rb +1 -1
- data/test/acts_as_authentic_test/login_test.rb +1 -1
- data/test/acts_as_authentic_test/magic_columns_test.rb +1 -1
- data/test/acts_as_authentic_test/password_test.rb +1 -1
- data/test/acts_as_authentic_test/perishable_token_test.rb +1 -1
- data/test/acts_as_authentic_test/persistence_token_test.rb +1 -1
- data/test/acts_as_authentic_test/restful_authentication_test.rb +1 -1
- data/test/acts_as_authentic_test/session_maintenance_test.rb +1 -1
- data/test/acts_as_authentic_test/single_access_test.rb +1 -1
- data/test/authenticates_many_test.rb +1 -1
- data/test/crypto_provider_test/aes256_test.rb +1 -1
- data/test/crypto_provider_test/bcrypt_test.rb +1 -1
- data/test/crypto_provider_test/sha1_test.rb +1 -1
- data/test/crypto_provider_test/sha256_test.rb +1 -1
- data/test/crypto_provider_test/sha512_test.rb +1 -1
- data/test/i18n_test.rb +1 -1
- data/test/random_test.rb +1 -8
- data/test/session_test/activation_test.rb +1 -1
- data/test/session_test/active_record_trickery_test.rb +12 -2
- data/test/session_test/brute_force_protection_test.rb +1 -1
- data/test/session_test/callbacks_test.rb +1 -1
- data/test/session_test/cookies_test.rb +26 -2
- data/test/session_test/existence_test.rb +1 -1
- data/test/session_test/http_auth_test.rb +31 -3
- data/test/session_test/id_test.rb +1 -1
- data/test/session_test/klass_test.rb +1 -1
- data/test/session_test/magic_columns_test.rb +1 -1
- data/test/session_test/magic_states_test.rb +1 -1
- data/test/session_test/params_test.rb +1 -1
- data/test/session_test/password_test.rb +1 -1
- data/test/session_test/perishability_test.rb +1 -1
- data/test/session_test/persistence_test.rb +1 -1
- data/test/session_test/scopes_test.rb +12 -12
- data/test/session_test/session_test.rb +1 -1
- data/test/session_test/timeout_test.rb +1 -1
- data/test/session_test/unauthorized_record_test.rb +1 -1
- data/test/session_test/validation_test.rb +1 -1
- data/test/test_helper.rb +27 -41
- metadata +50 -55
- data/.gitignore +0 -9
- data/CHANGELOG.rdoc +0 -353
@@ -1,19 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
3
|
module SessionTest
|
4
4
|
class ScopesTest < ActiveSupport::TestCase
|
5
5
|
def test_scope_method
|
6
6
|
assert_nil Authlogic::Session::Base.scope
|
7
|
-
|
7
|
+
|
8
8
|
thread1 = Thread.new do
|
9
9
|
scope = {:id => :scope1}
|
10
10
|
Authlogic::Session::Base.send(:scope=, scope)
|
11
11
|
assert_equal scope, Authlogic::Session::Base.scope
|
12
12
|
end
|
13
13
|
thread1.join
|
14
|
-
|
14
|
+
|
15
15
|
assert_nil Authlogic::Session::Base.scope
|
16
|
-
|
16
|
+
|
17
17
|
thread2 = Thread.new do
|
18
18
|
scope = {:id => :scope2}
|
19
19
|
Authlogic::Session::Base.send(:scope=, scope)
|
@@ -23,17 +23,17 @@ module SessionTest
|
|
23
23
|
|
24
24
|
assert_nil Authlogic::Session::Base.scope
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def test_with_scope_method
|
28
28
|
assert_raise(ArgumentError) { UserSession.with_scope }
|
29
|
-
|
29
|
+
|
30
30
|
UserSession.with_scope(:find_options => {:conditions => "awesome = 1"}, :id => "some_id") do
|
31
31
|
assert_equal({:find_options => {:conditions => "awesome = 1"}, :id => "some_id"}, UserSession.scope)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
assert_nil UserSession.scope
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_initialize
|
38
38
|
UserSession.with_scope(:find_options => {:conditions => "awesome = 1"}, :id => "some_id") do
|
39
39
|
session = UserSession.new
|
@@ -42,18 +42,18 @@ module SessionTest
|
|
42
42
|
assert_equal "another_id_some_id_test", session.send(:build_key, "test")
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def test_search_for_record_with_scopes
|
47
47
|
binary_logic = companies(:binary_logic)
|
48
48
|
ben = users(:ben)
|
49
49
|
zack = users(:zack)
|
50
|
-
|
50
|
+
|
51
51
|
session = UserSession.new
|
52
52
|
assert_equal zack, session.send(:search_for_record, "find_by_login", zack.login)
|
53
|
-
|
53
|
+
|
54
54
|
session.scope = {:find_options => {:conditions => ["company_id = ?", binary_logic.id]}}
|
55
55
|
assert_nil session.send(:search_for_record, "find_by_login", zack.login)
|
56
|
-
|
56
|
+
|
57
57
|
assert_equal ben, session.send(:search_for_record, "find_by_login", ben.login)
|
58
58
|
end
|
59
59
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,48 +4,34 @@ require "ruby-debug"
|
|
4
4
|
require "active_record"
|
5
5
|
require "active_record/fixtures"
|
6
6
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
value = on(key)
|
13
|
-
value.is_a?(Array) ? value : [value].compact
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
ActiveRecord::Schema.verbose = false
|
20
|
-
|
21
|
-
begin
|
22
|
-
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
23
|
-
rescue ArgumentError
|
24
|
-
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
25
|
-
end
|
7
|
+
#ActiveRecord::Schema.verbose = false
|
8
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
9
|
+
logger = Logger.new(STDOUT)
|
10
|
+
logger.level= Logger::FATAL
|
11
|
+
ActiveRecord::Base.logger = logger
|
26
12
|
|
27
13
|
ActiveRecord::Base.configurations = true
|
28
14
|
ActiveRecord::Schema.define(:version => 1) do
|
29
15
|
create_table :companies do |t|
|
30
|
-
t.datetime :created_at
|
16
|
+
t.datetime :created_at
|
31
17
|
t.datetime :updated_at
|
32
18
|
t.string :name
|
33
19
|
t.boolean :active
|
34
20
|
end
|
35
21
|
|
36
22
|
create_table :projects do |t|
|
37
|
-
t.datetime :created_at
|
23
|
+
t.datetime :created_at
|
38
24
|
t.datetime :updated_at
|
39
25
|
t.string :name
|
40
26
|
end
|
41
|
-
|
27
|
+
|
42
28
|
create_table :projects_users, :id => false do |t|
|
43
29
|
t.integer :project_id
|
44
30
|
t.integer :user_id
|
45
31
|
end
|
46
|
-
|
32
|
+
|
47
33
|
create_table :users do |t|
|
48
|
-
t.datetime :created_at
|
34
|
+
t.datetime :created_at
|
49
35
|
t.datetime :updated_at
|
50
36
|
t.integer :lock_version, :default => 0
|
51
37
|
t.integer :company_id
|
@@ -69,9 +55,9 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
69
55
|
t.boolean :approved, :default => true
|
70
56
|
t.boolean :confirmed, :default => true
|
71
57
|
end
|
72
|
-
|
58
|
+
|
73
59
|
create_table :employees do |t|
|
74
|
-
t.datetime :created_at
|
60
|
+
t.datetime :created_at
|
75
61
|
t.datetime :updated_at
|
76
62
|
t.integer :company_id
|
77
63
|
t.string :email
|
@@ -87,9 +73,9 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
87
73
|
t.string :current_login_ip
|
88
74
|
t.string :last_login_ip
|
89
75
|
end
|
90
|
-
|
76
|
+
|
91
77
|
create_table :affiliates do |t|
|
92
|
-
t.datetime :created_at
|
78
|
+
t.datetime :created_at
|
93
79
|
t.datetime :updated_at
|
94
80
|
t.integer :company_id
|
95
81
|
t.string :username
|
@@ -97,9 +83,9 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
97
83
|
t.string :pw_salt
|
98
84
|
t.string :persistence_token
|
99
85
|
end
|
100
|
-
|
86
|
+
|
101
87
|
create_table :ldapers do |t|
|
102
|
-
t.datetime :created_at
|
88
|
+
t.datetime :created_at
|
103
89
|
t.datetime :updated_at
|
104
90
|
t.string :ldap_login
|
105
91
|
t.string :persistence_token
|
@@ -127,7 +113,7 @@ class ActiveSupport::TestCase
|
|
127
113
|
self.pre_loaded_fixtures = false
|
128
114
|
fixtures :all
|
129
115
|
setup :activate_authlogic
|
130
|
-
|
116
|
+
|
131
117
|
private
|
132
118
|
def password_for(user)
|
133
119
|
case user
|
@@ -137,45 +123,45 @@ class ActiveSupport::TestCase
|
|
137
123
|
"zackrocks"
|
138
124
|
end
|
139
125
|
end
|
140
|
-
|
126
|
+
|
141
127
|
def http_basic_auth_for(user = nil, &block)
|
142
128
|
unless user.blank?
|
143
129
|
controller.http_user = user.login
|
144
130
|
controller.http_password = password_for(user)
|
145
131
|
end
|
146
132
|
yield
|
147
|
-
controller.http_user = controller.http_password = nil
|
133
|
+
controller.http_user = controller.http_password = controller.realm = nil
|
148
134
|
end
|
149
|
-
|
135
|
+
|
150
136
|
def set_cookie_for(user, id = nil)
|
151
137
|
controller.cookies["user_credentials"] = {:value => user.persistence_token, :expires => nil}
|
152
138
|
end
|
153
|
-
|
139
|
+
|
154
140
|
def unset_cookie
|
155
141
|
controller.cookies["user_credentials"] = nil
|
156
142
|
end
|
157
|
-
|
143
|
+
|
158
144
|
def set_params_for(user, id = nil)
|
159
145
|
controller.params["user_credentials"] = user.single_access_token
|
160
146
|
end
|
161
|
-
|
147
|
+
|
162
148
|
def unset_params
|
163
149
|
controller.params["user_credentials"] = nil
|
164
150
|
end
|
165
|
-
|
151
|
+
|
166
152
|
def set_request_content_type(type)
|
167
153
|
controller.request_content_type = type
|
168
154
|
end
|
169
|
-
|
155
|
+
|
170
156
|
def unset_request_content_type
|
171
157
|
controller.request_content_type = nil
|
172
158
|
end
|
173
|
-
|
159
|
+
|
174
160
|
def set_session_for(user, id = nil)
|
175
161
|
controller.session["user_credentials"] = user.persistence_token
|
176
162
|
controller.session["user_credentials_id"] = user.id
|
177
163
|
end
|
178
|
-
|
164
|
+
|
179
165
|
def unset_session
|
180
166
|
controller.session["user_credentials"] = controller.session["user_credentials_id"] = nil
|
181
167
|
end
|
metadata
CHANGED
@@ -1,51 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: Empact-authlogic
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
- 5
|
10
|
-
version: 2.1.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.3
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ben Johnson of Binary Logic
|
14
9
|
- Ben Woosley
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
date: 2011-08-14 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
requirement: &2164354060 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.7
|
23
|
+
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
|
25
|
+
version_requirements: *2164354060
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: activerecord
|
28
|
+
requirement: &2164350480 !ruby/object:Gem::Requirement
|
26
29
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.7
|
34
34
|
type: :runtime
|
35
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2164350480
|
36
37
|
description:
|
37
38
|
email: bjohnson@binarylogic.com
|
38
39
|
executables: []
|
39
|
-
|
40
40
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
41
|
+
extra_rdoc_files:
|
43
42
|
- LICENSE
|
44
43
|
- README.rdoc
|
45
|
-
files:
|
46
|
-
- .gitignore
|
47
|
-
- CHANGELOG.rdoc
|
44
|
+
files:
|
48
45
|
- Empact-authlogic.gemspec
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.lock
|
49
48
|
- LICENSE
|
50
49
|
- README.rdoc
|
51
50
|
- Rakefile
|
@@ -112,6 +111,9 @@ files:
|
|
112
111
|
- lib/authlogic/test_case/mock_logger.rb
|
113
112
|
- lib/authlogic/test_case/mock_request.rb
|
114
113
|
- lib/authlogic/test_case/rails_request_adapter.rb
|
114
|
+
- lib/generators/authlogic/USAGE
|
115
|
+
- lib/generators/authlogic/session_generator.rb
|
116
|
+
- lib/generators/authlogic/templates/session.rb
|
115
117
|
- rails/init.rb
|
116
118
|
- shoulda_macros/authlogic.rb
|
117
119
|
- test/acts_as_authentic_test/base_test.rb
|
@@ -168,41 +170,34 @@ files:
|
|
168
170
|
- test/session_test/unauthorized_record_test.rb
|
169
171
|
- test/session_test/validation_test.rb
|
170
172
|
- test/test_helper.rb
|
171
|
-
has_rdoc: true
|
172
173
|
homepage: http://github.com/binarylogic/authlogic
|
173
174
|
licenses: []
|
174
|
-
|
175
175
|
post_install_message:
|
176
|
-
rdoc_options:
|
177
|
-
|
178
|
-
require_paths:
|
176
|
+
rdoc_options: []
|
177
|
+
require_paths:
|
179
178
|
- lib
|
180
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
180
|
none: false
|
182
|
-
requirements:
|
183
|
-
- -
|
184
|
-
- !ruby/object:Gem::Version
|
185
|
-
|
186
|
-
segments:
|
181
|
+
requirements:
|
182
|
+
- - ! '>='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
segments:
|
187
186
|
- 0
|
188
|
-
|
189
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
hash: -2975867320564342286
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
189
|
none: false
|
191
|
-
requirements:
|
192
|
-
- -
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
|
195
|
-
segments:
|
196
|
-
- 0
|
197
|
-
version: "0"
|
190
|
+
requirements:
|
191
|
+
- - ! '>='
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
198
194
|
requirements: []
|
199
|
-
|
200
|
-
|
201
|
-
rubygems_version: 1.3.7
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 1.8.5
|
202
197
|
signing_key:
|
203
198
|
specification_version: 3
|
204
199
|
summary: A clean, simple, and unobtrusive ruby authentication solution.
|
205
|
-
test_files:
|
200
|
+
test_files:
|
206
201
|
- test/acts_as_authentic_test/base_test.rb
|
207
202
|
- test/acts_as_authentic_test/email_test.rb
|
208
203
|
- test/acts_as_authentic_test/logged_in_status_test.rb
|