authlogic 3.8.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/lib/authlogic/acts_as_authentic/base.rb +33 -36
  3. data/lib/authlogic/acts_as_authentic/email.rb +8 -141
  4. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +17 -10
  5. data/lib/authlogic/acts_as_authentic/login.rb +14 -165
  6. data/lib/authlogic/acts_as_authentic/magic_columns.rb +13 -10
  7. data/lib/authlogic/acts_as_authentic/password.rb +186 -254
  8. data/lib/authlogic/acts_as_authentic/perishable_token.rb +30 -22
  9. data/lib/authlogic/acts_as_authentic/persistence_token.rb +19 -18
  10. data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
  11. data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +83 -0
  12. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +94 -62
  13. data/lib/authlogic/acts_as_authentic/single_access_token.rb +28 -14
  14. data/lib/authlogic/config.rb +29 -10
  15. data/lib/authlogic/controller_adapters/abstract_adapter.rb +43 -13
  16. data/lib/authlogic/controller_adapters/rack_adapter.rb +11 -5
  17. data/lib/authlogic/controller_adapters/rails_adapter.rb +11 -29
  18. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +8 -2
  19. data/lib/authlogic/cookie_credentials.rb +63 -0
  20. data/lib/authlogic/crypto_providers/bcrypt.rb +24 -18
  21. data/lib/authlogic/crypto_providers/md5/v2.rb +35 -0
  22. data/lib/authlogic/crypto_providers/md5.rb +8 -6
  23. data/lib/authlogic/crypto_providers/scrypt.rb +24 -17
  24. data/lib/authlogic/crypto_providers/sha1/v2.rb +41 -0
  25. data/lib/authlogic/crypto_providers/sha1.rb +12 -5
  26. data/lib/authlogic/crypto_providers/sha256/v2.rb +58 -0
  27. data/lib/authlogic/crypto_providers/sha256.rb +18 -9
  28. data/lib/authlogic/crypto_providers/sha512/v2.rb +39 -0
  29. data/lib/authlogic/crypto_providers/sha512.rb +9 -26
  30. data/lib/authlogic/crypto_providers.rb +77 -1
  31. data/lib/authlogic/errors.rb +35 -0
  32. data/lib/authlogic/i18n/translator.rb +4 -1
  33. data/lib/authlogic/i18n.rb +29 -20
  34. data/lib/authlogic/random.rb +12 -28
  35. data/lib/authlogic/session/base.rb +2087 -33
  36. data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
  37. data/lib/authlogic/test_case/mock_controller.rb +7 -4
  38. data/lib/authlogic/test_case/mock_cookie_jar.rb +19 -3
  39. data/lib/authlogic/test_case/mock_logger.rb +2 -0
  40. data/lib/authlogic/test_case/mock_request.rb +8 -3
  41. data/lib/authlogic/test_case/rails_request_adapter.rb +5 -2
  42. data/lib/authlogic/test_case.rb +74 -2
  43. data/lib/authlogic/version.rb +22 -0
  44. data/lib/authlogic.rb +33 -54
  45. metadata +208 -234
  46. data/.github/ISSUE_TEMPLATE.md +0 -13
  47. data/.gitignore +0 -14
  48. data/.rubocop.yml +0 -33
  49. data/.rubocop_todo.yml +0 -391
  50. data/.travis.yml +0 -48
  51. data/CHANGELOG.md +0 -5
  52. data/CONTRIBUTING.md +0 -60
  53. data/Gemfile +0 -5
  54. data/LICENSE +0 -20
  55. data/README.md +0 -294
  56. data/Rakefile +0 -21
  57. data/authlogic.gemspec +0 -27
  58. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +0 -70
  59. data/lib/authlogic/acts_as_authentic/validations_scope.rb +0 -32
  60. data/lib/authlogic/authenticates_many/association.rb +0 -50
  61. data/lib/authlogic/authenticates_many/base.rb +0 -65
  62. data/lib/authlogic/crypto_providers/aes256.rb +0 -66
  63. data/lib/authlogic/crypto_providers/wordpress.rb +0 -43
  64. data/lib/authlogic/regex.rb +0 -48
  65. data/lib/authlogic/session/activation.rb +0 -70
  66. data/lib/authlogic/session/active_record_trickery.rb +0 -61
  67. data/lib/authlogic/session/brute_force_protection.rb +0 -120
  68. data/lib/authlogic/session/callbacks.rb +0 -105
  69. data/lib/authlogic/session/cookies.rb +0 -244
  70. data/lib/authlogic/session/existence.rb +0 -93
  71. data/lib/authlogic/session/foundation.rb +0 -55
  72. data/lib/authlogic/session/http_auth.rb +0 -100
  73. data/lib/authlogic/session/id.rb +0 -48
  74. data/lib/authlogic/session/klass.rb +0 -70
  75. data/lib/authlogic/session/magic_columns.rb +0 -116
  76. data/lib/authlogic/session/magic_states.rb +0 -76
  77. data/lib/authlogic/session/params.rb +0 -116
  78. data/lib/authlogic/session/password.rb +0 -308
  79. data/lib/authlogic/session/perishable_token.rb +0 -23
  80. data/lib/authlogic/session/persistence.rb +0 -71
  81. data/lib/authlogic/session/priority_record.rb +0 -35
  82. data/lib/authlogic/session/scopes.rb +0 -119
  83. data/lib/authlogic/session/session.rb +0 -67
  84. data/lib/authlogic/session/timeout.rb +0 -103
  85. data/lib/authlogic/session/unauthorized_record.rb +0 -51
  86. data/lib/authlogic/session/validation.rb +0 -93
  87. data/test/acts_as_authentic_test/base_test.rb +0 -25
  88. data/test/acts_as_authentic_test/email_test.rb +0 -240
  89. data/test/acts_as_authentic_test/logged_in_status_test.rb +0 -62
  90. data/test/acts_as_authentic_test/login_test.rb +0 -156
  91. data/test/acts_as_authentic_test/magic_columns_test.rb +0 -27
  92. data/test/acts_as_authentic_test/password_test.rb +0 -249
  93. data/test/acts_as_authentic_test/perishable_token_test.rb +0 -90
  94. data/test/acts_as_authentic_test/persistence_token_test.rb +0 -56
  95. data/test/acts_as_authentic_test/restful_authentication_test.rb +0 -37
  96. data/test/acts_as_authentic_test/session_maintenance_test.rb +0 -96
  97. data/test/acts_as_authentic_test/single_access_test.rb +0 -44
  98. data/test/authenticates_many_test.rb +0 -31
  99. data/test/config_test.rb +0 -36
  100. data/test/crypto_provider_test/aes256_test.rb +0 -14
  101. data/test/crypto_provider_test/bcrypt_test.rb +0 -14
  102. data/test/crypto_provider_test/scrypt_test.rb +0 -14
  103. data/test/crypto_provider_test/sha1_test.rb +0 -23
  104. data/test/crypto_provider_test/sha256_test.rb +0 -14
  105. data/test/crypto_provider_test/sha512_test.rb +0 -14
  106. data/test/fixtures/companies.yml +0 -5
  107. data/test/fixtures/employees.yml +0 -17
  108. data/test/fixtures/projects.yml +0 -3
  109. data/test/fixtures/users.yml +0 -41
  110. data/test/gemfiles/Gemfile.rails-3.2.x +0 -7
  111. data/test/gemfiles/Gemfile.rails-4.0.x +0 -7
  112. data/test/gemfiles/Gemfile.rails-4.1.x +0 -7
  113. data/test/gemfiles/Gemfile.rails-4.2.x +0 -7
  114. data/test/gemfiles/Gemfile.rails-5.0.x +0 -6
  115. data/test/gemfiles/Gemfile.rails-5.1.x +0 -6
  116. data/test/gemfiles/Gemfile.rails-5.2.x +0 -6
  117. data/test/i18n/lol.yml +0 -4
  118. data/test/i18n_test.rb +0 -33
  119. data/test/libs/affiliate.rb +0 -7
  120. data/test/libs/company.rb +0 -6
  121. data/test/libs/employee.rb +0 -7
  122. data/test/libs/employee_session.rb +0 -2
  123. data/test/libs/ldaper.rb +0 -3
  124. data/test/libs/project.rb +0 -3
  125. data/test/libs/user.rb +0 -7
  126. data/test/libs/user_session.rb +0 -25
  127. data/test/random_test.rb +0 -43
  128. data/test/session_test/activation_test.rb +0 -43
  129. data/test/session_test/active_record_trickery_test.rb +0 -75
  130. data/test/session_test/brute_force_protection_test.rb +0 -108
  131. data/test/session_test/callbacks_test.rb +0 -34
  132. data/test/session_test/cookies_test.rb +0 -201
  133. data/test/session_test/credentials_test.rb +0 -0
  134. data/test/session_test/existence_test.rb +0 -75
  135. data/test/session_test/foundation_test.rb +0 -6
  136. data/test/session_test/http_auth_test.rb +0 -56
  137. data/test/session_test/id_test.rb +0 -17
  138. data/test/session_test/klass_test.rb +0 -40
  139. data/test/session_test/magic_columns_test.rb +0 -62
  140. data/test/session_test/magic_states_test.rb +0 -58
  141. data/test/session_test/params_test.rb +0 -53
  142. data/test/session_test/password_test.rb +0 -105
  143. data/test/session_test/perishability_test.rb +0 -15
  144. data/test/session_test/persistence_test.rb +0 -32
  145. data/test/session_test/scopes_test.rb +0 -60
  146. data/test/session_test/session_test.rb +0 -78
  147. data/test/session_test/timeout_test.rb +0 -82
  148. data/test/session_test/unauthorized_record_test.rb +0 -13
  149. data/test/session_test/validation_test.rb +0 -23
  150. data/test/test_helper.rb +0 -233
@@ -1,96 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActsAsAuthenticTest
4
- class SessionMaintenanceTest < ActiveSupport::TestCase
5
- def test_maintain_sessions_config
6
- assert User.maintain_sessions
7
- User.maintain_sessions = false
8
- refute User.maintain_sessions
9
- User.maintain_sessions true
10
- assert User.maintain_sessions
11
- end
12
-
13
- def test_login_after_create
14
- user = User.create(
15
- :login => "awesome",
16
- :password => "saweeeet",
17
- :password_confirmation => "saweeeet",
18
- :email => "awesome@awesome.com"
19
- )
20
- assert user.persisted?
21
- assert UserSession.find
22
- end
23
-
24
- def test_updating_session_with_failed_magic_state
25
- ben = users(:ben)
26
- ben.confirmed = false
27
- ben.password = "newpasswd"
28
- ben.password_confirmation = "newpasswd"
29
- assert ben.save
30
- end
31
-
32
- def test_update_session_after_password_modify
33
- ben = users(:ben)
34
- UserSession.create(ben)
35
- old_session_key = controller.session["user_credentials"]
36
- old_cookie_key = controller.cookies["user_credentials"]
37
- ben.password = "newpasswd"
38
- ben.password_confirmation = "newpasswd"
39
- assert ben.save
40
- assert controller.session["user_credentials"]
41
- assert controller.cookies["user_credentials"]
42
- assert_not_equal controller.session["user_credentials"], old_session_key
43
- assert_not_equal controller.cookies["user_credentials"], old_cookie_key
44
- end
45
-
46
- def test_no_session_update_after_modify
47
- ben = users(:ben)
48
- UserSession.create(ben)
49
- old_session_key = controller.session["user_credentials"]
50
- old_cookie_key = controller.cookies["user_credentials"]
51
- ben.first_name = "Ben"
52
- assert ben.save
53
- assert_equal controller.session["user_credentials"], old_session_key
54
- assert_equal controller.cookies["user_credentials"], old_cookie_key
55
- end
56
-
57
- def test_creating_other_user
58
- ben = users(:ben)
59
- UserSession.create(ben)
60
- old_session_key = controller.session["user_credentials"]
61
- old_cookie_key = controller.cookies["user_credentials"]
62
- user = User.create(
63
- :login => "awesome",
64
- :password => "saweet", # Password is too short, user invalid
65
- :password_confirmation => "saweet",
66
- :email => "awesome@saweet.com"
67
- )
68
- refute user.persisted?
69
- assert_equal controller.session["user_credentials"], old_session_key
70
- assert_equal controller.cookies["user_credentials"], old_cookie_key
71
- end
72
-
73
- def test_updating_other_user
74
- ben = users(:ben)
75
- UserSession.create(ben)
76
- old_session_key = controller.session["user_credentials"]
77
- old_cookie_key = controller.cookies["user_credentials"]
78
- zack = users(:zack)
79
- zack.password = "newpasswd"
80
- zack.password_confirmation = "newpasswd"
81
- assert zack.save
82
- assert_equal controller.session["user_credentials"], old_session_key
83
- assert_equal controller.cookies["user_credentials"], old_cookie_key
84
- end
85
-
86
- def test_resetting_password_when_logged_out
87
- ben = users(:ben)
88
- refute UserSession.find
89
- ben.password = "newpasswd"
90
- ben.password_confirmation = "newpasswd"
91
- assert ben.save
92
- assert UserSession.find
93
- assert_equal ben, UserSession.find.record
94
- end
95
- end
96
- end
@@ -1,44 +0,0 @@
1
- require 'test_helper'
2
-
3
- module ActsAsAuthenticTest
4
- class SingleAccessTest < ActiveSupport::TestCase
5
- def test_change_single_access_token_with_password_config
6
- refute User.change_single_access_token_with_password
7
- refute Employee.change_single_access_token_with_password
8
-
9
- User.change_single_access_token_with_password = true
10
- assert User.change_single_access_token_with_password
11
- User.change_single_access_token_with_password false
12
- refute User.change_single_access_token_with_password
13
- end
14
-
15
- def test_validates_uniqueness_of_single_access_token
16
- u = User.new
17
- u.single_access_token = users(:ben).single_access_token
18
- refute u.valid?
19
- refute u.errors[:single_access_token].empty?
20
- end
21
-
22
- def test_before_validation_reset_single_access_token
23
- u = User.new
24
- refute u.valid?
25
- assert_not_nil u.single_access_token
26
- end
27
-
28
- def test_after_password_set_reset_single_access_token
29
- User.change_single_access_token_with_password = true
30
-
31
- ben = users(:ben)
32
- old_single_access_token = ben.single_access_token
33
- ben.password = "new_pass"
34
- assert_not_equal old_single_access_token, ben.single_access_token
35
-
36
- User.change_single_access_token_with_password = false
37
- end
38
-
39
- def test_after_password_set_is_not_called
40
- ldaper = Ldaper.new
41
- assert ldaper.save
42
- end
43
- end
44
- end
@@ -1,31 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AuthenticatesManyTest < ActiveSupport::TestCase
4
- def test_employee_sessions
5
- binary_logic = companies(:binary_logic)
6
-
7
- # Drew is a binary_logic employee, authentication succeeds
8
- drew = employees(:drew)
9
- set_session_for(drew)
10
- assert binary_logic.employee_sessions.find
11
-
12
- # Jennifer is not a binary_logic employee, authentication fails
13
- jennifer = employees(:jennifer)
14
- set_session_for(jennifer)
15
- refute binary_logic.employee_sessions.find
16
- end
17
-
18
- def test_user_sessions
19
- binary_logic = companies(:binary_logic)
20
-
21
- # Ben is a binary_logic user, authentication succeeds
22
- ben = users(:ben)
23
- set_session_for(ben, binary_logic)
24
- assert binary_logic.user_sessions.find
25
-
26
- # Zack is not a binary_logic user, authentication fails
27
- zack = users(:zack)
28
- set_session_for(zack, binary_logic)
29
- refute binary_logic.user_sessions.find
30
- end
31
- end
data/test/config_test.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigTest < ActiveSupport::TestCase
4
- def setup
5
- @klass = Class.new {
6
- extend Authlogic::Config
7
-
8
- def self.foobar(value = nil)
9
- rw_config(:foobar_field, value, 'default_foobar')
10
- end
11
- }
12
-
13
- @subklass = Class.new(@klass)
14
- end
15
-
16
- def test_config
17
- assert_equal({}, @klass.acts_as_authentic_config)
18
- end
19
-
20
- def test_rw_config_read_with_default
21
- assert 'default_foobar', @klass.foobar
22
- end
23
-
24
- def test_rw_config_write
25
- assert_equal 'my_foobar', @klass.foobar('my_foobar')
26
- assert_equal 'my_foobar', @klass.foobar
27
-
28
- assert_equal 'my_new_foobar', @klass.foobar('my_new_foobar')
29
- assert_equal 'my_new_foobar', @klass.foobar
30
- end
31
-
32
- def test_subclass_rw_config_write
33
- assert_equal 'subklass_foobar', @subklass.foobar('subklass_foobar')
34
- assert_equal 'default_foobar', @klass.foobar
35
- end
36
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class AES256Test < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::AES256.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::AES256.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::AES256.matches?(hash, "mypass")
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class BCryptTest < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::BCrypt.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::BCrypt.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::BCrypt.matches?(hash, "mypass")
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class SCryptTest < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::SCrypt.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::SCrypt.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::SCrypt.matches?(hash, "mypass")
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class Sha1Test < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::Sha1.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::Sha1.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::Sha1.matches?(hash, "mypass")
12
- end
13
-
14
- def test_old_restful_authentication_passwords
15
- password = "test"
16
- salt = "7e3041ebc2fc05a40c60028e2c4901a81035d3cd"
17
- digest = "00742970dc9e6319f8019fd54864d3ea740f04b1"
18
- Authlogic::CryptoProviders::Sha1.stretches = 1
19
- assert Authlogic::CryptoProviders::Sha1.matches?(digest, nil, salt, password, nil)
20
- Authlogic::CryptoProviders::Sha1.stretches = 10
21
- end
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class Sha256Test < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::Sha256.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::Sha256.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::Sha256.matches?(hash, "mypass")
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module CryptoProviderTest
4
- class Sha512Test < ActiveSupport::TestCase
5
- def test_encrypt
6
- assert Authlogic::CryptoProviders::Sha512.encrypt("mypass")
7
- end
8
-
9
- def test_matches
10
- hash = Authlogic::CryptoProviders::Sha512.encrypt("mypass")
11
- assert Authlogic::CryptoProviders::Sha512.matches?(hash, "mypass")
12
- end
13
- end
14
- end
@@ -1,5 +0,0 @@
1
- binary_logic:
2
- name: Binary Logic
3
-
4
- logic_over_data:
5
- name: Logic Over Data
@@ -1,17 +0,0 @@
1
- drew:
2
- company: binary_logic
3
- email: dgainor@binarylogic.com
4
- password_salt: <%= salt = Authlogic::Random.hex_token %>
5
- crypted_password: '<%= Employee.crypto_provider.encrypt("drewrocks" + salt) %>'
6
- persistence_token: 5273d85ed156e9dbd6a7c1438d319ef8c8d41dd24368db6c222de11346c7b11e53ee08d45ecf619b1c1dc91233d22b372482b751b066d0a6f6f9bac42eacaabf
7
- first_name: Drew
8
- last_name: Gainor
9
-
10
- jennifer:
11
- company: logic_over_data
12
- email: jjohnson@logicoverdata.com
13
- password_salt: <%= salt = Authlogic::Random.hex_token %>
14
- crypted_password: '<%= Employee.crypto_provider.encrypt("jenniferocks" + salt) %>'
15
- persistence_token: 2be52a8f741ad00056e6f94eb6844d5316527206da7a3a5e3d0e14d19499ef9fe4c47c89b87febb59a2b41a69edfb4733b6b79302040f3de83f297c6991c75a2
16
- first_name: Jennifer
17
- last_name: Johnson
@@ -1,3 +0,0 @@
1
- web_services:
2
- name: web services
3
- users: ben, zack
@@ -1,41 +0,0 @@
1
- # NB :ben and :zack use the legacy crypto provider (Sha512) ... when they're
2
- # tested for valid_password?() it will transition their password
3
- # (re: test/libs/user.rb). This could have unintended side-effects (like auto-
4
- # resetting their persistence token when checking password) -- one solution
5
- # is to just switch in users(:aaron) for those tests.
6
- ben:
7
- company: binary_logic
8
- projects: web_services
9
- login: bjohnson
10
- password_salt: <%= salt = Authlogic::Random.hex_token %>
11
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("benrocks" + salt) %>
12
- persistence_token: 6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
13
- single_access_token: <%= Authlogic::Random.friendly_token %>
14
- perishable_token: <%= Authlogic::Random.friendly_token %>
15
- email: bjohnson@binarylogic.com
16
- first_name: Ben
17
- last_name: Johnson
18
-
19
- zack:
20
- company: logic_over_data
21
- projects: web_services
22
- login: zackham
23
- password_salt: <%= salt = Authlogic::Random.hex_token %>
24
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt("zackrocks" + salt) %>
25
- persistence_token: fd3c2d5ce09ab98e7547d21f1b3dcf9158a9a19b5d3022c0402f32ae197019fce3fdbc6614d7ee57d719bae53bb089e30edc9e5d6153e5bc3afca0ac1d320342
26
- single_access_token: <%= Authlogic::Random.friendly_token %>
27
- email: zham@ziggityzack.com
28
- first_name: Zack
29
- last_name: Ham
30
-
31
- aaron:
32
- company: cigital
33
- projects: web_services
34
- login: abedra
35
- crypted_password: <%= Authlogic::CryptoProviders::SCrypt.encrypt("aaronrocks") %>
36
- persistence_token: e3d853f5aa0dacac5c257d03c4e097a3a7f51b182a8fc4f62096d05e939b019855aff0290157ac854e4195f13284ff5223f1996d0fd073e7e360171de54db278
37
- single_access_token: <%= Authlogic::Random.friendly_token %>
38
- perishable_token: <%= Authlogic::Random.friendly_token %>
39
- email: abedra@cigital.com
40
- first_name: Aaron
41
- last_name: Bedra
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "3.2.22"
5
- gem "activesupport", "3.2.22"
6
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
7
- gem 'sqlite3', :platforms => :ruby
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 4.0.3"
5
- gem "activesupport", "~> 4.0.3"
6
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
7
- gem 'sqlite3', :platforms => :ruby
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 4.1.0"
5
- gem "activesupport", "~> 4.1.0"
6
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
7
- gem 'sqlite3', :platforms => :ruby
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 4.2.0"
5
- gem "activesupport", "~> 4.2.0"
6
- gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
7
- gem 'sqlite3', :platforms => :ruby
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 5.0.0"
5
- gem "activesupport", "~> 5.0.0"
6
- gem 'sqlite3', :platforms => :ruby
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 5.1.0"
5
- gem "activesupport", "~> 5.1.0"
6
- gem 'sqlite3', :platforms => :ruby
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => "./../.."
3
-
4
- gem "activerecord", "~> 5.2.x"
5
- gem "activesupport", "~> 5.2.x"
6
- gem 'sqlite3', :platforms => :ruby
data/test/i18n/lol.yml DELETED
@@ -1,4 +0,0 @@
1
- lol:
2
- authlogic:
3
- error_messages:
4
- email_invalid: LOL email should be valid.
data/test/i18n_test.rb DELETED
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
-
3
- class I18nTest < ActiveSupport::TestCase
4
- def test_uses_authlogic_as_scope_by_default
5
- assert_equal :authlogic, Authlogic::I18n.scope
6
- end
7
-
8
- def test_can_set_scope
9
- assert_nothing_raised { Authlogic::I18n.scope = [:a, :b] }
10
- assert_equal [:a, :b], Authlogic::I18n.scope
11
- Authlogic::I18n.scope = :authlogic
12
- end
13
-
14
- def test_uses_built_in_translator_by_default
15
- assert_equal Authlogic::I18n::Translator, Authlogic::I18n.translator.class
16
- end
17
-
18
- def test_can_set_custom_translator
19
- old_translator = Authlogic::I18n.translator
20
-
21
- assert_nothing_raised do
22
- Authlogic::I18n.translator = Class.new do
23
- def translate(key, options = {})
24
- "Translated: #{key}"
25
- end
26
- end.new
27
- end
28
-
29
- assert_equal "Translated: x", Authlogic::I18n.translate(:x)
30
-
31
- Authlogic::I18n.translator = old_translator
32
- end
33
- end
@@ -1,7 +0,0 @@
1
- class Affiliate < ActiveRecord::Base
2
- acts_as_authentic do |c|
3
- c.crypted_password_field = :pw_hash
4
- end
5
-
6
- belongs_to :company
7
- end
data/test/libs/company.rb DELETED
@@ -1,6 +0,0 @@
1
- class Company < ActiveRecord::Base
2
- authenticates_many :employee_sessions
3
- authenticates_many :user_sessions, scope_cookies: true
4
- has_many :employees, :dependent => :destroy
5
- has_many :users, :dependent => :destroy
6
- end
@@ -1,7 +0,0 @@
1
- class Employee < ActiveRecord::Base
2
- acts_as_authentic do |c|
3
- c.crypto_provider Authlogic::CryptoProviders::AES256
4
- end
5
-
6
- belongs_to :company
7
- end
@@ -1,2 +0,0 @@
1
- class EmployeeSession < Authlogic::Session::Base
2
- end
data/test/libs/ldaper.rb DELETED
@@ -1,3 +0,0 @@
1
- class Ldaper < ActiveRecord::Base
2
- acts_as_authentic
3
- end
data/test/libs/project.rb DELETED
@@ -1,3 +0,0 @@
1
- class Project < ActiveRecord::Base
2
- has_and_belongs_to_many :users
3
- end
data/test/libs/user.rb DELETED
@@ -1,7 +0,0 @@
1
- class User < ActiveRecord::Base
2
- acts_as_authentic do |c|
3
- c.transition_from_crypto_providers Authlogic::CryptoProviders::Sha512
4
- end
5
- belongs_to :company
6
- has_and_belongs_to_many :projects
7
- end
@@ -1,25 +0,0 @@
1
- class UserSession < Authlogic::Session::Base
2
- end
3
-
4
- class BackOfficeUserSession < Authlogic::Session::Base
5
- end
6
-
7
- class WackyUserSession < Authlogic::Session::Base
8
- attr_accessor :counter
9
- authenticate_with User
10
-
11
- def initialize
12
- @counter = 0
13
- super
14
- end
15
-
16
- def persist_by_false
17
- self.counter += 1
18
- return false
19
- end
20
-
21
- def persist_by_true
22
- self.counter += 1
23
- return true
24
- end
25
- end
data/test/random_test.rb DELETED
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RandomTest < ActiveSupport::TestCase
4
- def test_random_tokens_are_indeed_random
5
- # this might fail if you are *really* unlucky :)
6
- with_any_random do
7
- assert_not_equal Authlogic::Random.hex_token, Authlogic::Random.hex_token
8
- assert_not_equal Authlogic::Random.friendly_token, Authlogic::Random.friendly_token
9
- end
10
- end
11
-
12
- private
13
-
14
- def with_any_random(&block)
15
- [true, false].each { |val| with_secure_random_enabled(val, &block) }
16
- end
17
-
18
- def with_secure_random_enabled(enabled = true)
19
- # can't really test SecureRandom if we don't have an implementation
20
- return if enabled && !Authlogic::Random::SecureRandom
21
-
22
- current_sec_rand = Authlogic::Random::SecureRandom
23
- reload_authlogic_with_sec_random!(current_sec_rand, enabled)
24
-
25
- yield
26
- ensure
27
- reload_authlogic_with_sec_random!(current_sec_rand)
28
- end
29
-
30
- def reload_authlogic_with_sec_random!(secure_random, enabled = true)
31
- silence_warnings do
32
- secure_random.parent.const_set(secure_random.name.sub("#{secure_random.parent}::", ''), enabled ? secure_random : nil)
33
- load(File.dirname(__FILE__) + '/../lib/authlogic/random.rb')
34
- end
35
- end
36
-
37
- def silence_warnings
38
- old_verbose, $VERBOSE = $VERBOSE, nil
39
- yield
40
- ensure
41
- $VERBOSE = old_verbose
42
- end
43
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
-
3
- module SessionTest
4
- module ActivationTest
5
- class ClassMethodsTest < ActiveSupport::TestCase
6
- def test_activated
7
- assert UserSession.activated?
8
- Authlogic::Session::Base.controller = nil
9
- refute UserSession.activated?
10
- end
11
-
12
- def test_controller
13
- Authlogic::Session::Base.controller = nil
14
- assert_nil Authlogic::Session::Base.controller
15
- thread1 = Thread.new do
16
- controller = MockController.new
17
- Authlogic::Session::Base.controller = controller
18
- assert_equal controller, Authlogic::Session::Base.controller
19
- end
20
- thread1.join
21
-
22
- assert_nil Authlogic::Session::Base.controller
23
-
24
- thread2 = Thread.new do
25
- controller = MockController.new
26
- Authlogic::Session::Base.controller = controller
27
- assert_equal controller, Authlogic::Session::Base.controller
28
- end
29
- thread2.join
30
-
31
- assert_nil Authlogic::Session::Base.controller
32
- end
33
- end
34
-
35
- class InstanceMethodsTest < ActiveSupport::TestCase
36
- def test_init
37
- UserSession.controller = nil
38
- assert_raise(Authlogic::Session::Activation::NotActivatedError) { UserSession.new }
39
- UserSession.controller = controller
40
- end
41
- end
42
- end
43
- end