authlogic 4.4.3 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/authlogic.rb +4 -28
- data/lib/authlogic/acts_as_authentic/base.rb +3 -18
- data/lib/authlogic/acts_as_authentic/email.rb +3 -170
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -1
- data/lib/authlogic/acts_as_authentic/login.rb +7 -174
- data/lib/authlogic/acts_as_authentic/magic_columns.rb +7 -4
- data/lib/authlogic/acts_as_authentic/password.rb +54 -253
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +8 -5
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +10 -4
- data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
- data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +36 -20
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +8 -6
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +10 -8
- data/lib/authlogic/config.rb +9 -1
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +7 -4
- data/lib/authlogic/controller_adapters/rack_adapter.rb +2 -0
- data/lib/authlogic/controller_adapters/rails_adapter.rb +6 -29
- data/lib/authlogic/controller_adapters/sinatra_adapter.rb +6 -0
- data/lib/authlogic/cookie_credentials.rb +63 -0
- data/lib/authlogic/crypto_providers.rb +5 -20
- data/lib/authlogic/crypto_providers/bcrypt.rb +3 -3
- data/lib/authlogic/crypto_providers/md5.rb +3 -6
- data/lib/authlogic/crypto_providers/scrypt.rb +2 -0
- data/lib/authlogic/crypto_providers/sha1.rb +4 -6
- data/lib/authlogic/crypto_providers/sha256.rb +2 -0
- data/lib/authlogic/crypto_providers/sha512.rb +6 -5
- data/lib/authlogic/i18n.rb +3 -1
- data/lib/authlogic/i18n/translator.rb +3 -0
- data/lib/authlogic/random.rb +2 -0
- data/lib/authlogic/session/base.rb +2087 -39
- data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
- data/lib/authlogic/test_case.rb +4 -0
- data/lib/authlogic/test_case/mock_controller.rb +2 -0
- data/lib/authlogic/test_case/mock_cookie_jar.rb +7 -35
- data/lib/authlogic/test_case/mock_logger.rb +2 -0
- data/lib/authlogic/test_case/mock_request.rb +2 -0
- data/lib/authlogic/test_case/rails_request_adapter.rb +2 -0
- data/lib/authlogic/version.rb +2 -1
- metadata +136 -182
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
- data/.github/ISSUE_TEMPLATE/feature_proposal.md +0 -32
- data/.github/triage.md +0 -86
- data/.gitignore +0 -15
- data/.rubocop.yml +0 -133
- data/.rubocop_todo.yml +0 -74
- data/.travis.yml +0 -24
- data/CHANGELOG.md +0 -336
- data/CONTRIBUTING.md +0 -91
- data/Gemfile +0 -6
- data/LICENSE +0 -20
- data/README.md +0 -439
- data/Rakefile +0 -21
- data/UPGRADING.md +0 -22
- data/authlogic.gemspec +0 -40
- data/doc/use_normal_rails_validation.md +0 -82
- data/gemfiles/Gemfile.rails-4.2.x +0 -6
- data/gemfiles/Gemfile.rails-5.1.x +0 -6
- data/gemfiles/Gemfile.rails-5.2.x +0 -6
- data/lib/authlogic/acts_as_authentic/restful_authentication.rb +0 -106
- data/lib/authlogic/acts_as_authentic/validations_scope.rb +0 -35
- data/lib/authlogic/authenticates_many/association.rb +0 -50
- data/lib/authlogic/authenticates_many/base.rb +0 -81
- data/lib/authlogic/crypto_providers/aes256.rb +0 -71
- data/lib/authlogic/crypto_providers/wordpress.rb +0 -72
- data/lib/authlogic/regex.rb +0 -79
- data/lib/authlogic/session/activation.rb +0 -73
- data/lib/authlogic/session/active_record_trickery.rb +0 -65
- data/lib/authlogic/session/brute_force_protection.rb +0 -127
- data/lib/authlogic/session/callbacks.rb +0 -153
- data/lib/authlogic/session/cookies.rb +0 -329
- data/lib/authlogic/session/existence.rb +0 -103
- data/lib/authlogic/session/foundation.rb +0 -105
- data/lib/authlogic/session/http_auth.rb +0 -107
- data/lib/authlogic/session/id.rb +0 -53
- data/lib/authlogic/session/klass.rb +0 -73
- data/lib/authlogic/session/magic_columns.rb +0 -119
- data/lib/authlogic/session/magic_states.rb +0 -82
- data/lib/authlogic/session/params.rb +0 -130
- data/lib/authlogic/session/password.rb +0 -318
- data/lib/authlogic/session/perishable_token.rb +0 -24
- data/lib/authlogic/session/persistence.rb +0 -77
- data/lib/authlogic/session/priority_record.rb +0 -38
- data/lib/authlogic/session/scopes.rb +0 -138
- data/lib/authlogic/session/session.rb +0 -77
- data/lib/authlogic/session/timeout.rb +0 -103
- data/lib/authlogic/session/unauthorized_record.rb +0 -56
- data/lib/authlogic/session/validation.rb +0 -93
- data/test/acts_as_authentic_test/base_test.rb +0 -27
- data/test/acts_as_authentic_test/email_test.rb +0 -241
- data/test/acts_as_authentic_test/logged_in_status_test.rb +0 -64
- data/test/acts_as_authentic_test/login_test.rb +0 -153
- data/test/acts_as_authentic_test/magic_columns_test.rb +0 -29
- data/test/acts_as_authentic_test/password_test.rb +0 -263
- data/test/acts_as_authentic_test/perishable_token_test.rb +0 -98
- data/test/acts_as_authentic_test/persistence_token_test.rb +0 -62
- data/test/acts_as_authentic_test/restful_authentication_test.rb +0 -48
- data/test/acts_as_authentic_test/session_maintenance_test.rb +0 -150
- data/test/acts_as_authentic_test/single_access_test.rb +0 -46
- data/test/adapter_test.rb +0 -23
- data/test/authenticates_many_test.rb +0 -33
- data/test/config_test.rb +0 -38
- data/test/crypto_provider_test/aes256_test.rb +0 -16
- data/test/crypto_provider_test/bcrypt_test.rb +0 -16
- data/test/crypto_provider_test/scrypt_test.rb +0 -16
- data/test/crypto_provider_test/sha1_test.rb +0 -25
- data/test/crypto_provider_test/sha256_test.rb +0 -16
- data/test/crypto_provider_test/sha512_test.rb +0 -16
- data/test/crypto_provider_test/wordpress_test.rb +0 -26
- data/test/fixtures/companies.yml +0 -5
- data/test/fixtures/employees.yml +0 -17
- data/test/fixtures/projects.yml +0 -3
- data/test/fixtures/users.yml +0 -41
- data/test/i18n/lol.yml +0 -4
- data/test/i18n_test.rb +0 -35
- data/test/libs/affiliate.rb +0 -9
- data/test/libs/company.rb +0 -8
- data/test/libs/employee.rb +0 -9
- data/test/libs/employee_session.rb +0 -4
- data/test/libs/ldaper.rb +0 -5
- data/test/libs/project.rb +0 -5
- data/test/libs/user.rb +0 -9
- data/test/libs/user_session.rb +0 -27
- data/test/random_test.rb +0 -15
- data/test/session_test/activation_test.rb +0 -45
- data/test/session_test/active_record_trickery_test.rb +0 -78
- data/test/session_test/brute_force_protection_test.rb +0 -110
- data/test/session_test/callbacks_test.rb +0 -42
- data/test/session_test/cookies_test.rb +0 -242
- data/test/session_test/credentials_test.rb +0 -0
- data/test/session_test/existence_test.rb +0 -88
- data/test/session_test/foundation_test.rb +0 -24
- data/test/session_test/http_auth_test.rb +0 -60
- data/test/session_test/id_test.rb +0 -19
- data/test/session_test/klass_test.rb +0 -42
- data/test/session_test/magic_columns_test.rb +0 -62
- data/test/session_test/magic_states_test.rb +0 -60
- data/test/session_test/params_test.rb +0 -61
- data/test/session_test/password_test.rb +0 -107
- data/test/session_test/perishability_test.rb +0 -17
- data/test/session_test/persistence_test.rb +0 -35
- data/test/session_test/scopes_test.rb +0 -68
- data/test/session_test/session_test.rb +0 -80
- data/test/session_test/timeout_test.rb +0 -84
- data/test/session_test/unauthorized_record_test.rb +0 -15
- data/test/session_test/validation_test.rb +0 -25
- data/test/test_helper.rb +0 -272
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module ActsAsAuthenticTest
|
6
|
-
class PersistenceTokenTest < ActiveSupport::TestCase
|
7
|
-
def test_after_password_set_reset_persistence_token
|
8
|
-
ben = users(:ben)
|
9
|
-
old_persistence_token = ben.persistence_token
|
10
|
-
ben.password = "newpass"
|
11
|
-
assert_not_equal old_persistence_token, ben.persistence_token
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_after_password_verification_reset_persistence_token
|
15
|
-
aaron = users(:aaron)
|
16
|
-
old_persistence_token = aaron.persistence_token
|
17
|
-
|
18
|
-
assert aaron.valid_password?(password_for(aaron))
|
19
|
-
assert_equal old_persistence_token, aaron.reload.persistence_token
|
20
|
-
|
21
|
-
# only update it if it is nil
|
22
|
-
assert aaron.update_attribute(:persistence_token, nil)
|
23
|
-
assert aaron.valid_password?(password_for(aaron))
|
24
|
-
assert_not_equal old_persistence_token, aaron.persistence_token
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_before_validate_reset_persistence_token
|
28
|
-
u = User.new
|
29
|
-
refute u.valid?
|
30
|
-
assert_not_nil u.persistence_token
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_forget_all
|
34
|
-
UserSession.allow_http_basic_auth = true
|
35
|
-
|
36
|
-
http_basic_auth_for(users(:ben)) { UserSession.find }
|
37
|
-
http_basic_auth_for(users(:zack)) { UserSession.find(:ziggity_zack) }
|
38
|
-
assert UserSession.find
|
39
|
-
assert UserSession.find(:ziggity_zack)
|
40
|
-
User.forget_all
|
41
|
-
refute UserSession.find
|
42
|
-
refute UserSession.find(:ziggity_zack)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_forget
|
46
|
-
UserSession.allow_http_basic_auth = true
|
47
|
-
|
48
|
-
ben = users(:ben)
|
49
|
-
zack = users(:zack)
|
50
|
-
http_basic_auth_for(ben) { UserSession.find }
|
51
|
-
http_basic_auth_for(zack) { UserSession.find(:ziggity_zack) }
|
52
|
-
|
53
|
-
assert ben.reload.logged_in?
|
54
|
-
assert zack.reload.logged_in?
|
55
|
-
|
56
|
-
ben.forget!
|
57
|
-
|
58
|
-
refute UserSession.find
|
59
|
-
assert UserSession.find(:ziggity_zack)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module ActsAsAuthenticTest
|
6
|
-
class RestfulAuthenticationTest < ActiveSupport::TestCase
|
7
|
-
def setup
|
8
|
-
@old_deprecation_behavior = ::ActiveSupport::Deprecation.behavior
|
9
|
-
::ActiveSupport::Deprecation.behavior = :silence
|
10
|
-
end
|
11
|
-
|
12
|
-
def teardown
|
13
|
-
::ActiveSupport::Deprecation.behavior = @old_deprecation_behavior
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_act_like_restful_authentication_config
|
17
|
-
refute User.act_like_restful_authentication
|
18
|
-
refute Employee.act_like_restful_authentication
|
19
|
-
|
20
|
-
User.act_like_restful_authentication = true
|
21
|
-
assert User.act_like_restful_authentication
|
22
|
-
assert_equal Authlogic::CryptoProviders::Sha1, User.crypto_provider
|
23
|
-
assert defined?(::REST_AUTH_SITE_KEY)
|
24
|
-
assert_equal "", ::REST_AUTH_SITE_KEY
|
25
|
-
assert_equal 1, Authlogic::CryptoProviders::Sha1.stretches
|
26
|
-
|
27
|
-
User.act_like_restful_authentication false
|
28
|
-
refute User.act_like_restful_authentication
|
29
|
-
|
30
|
-
User.crypto_provider = Authlogic::CryptoProviders::Sha512
|
31
|
-
User.transition_from_crypto_providers = []
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_transition_from_restful_authentication_config
|
35
|
-
refute User.transition_from_restful_authentication
|
36
|
-
refute Employee.transition_from_restful_authentication
|
37
|
-
|
38
|
-
User.transition_from_restful_authentication = true
|
39
|
-
assert User.transition_from_restful_authentication
|
40
|
-
assert defined?(::REST_AUTH_SITE_KEY)
|
41
|
-
assert_equal "", ::REST_AUTH_SITE_KEY
|
42
|
-
assert_equal 1, Authlogic::CryptoProviders::Sha1.stretches
|
43
|
-
|
44
|
-
User.transition_from_restful_authentication false
|
45
|
-
refute User.transition_from_restful_authentication
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module ActsAsAuthenticTest
|
6
|
-
class SessionMaintenanceTest < ActiveSupport::TestCase
|
7
|
-
def setup
|
8
|
-
User.log_in_after_create = true
|
9
|
-
User.log_in_after_password_change = true
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_log_in_after_create_config
|
13
|
-
assert User.log_in_after_create
|
14
|
-
User.log_in_after_create = false
|
15
|
-
refute User.log_in_after_create
|
16
|
-
User.log_in_after_create = true
|
17
|
-
assert User.log_in_after_create
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_log_in_after_password_change_config
|
21
|
-
assert User.log_in_after_password_change
|
22
|
-
User.log_in_after_password_change = false
|
23
|
-
refute User.log_in_after_password_change
|
24
|
-
User.log_in_after_password_change = true
|
25
|
-
assert User.log_in_after_password_change
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_login_after_create
|
29
|
-
User.log_in_after_create = true
|
30
|
-
user = User.create(
|
31
|
-
login: "awesome",
|
32
|
-
password: "saweeeet",
|
33
|
-
password_confirmation: "saweeeet",
|
34
|
-
email: "awesome@awesome.com"
|
35
|
-
)
|
36
|
-
assert user.persisted?
|
37
|
-
assert UserSession.find
|
38
|
-
logged_in_user = UserSession.find.user
|
39
|
-
assert_equal logged_in_user, user
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_no_login_after_create
|
43
|
-
old_user = User.create(
|
44
|
-
login: "awesome",
|
45
|
-
password: "saweeeet",
|
46
|
-
password_confirmation: "saweeeet",
|
47
|
-
email: "awesome@awesome.com"
|
48
|
-
)
|
49
|
-
User.log_in_after_create = false
|
50
|
-
user2 = User.create(
|
51
|
-
login: "awesome2",
|
52
|
-
password: "saweeeet2",
|
53
|
-
password_confirmation: "saweeeet2",
|
54
|
-
email: "awesome2@awesome.com"
|
55
|
-
)
|
56
|
-
assert user2.persisted?
|
57
|
-
logged_in_user = UserSession.find.user
|
58
|
-
assert_not_equal logged_in_user, user2
|
59
|
-
assert_equal logged_in_user, old_user
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_updating_session_with_failed_magic_state
|
63
|
-
ben = users(:ben)
|
64
|
-
ben.confirmed = false
|
65
|
-
ben.password = "newpasswd"
|
66
|
-
ben.password_confirmation = "newpasswd"
|
67
|
-
assert ben.save
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_update_session_after_password_modify
|
71
|
-
User.log_in_after_password_change = true
|
72
|
-
ben = users(:ben)
|
73
|
-
UserSession.create(ben)
|
74
|
-
old_session_key = controller.session["user_credentials"]
|
75
|
-
old_cookie_key = controller.cookies["user_credentials"]
|
76
|
-
ben.password = "newpasswd"
|
77
|
-
ben.password_confirmation = "newpasswd"
|
78
|
-
assert ben.save
|
79
|
-
assert controller.session["user_credentials"]
|
80
|
-
assert controller.cookies["user_credentials"]
|
81
|
-
assert_not_equal controller.session["user_credentials"], old_session_key
|
82
|
-
assert_not_equal controller.cookies["user_credentials"], old_cookie_key
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_no_update_session_after_password_modify
|
86
|
-
User.log_in_after_password_change = false
|
87
|
-
ben = users(:ben)
|
88
|
-
UserSession.create(ben)
|
89
|
-
old_session_key = controller.session["user_credentials"]
|
90
|
-
old_cookie_key = controller.cookies["user_credentials"]
|
91
|
-
ben.password = "newpasswd"
|
92
|
-
ben.password_confirmation = "newpasswd"
|
93
|
-
assert ben.save
|
94
|
-
assert controller.session["user_credentials"]
|
95
|
-
assert controller.cookies["user_credentials"]
|
96
|
-
assert_equal controller.session["user_credentials"], old_session_key
|
97
|
-
assert_equal controller.cookies["user_credentials"], old_cookie_key
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_no_session_update_after_modify
|
101
|
-
ben = users(:ben)
|
102
|
-
UserSession.create(ben)
|
103
|
-
old_session_key = controller.session["user_credentials"]
|
104
|
-
old_cookie_key = controller.cookies["user_credentials"]
|
105
|
-
ben.first_name = "Ben"
|
106
|
-
assert ben.save
|
107
|
-
assert_equal controller.session["user_credentials"], old_session_key
|
108
|
-
assert_equal controller.cookies["user_credentials"], old_cookie_key
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_creating_other_user
|
112
|
-
ben = users(:ben)
|
113
|
-
UserSession.create(ben)
|
114
|
-
old_session_key = controller.session["user_credentials"]
|
115
|
-
old_cookie_key = controller.cookies["user_credentials"]
|
116
|
-
user = User.create(
|
117
|
-
login: "awesome",
|
118
|
-
password: "saweet", # Password is too short, user invalid
|
119
|
-
password_confirmation: "saweet",
|
120
|
-
email: "awesome@saweet.com"
|
121
|
-
)
|
122
|
-
refute user.persisted?
|
123
|
-
assert_equal controller.session["user_credentials"], old_session_key
|
124
|
-
assert_equal controller.cookies["user_credentials"], old_cookie_key
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_updating_other_user
|
128
|
-
ben = users(:ben)
|
129
|
-
UserSession.create(ben)
|
130
|
-
old_session_key = controller.session["user_credentials"]
|
131
|
-
old_cookie_key = controller.cookies["user_credentials"]
|
132
|
-
zack = users(:zack)
|
133
|
-
zack.password = "newpasswd"
|
134
|
-
zack.password_confirmation = "newpasswd"
|
135
|
-
assert zack.save
|
136
|
-
assert_equal controller.session["user_credentials"], old_session_key
|
137
|
-
assert_equal controller.cookies["user_credentials"], old_cookie_key
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_resetting_password_when_logged_out
|
141
|
-
ben = users(:ben)
|
142
|
-
refute UserSession.find
|
143
|
-
ben.password = "newpasswd"
|
144
|
-
ben.password_confirmation = "newpasswd"
|
145
|
-
assert ben.save
|
146
|
-
assert UserSession.find
|
147
|
-
assert_equal ben, UserSession.find.record
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module ActsAsAuthenticTest
|
6
|
-
class SingleAccessTest < ActiveSupport::TestCase
|
7
|
-
def test_change_single_access_token_with_password_config
|
8
|
-
refute User.change_single_access_token_with_password
|
9
|
-
refute Employee.change_single_access_token_with_password
|
10
|
-
|
11
|
-
User.change_single_access_token_with_password = true
|
12
|
-
assert User.change_single_access_token_with_password
|
13
|
-
User.change_single_access_token_with_password false
|
14
|
-
refute User.change_single_access_token_with_password
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_validates_uniqueness_of_single_access_token
|
18
|
-
u = User.new
|
19
|
-
u.single_access_token = users(:ben).single_access_token
|
20
|
-
refute u.valid?
|
21
|
-
refute u.errors[:single_access_token].empty?
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_before_validation_reset_single_access_token
|
25
|
-
u = User.new
|
26
|
-
refute u.valid?
|
27
|
-
assert_not_nil u.single_access_token
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_after_password_set_reset_single_access_token
|
31
|
-
User.change_single_access_token_with_password = true
|
32
|
-
|
33
|
-
ben = users(:ben)
|
34
|
-
old_single_access_token = ben.single_access_token
|
35
|
-
ben.password = "new_pass"
|
36
|
-
assert_not_equal old_single_access_token, ben.single_access_token
|
37
|
-
|
38
|
-
User.change_single_access_token_with_password = false
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_after_password_set_is_not_called
|
42
|
-
ldaper = Ldaper.new
|
43
|
-
assert ldaper.save
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/test/adapter_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module Authlogic
|
6
|
-
module ControllerAdapters
|
7
|
-
class AbstractAdapterTest < ActiveSupport::TestCase
|
8
|
-
def test_controller
|
9
|
-
controller = Class.new(MockController) do
|
10
|
-
def controller.an_arbitrary_method
|
11
|
-
"bar"
|
12
|
-
end
|
13
|
-
end.new
|
14
|
-
adapter = Authlogic::ControllerAdapters::AbstractAdapter.new(controller)
|
15
|
-
|
16
|
-
assert_equal controller, adapter.controller
|
17
|
-
assert controller.params.equal?(adapter.params)
|
18
|
-
assert adapter.respond_to?(:an_arbitrary_method)
|
19
|
-
assert_equal "bar", adapter.an_arbitrary_method
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
class AuthenticatesManyTest < ActiveSupport::TestCase
|
6
|
-
def test_employee_sessions
|
7
|
-
binary_logic = companies(:binary_logic)
|
8
|
-
|
9
|
-
# Drew is a binary_logic employee, authentication succeeds
|
10
|
-
drew = employees(:drew)
|
11
|
-
set_session_for(drew)
|
12
|
-
assert binary_logic.employee_sessions.find
|
13
|
-
|
14
|
-
# Jennifer is not a binary_logic employee, authentication fails
|
15
|
-
jennifer = employees(:jennifer)
|
16
|
-
set_session_for(jennifer)
|
17
|
-
refute binary_logic.employee_sessions.find
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_user_sessions
|
21
|
-
binary_logic = companies(:binary_logic)
|
22
|
-
|
23
|
-
# Ben is a binary_logic user, authentication succeeds
|
24
|
-
ben = users(:ben)
|
25
|
-
set_session_for(ben, binary_logic)
|
26
|
-
assert binary_logic.user_sessions.find
|
27
|
-
|
28
|
-
# Zack is not a binary_logic user, authentication fails
|
29
|
-
zack = users(:zack)
|
30
|
-
set_session_for(zack, binary_logic)
|
31
|
-
refute binary_logic.user_sessions.find
|
32
|
-
end
|
33
|
-
end
|
data/test/config_test.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
class ConfigTest < ActiveSupport::TestCase
|
6
|
-
def setup
|
7
|
-
@klass = Class.new {
|
8
|
-
extend Authlogic::Config
|
9
|
-
|
10
|
-
def self.foobar(value = nil)
|
11
|
-
rw_config(:foobar_field, value, "default_foobar")
|
12
|
-
end
|
13
|
-
}
|
14
|
-
|
15
|
-
@subklass = Class.new(@klass)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_config
|
19
|
-
assert_equal({}, @klass.acts_as_authentic_config)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_rw_config_read_with_default
|
23
|
-
assert "default_foobar", @klass.foobar
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_rw_config_write
|
27
|
-
assert_equal "my_foobar", @klass.foobar("my_foobar")
|
28
|
-
assert_equal "my_foobar", @klass.foobar
|
29
|
-
|
30
|
-
assert_equal "my_new_foobar", @klass.foobar("my_new_foobar")
|
31
|
-
assert_equal "my_new_foobar", @klass.foobar
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_subclass_rw_config_write
|
35
|
-
assert_equal "subklass_foobar", @subklass.foobar("subklass_foobar")
|
36
|
-
assert_equal "default_foobar", @klass.foobar
|
37
|
-
end
|
38
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module CryptoProviderTest
|
6
|
-
class AES256Test < ActiveSupport::TestCase
|
7
|
-
def test_encrypt
|
8
|
-
assert Authlogic::CryptoProviders::AES256.encrypt("mypass")
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_matches
|
12
|
-
hash = Authlogic::CryptoProviders::AES256.encrypt("mypass")
|
13
|
-
assert Authlogic::CryptoProviders::AES256.matches?(hash, "mypass")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module CryptoProviderTest
|
6
|
-
class BCryptTest < ActiveSupport::TestCase
|
7
|
-
def test_encrypt
|
8
|
-
assert Authlogic::CryptoProviders::BCrypt.encrypt("mypass")
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_matches
|
12
|
-
hash = Authlogic::CryptoProviders::BCrypt.encrypt("mypass")
|
13
|
-
assert Authlogic::CryptoProviders::BCrypt.matches?(hash, "mypass")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "test_helper"
|
4
|
-
|
5
|
-
module CryptoProviderTest
|
6
|
-
class SCryptTest < ActiveSupport::TestCase
|
7
|
-
def test_encrypt
|
8
|
-
assert Authlogic::CryptoProviders::SCrypt.encrypt("mypass")
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_matches
|
12
|
-
hash = Authlogic::CryptoProviders::SCrypt.encrypt("mypass")
|
13
|
-
assert Authlogic::CryptoProviders::SCrypt.matches?(hash, "mypass")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|