activeldap 1.2.0 → 1.2.1
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/CHANGES +11 -0
- data/README +6 -3
- data/Rakefile +6 -6
- data/examples/al-admin/config/environment.rb +3 -3
- data/examples/groupadd +1 -1
- data/examples/groupdel +1 -1
- data/examples/groupls +1 -1
- data/examples/groupmod +1 -1
- data/examples/lpasswd +1 -1
- data/examples/ouadd +1 -1
- data/examples/useradd +1 -1
- data/examples/useradd-binary +1 -1
- data/examples/userdel +1 -1
- data/examples/userls +1 -1
- data/examples/usermod +1 -1
- data/examples/usermod-binary-add +1 -1
- data/examples/usermod-binary-add-time +1 -1
- data/examples/usermod-binary-del +1 -1
- data/examples/usermod-lang-add +1 -1
- data/lib/active_ldap.rb +6 -6
- data/lib/active_ldap/adapter/base.rb +14 -1
- data/lib/active_ldap/adapter/jndi.rb +5 -1
- data/lib/active_ldap/adapter/net_ldap.rb +7 -1
- data/lib/active_ldap/association/belongs_to_many.rb +4 -0
- data/lib/active_ldap/association/has_many.rb +5 -5
- data/lib/active_ldap/association/has_many_utils.rb +5 -6
- data/lib/active_ldap/association/has_many_wrap.rb +13 -9
- data/lib/active_ldap/association/proxy.rb +5 -1
- data/lib/active_ldap/associations.rb +1 -1
- data/lib/active_ldap/attributes.rb +7 -3
- data/lib/active_ldap/base.rb +16 -2
- data/lib/active_ldap/distinguished_name.rb +3 -6
- data/lib/active_ldap/operations.rb +11 -8
- data/lib/active_ldap/timeout_stub.rb +1 -1
- data/lib/active_ldap/xml.rb +5 -2
- data/test-unit/History.txt +54 -0
- data/test-unit/Manifest.txt +3 -3
- data/test-unit/README.txt +4 -1
- data/test-unit/images/color-diff.png +0 -0
- data/test-unit/lib/test/unit.rb +23 -42
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +77 -8
- data/test-unit/lib/test/unit/autorunner.rb +13 -2
- data/test-unit/lib/test/unit/collector/load.rb +2 -3
- data/test-unit/lib/test/unit/color-scheme.rb +13 -1
- data/test-unit/lib/test/unit/diff.rb +223 -37
- data/test-unit/lib/test/unit/failure.rb +27 -5
- data/test-unit/lib/test/unit/omission.rb +47 -3
- data/test-unit/lib/test/unit/testcase.rb +42 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +189 -3
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +7 -0
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +27 -0
- data/test-unit/test/test_assertions.rb +43 -10
- data/test/al-test-utils.rb +15 -0
- data/test/test_associations.rb +46 -1
- data/test/test_attributes.rb +43 -20
- data/test/test_base.rb +60 -3
- metadata +12 -12
- data/test-unit/sample/ts_examples.rb +0 -7
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= CHANGES
|
2
2
|
|
3
|
+
== 1.2.1: 2009-12-15
|
4
|
+
|
5
|
+
* Supported ActiveRecord 2.3.5 and Rails 2.3.5.
|
6
|
+
* Supported GetText 2.1.0 and Locale 2.0.5.
|
7
|
+
* belongs_to(:many) support DN attribute.
|
8
|
+
* [#31] ActiveLdap::Base#attributes returns data that reflects
|
9
|
+
schema definition. [Alexey.Chebotar]
|
10
|
+
* blocks DN attribute change by mass assignment with :id => ....
|
11
|
+
* [#35] fix has_many association is broken. [culturespy]
|
12
|
+
* Supported nested attribute options. [Hideyuki Yasuda]
|
13
|
+
|
3
14
|
== 1.2.0: 2009-09-22
|
4
15
|
|
5
16
|
* Supported ActiveRecord 2.3.4 and Rails 2.3.4.
|
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= ActiveLdap
|
2
2
|
|
3
3
|
ruby library for object-oriented LDAP interction
|
4
4
|
|
@@ -13,7 +13,7 @@ Contributors::
|
|
13
13
|
|
14
14
|
== DESCRIPTION
|
15
15
|
|
16
|
-
'
|
16
|
+
'ActiveLdap' is a ruby extension library which provides a clean objected
|
17
17
|
oriented interface to the Ruby/LDAP[0] library. It was inspired by
|
18
18
|
ActivRecord[3]. This is not nearly as clean or as flexible as ActiveRecord, but
|
19
19
|
it is still trivial to define new objects and manipulate them with minimal
|
@@ -114,7 +114,9 @@ list, please point out.
|
|
114
114
|
* Lennon Day-Reynolds: Bug reports.
|
115
115
|
* Tilo: A bug report.
|
116
116
|
* Matt Mencel: A bug report.
|
117
|
-
* CultureSpy:
|
117
|
+
* CultureSpy:
|
118
|
+
* Bug reports.
|
119
|
+
* Bug fixes.
|
118
120
|
* gwarf12: A bug report.
|
119
121
|
* Baptiste Grenier: API improvement ideas.
|
120
122
|
* Richard 3 Nicholas: API improvement ideas.
|
@@ -137,3 +139,4 @@ list, please point out.
|
|
137
139
|
* George Montana Harkin: A suggestion.
|
138
140
|
* Marc Dequènes: Bug reports.
|
139
141
|
* brad@lucky-dip.net: A bug report.
|
142
|
+
* Hideyuki Yasuda: Bug reports.
|
data/Rakefile
CHANGED
@@ -59,21 +59,21 @@ project = Hoe.spec('activeldap') do
|
|
59
59
|
self.rubyforge_name = 'ruby-activeldap'
|
60
60
|
self.author = ['Will Drewry', 'Kouhei Sutou']
|
61
61
|
self.email = ['redpig@dataspill.org', 'kou@cozmixng.org']
|
62
|
-
self.summary = '
|
62
|
+
self.summary = 'ActiveLdap is a object-oriented API to LDAP'
|
63
63
|
self.url = 'http://rubyforge.org/projects/ruby-activeldap/'
|
64
64
|
self.test_globs = ['test/test_*.rb']
|
65
65
|
self.changes = self.paragraphs_of('CHANGES', 1..2).join("\n\n")
|
66
66
|
self.extra_deps = [
|
67
67
|
# ['ruby-ldap', '= 0.9.9'],
|
68
|
-
['activerecord', '= 2.3.
|
69
|
-
['locale', '= 2.0.
|
70
|
-
['gettext', '= 2.0
|
71
|
-
['gettext_activerecord', '= 2.0
|
68
|
+
['activerecord', '= 2.3.5'],
|
69
|
+
['locale', '= 2.0.5'],
|
70
|
+
['gettext', '= 2.1.0'],
|
71
|
+
['gettext_activerecord', '= 2.1.0'],
|
72
72
|
]
|
73
73
|
self.remote_rdoc_dir = "doc"
|
74
74
|
self.rsync_args += " --chmod=Dg+ws,Fg+w"
|
75
75
|
self.description = String.new(<<-EOF)
|
76
|
-
'
|
76
|
+
'ActiveLdap' is a ruby extension library which provides a clean
|
77
77
|
objected oriented interface to the Ruby/LDAP library. It was inspired
|
78
78
|
by ActiveRecord. This is not nearly as clean or as flexible as
|
79
79
|
ActiveRecord, but it is still trivial to define new objects and manipulate
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# ENV['RAILS_ENV'] ||= 'production'
|
6
6
|
|
7
7
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
|
-
RAILS_GEM_VERSION = '2.3.
|
8
|
+
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
|
9
9
|
|
10
10
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
11
11
|
require File.join(File.dirname(__FILE__), 'boot')
|
@@ -27,8 +27,8 @@ Rails::Initializer.run do |config|
|
|
27
27
|
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
28
28
|
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
29
29
|
# config.gem "aws-s3", :lib => "aws/s3"
|
30
|
-
config.gem "locale_rails", :version => "2.0.
|
31
|
-
config.gem "gettext_rails", :version => "2.0
|
30
|
+
config.gem "locale_rails", :version => "2.0.5"
|
31
|
+
config.gem "gettext_rails", :version => "2.1.0"
|
32
32
|
|
33
33
|
# Only load the plugins named here, in the order given. By default, all plugins
|
34
34
|
# in vendor/plugins are loaded in alphabetical order.
|
data/examples/groupadd
CHANGED
data/examples/groupdel
CHANGED
data/examples/groupls
CHANGED
data/examples/groupmod
CHANGED
data/examples/lpasswd
CHANGED
data/examples/ouadd
CHANGED
data/examples/useradd
CHANGED
data/examples/useradd-binary
CHANGED
data/examples/userdel
CHANGED
data/examples/userls
CHANGED
data/examples/usermod
CHANGED
data/examples/usermod-binary-add
CHANGED
data/examples/usermod-binary-del
CHANGED
data/examples/usermod-lang-add
CHANGED
data/lib/active_ldap.rb
CHANGED
@@ -901,7 +901,7 @@ require_gem_if_need = Proc.new do |library_name, gem_name, *gem_args|
|
|
901
901
|
end
|
902
902
|
end
|
903
903
|
|
904
|
-
require_gem_if_need.call("active_support", "activesupport", "= 2.3.
|
904
|
+
require_gem_if_need.call("active_support", "activesupport", "= 2.3.5")
|
905
905
|
|
906
906
|
if ActiveSupport.const_defined?(:Dependencies)
|
907
907
|
dependencies = ActiveSupport::Dependencies
|
@@ -914,7 +914,7 @@ if dependencies.respond_to?(:load_paths)
|
|
914
914
|
end
|
915
915
|
|
916
916
|
module ActiveLdap
|
917
|
-
VERSION = "1.2.
|
917
|
+
VERSION = "1.2.1"
|
918
918
|
end
|
919
919
|
|
920
920
|
if RUBY_PLATFORM.match('linux')
|
@@ -923,11 +923,11 @@ else
|
|
923
923
|
require 'active_ldap/timeout_stub'
|
924
924
|
end
|
925
925
|
|
926
|
-
require_gem_if_need.call("active_record", "activerecord", "= 2.3.
|
926
|
+
require_gem_if_need.call("active_record", "activerecord", "= 2.3.5")
|
927
927
|
begin
|
928
|
-
require_gem_if_need.call("locale", nil, "= 2.0.
|
929
|
-
require_gem_if_need.call("gettext", nil, "= 2.0
|
930
|
-
require_gem_if_need.call("gettext_activerecord", nil, "= 2.0
|
928
|
+
require_gem_if_need.call("locale", nil, "= 2.0.5")
|
929
|
+
require_gem_if_need.call("gettext", nil, "= 2.1.0")
|
930
|
+
require_gem_if_need.call("gettext_activerecord", nil, "= 2.1.0")
|
931
931
|
rescue LoadError
|
932
932
|
end
|
933
933
|
require 'active_ldap/get_text'
|
@@ -67,7 +67,7 @@ module ActiveLdap
|
|
67
67
|
def bind(options={})
|
68
68
|
@bind_tried = true
|
69
69
|
|
70
|
-
bind_dn = options[:bind_dn] || @bind_dn
|
70
|
+
bind_dn = ensure_dn_string(options[:bind_dn] || @bind_dn)
|
71
71
|
try_sasl = options.has_key?(:try_sasl) ? options[:try_sasl] : @try_sasl
|
72
72
|
if options.has_key?(:allow_anonymous)
|
73
73
|
allow_anonymous = options[:allow_anonymous]
|
@@ -164,6 +164,7 @@ module ActiveLdap
|
|
164
164
|
values << value
|
165
165
|
end
|
166
166
|
|
167
|
+
base = ensure_dn_string(base)
|
167
168
|
begin
|
168
169
|
operation(options) do
|
169
170
|
yield(base, scope, filter, attrs, limit, callback)
|
@@ -185,6 +186,7 @@ module ActiveLdap
|
|
185
186
|
begin
|
186
187
|
operation(options) do
|
187
188
|
targets.each do |target|
|
189
|
+
target = ensure_dn_string(target)
|
188
190
|
begin
|
189
191
|
yield(target)
|
190
192
|
rescue LdapError::UnwillingToPerform, LdapError::InsufficientAccess
|
@@ -198,6 +200,7 @@ module ActiveLdap
|
|
198
200
|
end
|
199
201
|
|
200
202
|
def add(dn, entries, options={})
|
203
|
+
dn = ensure_dn_string(dn)
|
201
204
|
begin
|
202
205
|
operation(options) do
|
203
206
|
yield(dn, entries)
|
@@ -218,6 +221,7 @@ module ActiveLdap
|
|
218
221
|
end
|
219
222
|
|
220
223
|
def modify(dn, entries, options={})
|
224
|
+
dn = ensure_dn_string(dn)
|
221
225
|
begin
|
222
226
|
operation(options) do
|
223
227
|
begin
|
@@ -234,6 +238,7 @@ module ActiveLdap
|
|
234
238
|
end
|
235
239
|
|
236
240
|
def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
|
241
|
+
dn = ensure_dn_string(dn)
|
237
242
|
operation(options) do
|
238
243
|
yield(dn, new_rdn, delete_old_rdn, new_superior)
|
239
244
|
end
|
@@ -685,6 +690,14 @@ module ActiveLdap
|
|
685
690
|
log_entry
|
686
691
|
end
|
687
692
|
end
|
693
|
+
|
694
|
+
def ensure_dn_string(dn)
|
695
|
+
if dn.is_a?(DN)
|
696
|
+
dn.to_s
|
697
|
+
else
|
698
|
+
dn
|
699
|
+
end
|
700
|
+
end
|
688
701
|
end
|
689
702
|
end
|
690
703
|
end
|
@@ -76,8 +76,12 @@ module ActiveLdap
|
|
76
76
|
super do |_dn, _new_rdn, _delete_old_rdn, _new_superior|
|
77
77
|
info = {
|
78
78
|
:name => "modify: RDN",
|
79
|
-
:dn => _dn,
|
79
|
+
:dn => _dn,
|
80
|
+
:new_rdn => _new_rdn,
|
81
|
+
:new_superior => _new_superior,
|
82
|
+
:delete_old_rdn => _delete_old_rdn
|
80
83
|
}
|
84
|
+
_new_rdn = "#{_new_rdn},#{_new_superior}" if _new_superior
|
81
85
|
execute(:modify_rdn, info, _dn, _new_rdn, _delete_old_rdn)
|
82
86
|
end
|
83
87
|
end
|
@@ -118,9 +118,15 @@ module ActiveLdap
|
|
118
118
|
|
119
119
|
def modify_rdn(dn, new_rdn, delete_old_rdn, new_superior, options={})
|
120
120
|
super do |_dn, _new_rdn, _delete_old_rdn, _new_superior|
|
121
|
+
if _new_superior
|
122
|
+
raise NotImplemented.new(_("modify RDN with new superior"))
|
123
|
+
end
|
121
124
|
info = {
|
122
125
|
:name => "modify: RDN",
|
123
|
-
:dn => _dn,
|
126
|
+
:dn => _dn,
|
127
|
+
:new_rdn => _new_rdn,
|
128
|
+
:new_superior => _new_superior,
|
129
|
+
:delete_old_rdn => _delete_old_rdn
|
124
130
|
}
|
125
131
|
execute(:rename, info,
|
126
132
|
:olddn => _dn,
|
@@ -5,6 +5,8 @@ module ActiveLdap
|
|
5
5
|
class BelongsToMany < Collection
|
6
6
|
private
|
7
7
|
def insert_entry(entry)
|
8
|
+
_foreign_class = foreign_class
|
9
|
+
entry = _foreign_class.find(entry) unless entry.is_a?(_foreign_class)
|
8
10
|
old_value = entry[@options[:many], true]
|
9
11
|
primary_key_name = @options[:primary_key_name]
|
10
12
|
if primary_key_name == "dn"
|
@@ -21,7 +23,9 @@ module ActiveLdap
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def delete_entries(entries)
|
26
|
+
_foreign_class = foreign_class
|
24
27
|
entries.each do |entry|
|
28
|
+
entry = _foreign_class.find(entry) unless entry.is_a?(_foreign_class)
|
25
29
|
old_value = entry[@options[:many], true]
|
26
30
|
primary_key_name = @options[:primary_key_name]
|
27
31
|
if primary_key_name == "dn"
|
@@ -8,23 +8,23 @@ module ActiveLdap
|
|
8
8
|
|
9
9
|
private
|
10
10
|
def insert_entry(entry)
|
11
|
-
entry[
|
11
|
+
entry[foreign_key] = @owner[primary_key]
|
12
12
|
entry.save
|
13
13
|
end
|
14
14
|
|
15
15
|
def find_target
|
16
|
-
collect_targets(
|
16
|
+
collect_targets(primary_key)
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete_entries(entries)
|
20
|
-
|
20
|
+
_foreign_key = foreign_key
|
21
21
|
components = @owner[primary_key, true].reject do |value|
|
22
22
|
value.nil?
|
23
23
|
end
|
24
24
|
filter = [:and,
|
25
|
-
[:and, {
|
25
|
+
[:and, {_foreign_key => components}],
|
26
26
|
[:or, {foreign_class.dn_attribute => entries.collect(&:id)}]]
|
27
|
-
foreign_class.update_all({
|
27
|
+
foreign_class.update_all({_foreign_key => []}, filter)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -3,15 +3,14 @@ module ActiveLdap
|
|
3
3
|
module HasManyUtils
|
4
4
|
private
|
5
5
|
def collect_targets(requested_target_key, need_requested_targets=false)
|
6
|
-
|
7
|
-
return [] if
|
8
|
-
|
9
|
-
requested_targets = @owner[@options[requested_target_key], true]
|
6
|
+
_foreign_key = foreign_key
|
7
|
+
return [] if _foreign_key.nil?
|
10
8
|
|
9
|
+
requested_targets = @owner[requested_target_key, true]
|
11
10
|
requested_targets = requested_targets.reject(&:nil?)
|
12
11
|
if requested_targets.empty?
|
13
12
|
targets = []
|
14
|
-
elsif
|
13
|
+
elsif _foreign_key == "dn"
|
15
14
|
requested_targets = requested_targets.collect do |target|
|
16
15
|
if target.is_a?(DN)
|
17
16
|
target
|
@@ -28,7 +27,7 @@ module ActiveLdap
|
|
28
27
|
end
|
29
28
|
else
|
30
29
|
components = requested_targets.collect do |value|
|
31
|
-
[
|
30
|
+
[_foreign_key, value]
|
32
31
|
end
|
33
32
|
options = find_options(:filter => [:or, *components])
|
34
33
|
targets = foreign_class.find(:all, options)
|
@@ -9,11 +9,11 @@ module ActiveLdap
|
|
9
9
|
private
|
10
10
|
def insert_entry(entry)
|
11
11
|
old_value = @owner[@options[:wrap], true]
|
12
|
-
|
13
|
-
if
|
12
|
+
_foreign_key = foreign_key
|
13
|
+
if _foreign_key == "dn"
|
14
14
|
old_value = dn_values_to_string_values(old_value)
|
15
15
|
end
|
16
|
-
current_value = entry[
|
16
|
+
current_value = entry[_foreign_key, true]
|
17
17
|
current_value = dn_values_to_string_values(current_value)
|
18
18
|
new_value = (old_value + current_value).uniq.sort
|
19
19
|
if old_value != new_value
|
@@ -24,11 +24,11 @@ module ActiveLdap
|
|
24
24
|
|
25
25
|
def delete_entries(entries)
|
26
26
|
old_value = @owner[@options[:wrap], true]
|
27
|
-
|
28
|
-
if
|
27
|
+
_foreign_key = foreign_key
|
28
|
+
if _foreign_key == "dn"
|
29
29
|
old_value = dn_values_to_string_values(old_value)
|
30
30
|
end
|
31
|
-
current_value = entries.collect {|entry| entry[
|
31
|
+
current_value = entries.collect {|entry| entry[_foreign_key]}
|
32
32
|
current_value = dn_values_to_string_values(current_value)
|
33
33
|
new_value = old_value - current_value
|
34
34
|
new_value = new_value.uniq.sort
|
@@ -39,13 +39,13 @@ module ActiveLdap
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def find_target
|
42
|
-
targets, requested_targets = collect_targets(:wrap, true)
|
42
|
+
targets, requested_targets = collect_targets(@options[:wrap], true)
|
43
43
|
return [] if targets.nil?
|
44
44
|
|
45
45
|
found_targets = {}
|
46
|
-
|
46
|
+
_foreign_key = foreign_key
|
47
47
|
targets.each do |target|
|
48
|
-
found_targets[target[
|
48
|
+
found_targets[target[_foreign_key]] ||= target
|
49
49
|
end
|
50
50
|
|
51
51
|
klass = foreign_class
|
@@ -53,6 +53,10 @@ module ActiveLdap
|
|
53
53
|
found_targets[name] || klass.new(name)
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
def foreign_key
|
58
|
+
@options[:primary_key_name] || foreign_class.dn_attribute
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|