activeldap/activeldap@e575577 [master] Fix too much configuration removing

1 view
Skip to first unread message

Kouhei Sutou

unread,
Jun 12, 2018, 12:49:02 AM6/12/18
to activeld...@googlegroups.com
Author
Kouhei Sutou <k...@clear-code.com>
Date
2018-06-12 13:48:06 +0900 (Tue, 12 Jun 2018)
New Revision
e575577e85ce5be69390869934aa31caa591a061
Message
Fix too much configuration removing

GitHub: fix #155

Reported by Juha Erkkilä. Thanks!!!
Modified files
  Modified: lib/active_ldap/configuration.rb (+2 -2)
===================================================================
...
91
92
93
94
95
 
 
96
97
98
...
91
92
93
 
 
94
95
96
97
98
@@ -91,8 +91,8 @@ module ActiveLdap
         @@defined_configurations
       end
 
-      def remove_configuration_by_configuration(config)
-        @@defined_configurations.delete_if {|key, value| value == config}
+      def remove_configuration_by_key(key)
+        @@defined_configurations.delete(key)
       end
 
       CONNECTION_CONFIGURATION_KEYS = [:uri, :base, :adapter]
  Modified: lib/active_ldap/connection.rb (+1 -1)
===================================================================
...
135
136
137
138
 
139
140
141
...
135
136
137
 
138
139
140
141
@@ -135,7 +135,7 @@ module ActiveLdap
         end
         config = configuration(key)
         conn = active_connections[key]
-        remove_configuration_by_configuration(config)
+        remove_configuration_by_key(key)
         active_connections.delete_if {|_key, value| value == conn}
         conn.disconnect! if conn
         config
  Modified: test/test_connection_per_class.rb (+34 -0)
===================================================================
...
57
58
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
61
62
...
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@@ -57,6 +57,40 @@ class TestConnectionPerClass < Test::Unit::TestCase
     assert_equal([sub2_base], sub2_class.find(:all).collect(&:dn))
   end
 
+  def test_multi_same_setup_connections
+    make_ou("Sub")
+    sub_class1 = ou_class("ou=Sub")
+    sub_class2 = ou_class("ou=Sub")
+
+    configuration = current_configuration.symbolize_keys
+    configuration[:scope] = :base
+    current_base = configuration[:base]
+    sub_configuration = configuration.dup
+    sub_base = "ou=Sub,#{current_base}"
+    sub_configuration[:base] = sub_base
+
+    sub_class1.setup_connection(sub_configuration)
+    sub_class2.setup_connection(sub_configuration)
+
+    sub_configuration1 = sub_class1.configuration
+    sub_configuration2 = sub_class2.configuration
+
+    assert_not_nil(sub_configuration1)
+    assert_not_nil(sub_configuration2)
+
+    sub_class1.setup_connection(sub_configuration.dup)
+    sub_class1.prefix = nil
+
+    assert_equal([
+                   sub_configuration1,
+                   sub_configuration2,
+                 ],
+                 [
+                   sub_class1.configuration,
+                   sub_class2.configuration,
+                 ])
+  end
+
   def test_bind
     non_anon_class = ou_class("ou=NonAnonymous")
     anon_class = ou_class("ou=Anonymous")
Reply all
Reply to author
Forward
0 new messages