summaryrefslogtreecommitdiffstats
path: root/test/unit/auth_source_ldap_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/auth_source_ldap_test.rb')
-rw-r--r--test/unit/auth_source_ldap_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/unit/auth_source_ldap_test.rb b/test/unit/auth_source_ldap_test.rb
index 32feda25b..f6eefed02 100644
--- a/test/unit/auth_source_ldap_test.rb
+++ b/test/unit/auth_source_ldap_test.rb
@@ -40,6 +40,8 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
assert_nil auth_source.attr_mail
assert_equal false, auth_source.onthefly_register
assert_equal false, auth_source.tls
+ assert_equal true, auth_source.verify_peer
+ assert_equal :ldap, auth_source.ldap_mode
assert_nil auth_source.filter
assert_nil auth_source.timeout
end
@@ -77,6 +79,42 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
assert a.valid?
end
+ test 'ldap_mode setter sets tls and verify_peer' do
+ a = AuthSourceLdap.new
+
+ a.ldap_mode = 'ldaps_verify_peer'
+ assert a.tls
+ assert a.verify_peer
+
+ a.ldap_mode = 'ldaps_verify_none'
+ assert a.tls
+ assert !a.verify_peer
+
+ a.ldap_mode = 'ldap'
+ assert !a.tls
+ assert !a.verify_peer
+ end
+
+ test 'ldap_mode getter reads from tls and verify_peer' do
+ a = AuthSourceLdap.new
+
+ a.tls = true
+ a.verify_peer = true
+ assert_equal :ldaps_verify_peer, a.ldap_mode
+
+ a.tls = true
+ a.verify_peer = false
+ assert_equal :ldaps_verify_none, a.ldap_mode
+
+ a.tls = false
+ a.verify_peer = false
+ assert_equal :ldap, a.ldap_mode
+
+ a.tls = false
+ a.verify_peer = true
+ assert_equal :ldap, a.ldap_mode
+ end
+
if ldap_configured?
test '#authenticate with a valid LDAP user should return the user attributes' do
auth = AuthSourceLdap.find(1)