authn 2.6.0 → 3.1.0
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/lib/authn/model.rb +8 -3
- data/lib/authn/version.rb +1 -1
- data/test/lib/authn/model_test.rb +21 -23
- data/test/lib/authn/session_test.rb +0 -1
- data/test/lib/authn/version_test.rb +1 -1
- metadata +4 -4
data/lib/authn/model.rb
CHANGED
@@ -5,9 +5,8 @@ module AuthN
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
|
-
def has_authentication(
|
9
|
-
options
|
10
|
-
config.merge! options
|
8
|
+
def has_authentication(options = {})
|
9
|
+
merge_config_with options
|
11
10
|
end
|
12
11
|
|
13
12
|
def config=(options)
|
@@ -38,6 +37,12 @@ module AuthN
|
|
38
37
|
# Return false if account was found and password didn't match
|
39
38
|
# Return nil if account wasn't found OR password wasn't given
|
40
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def merge_config_with(options)
|
44
|
+
config.merge! options.merge! AuthN.config
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
data/lib/authn/version.rb
CHANGED
@@ -3,64 +3,62 @@ require_relative '../../helper'
|
|
3
3
|
|
4
4
|
class TestAuthNModel < MiniTest::Unit::TestCase
|
5
5
|
def setup
|
6
|
-
|
6
|
+
@account = Account.new
|
7
7
|
end
|
8
8
|
|
9
|
-
# def has_authentication(
|
10
|
-
# options
|
11
|
-
# options.merge! AuthN.config if AuthN.config.to_hash
|
12
|
-
# options.merge! o unless o.empty?
|
13
|
-
# config options
|
9
|
+
# def has_authentication(options = {})
|
10
|
+
# merge_config_with options
|
14
11
|
# end
|
15
|
-
def
|
16
|
-
|
17
|
-
expected =
|
18
|
-
assert_equal expected, actual
|
12
|
+
def test_model_gets_has_authentication_method
|
13
|
+
assert Account.public_methods.include? :has_authentication
|
19
14
|
end
|
20
15
|
|
21
|
-
def
|
16
|
+
def test_has_authentication_config_combinds_with_default_config
|
22
17
|
actual =
|
23
18
|
expected =
|
24
19
|
assert_equal expected, actual
|
25
20
|
end
|
26
21
|
|
27
|
-
def
|
22
|
+
def test_has_autehntication_config_merges_in_model_config
|
28
23
|
actual =
|
29
24
|
expected =
|
30
25
|
assert_equal expected, actual
|
31
26
|
end
|
32
27
|
|
33
|
-
def
|
28
|
+
# def config=(options)
|
29
|
+
# @@config = options
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# def config
|
33
|
+
# @@config ||= AuthN::Config.new
|
34
|
+
# end
|
35
|
+
def test_model_has_class_wide_config_settings
|
34
36
|
actual =
|
35
37
|
expected =
|
36
38
|
assert_equal expected, actual
|
37
39
|
end
|
38
40
|
|
39
41
|
# def authenticate(identifiers = {})
|
40
|
-
# password = identifiers.delete
|
41
|
-
# criteria =
|
42
|
+
# password = identifiers.delete AuthN.config.login_password_key
|
43
|
+
# criteria = send AuthN.config.model_critera_method, identifiers
|
42
44
|
# instance = criteria.first
|
43
45
|
# if instance && password
|
44
|
-
#
|
45
|
-
# instance
|
46
|
-
# else
|
47
|
-
# false
|
48
|
-
# end
|
46
|
+
# instance.authenticate(password) ? instance : false
|
49
47
|
# end
|
50
48
|
# end
|
51
|
-
def
|
49
|
+
def test_authenticate_returns_instance_if_given_good_credentials
|
52
50
|
actual =
|
53
51
|
expected =
|
54
52
|
assert_equal expected, actual
|
55
53
|
end
|
56
54
|
|
57
|
-
def
|
55
|
+
def test_authenticate_returns_false_if_bad_password
|
58
56
|
actual =
|
59
57
|
expected =
|
60
58
|
assert_equal expected, actual
|
61
59
|
end
|
62
60
|
|
63
|
-
def
|
61
|
+
def test_authenticate_return_nil_if_no_record_found
|
64
62
|
actual =
|
65
63
|
expected =
|
66
64
|
assert_equal expected, actual
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -132,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
segments:
|
134
134
|
- 0
|
135
|
-
hash:
|
135
|
+
hash: 3456173400469928444
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: '0'
|
142
142
|
segments:
|
143
143
|
- 0
|
144
|
-
hash:
|
144
|
+
hash: 3456173400469928444
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
147
|
rubygems_version: 1.8.24
|