activeldap 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +15 -0
- data/README +4 -1
- data/Rakefile +1 -1
- data/TODO +1 -2
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/app/models/user.rb +1 -1
- data/examples/al-admin/config/boot.rb +1 -1
- data/examples/al-admin/config/environment.rb +1 -15
- data/examples/al-admin/config/initializers/session_store.rb +23 -0
- data/examples/al-admin/config/session_secret.txt +1 -0
- data/examples/al-admin/db/schema.rb +23 -0
- data/examples/al-admin/locale/en/LC_MESSAGES/al-admin.mo +0 -0
- data/examples/al-admin/locale/ja/LC_MESSAGES/al-admin.mo +0 -0
- data/examples/al-admin/locale/nl/LC_MESSAGES/al-admin.mo +0 -0
- data/lib/active_ldap.rb +3 -3
- data/lib/active_ldap/acts/tree.rb +1 -1
- data/lib/active_ldap/adapter/base.rb +9 -1
- data/lib/active_ldap/adapter/ldap.rb +7 -1
- data/lib/active_ldap/association/belongs_to_many.rb +6 -2
- data/lib/active_ldap/association/children.rb +1 -1
- data/lib/active_ldap/association/has_many_utils.rb +2 -2
- data/lib/active_ldap/association/has_many_wrap.rb +6 -2
- data/lib/active_ldap/attributes.rb +5 -1
- data/lib/active_ldap/base.rb +133 -59
- data/lib/active_ldap/connection.rb +10 -3
- data/lib/active_ldap/distinguished_name.rb +33 -1
- data/lib/active_ldap/ldif.rb +1 -0
- data/lib/active_ldap/operations.rb +33 -14
- data/lib/active_ldap/populate.rb +21 -12
- data/lib/active_ldap/schema.rb +21 -0
- data/lib/active_ldap/validations.rb +49 -4
- data/po/active-ldap.pot +4030 -0
- data/po/en/active-ldap.po +57 -37
- data/po/ja/active-ldap.po +58 -38
- data/test-unit/History.txt +1 -1
- data/test-unit/Manifest.txt +2 -0
- data/test-unit/README.txt +1 -1
- data/test-unit/lib/test/unit/assertions.rb +1 -1
- data/test-unit/lib/test/unit/autorunner.rb +19 -4
- data/test-unit/lib/test/unit/collector/load.rb +3 -1
- data/test-unit/lib/test/unit/color-scheme.rb +5 -1
- data/test-unit/lib/test/unit/error.rb +7 -5
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +63 -8
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/test/collector/test-load.rb +1 -5
- data/test-unit/test/test-color-scheme.rb +4 -0
- data/test/al-test-utils.rb +30 -2
- data/test/test_acts_as_tree.rb +6 -3
- data/test/test_associations.rb +3 -2
- data/test/test_base.rb +104 -5
- data/test/test_dn.rb +10 -0
- data/test/test_groupls.rb +1 -1
- data/test/test_lpasswd.rb +1 -1
- data/test/test_reflection.rb +23 -16
- data/test/test_schema.rb +33 -1
- data/test/test_useradd-binary.rb +1 -1
- data/test/test_useradd.rb +1 -1
- data/test/test_userdel.rb +1 -1
- data/test/test_userls.rb +1 -1
- data/test/test_usermod-binary-add-time.rb +1 -1
- data/test/test_usermod-binary-add.rb +1 -1
- data/test/test_usermod-binary-del.rb +1 -1
- data/test/test_usermod-lang-add.rb +1 -1
- data/test/test_usermod.rb +1 -1
- data/test/test_validation.rb +48 -10
- metadata +44 -35
data/test-unit/History.txt
CHANGED
data/test-unit/Manifest.txt
CHANGED
@@ -31,12 +31,14 @@ lib/test/unit/pending.rb
|
|
31
31
|
lib/test/unit/priority.rb
|
32
32
|
lib/test/unit/runner/console.rb
|
33
33
|
lib/test/unit/runner/emacs.rb
|
34
|
+
lib/test/unit/runner/tap.rb
|
34
35
|
lib/test/unit/testcase.rb
|
35
36
|
lib/test/unit/testresult.rb
|
36
37
|
lib/test/unit/testsuite.rb
|
37
38
|
lib/test/unit/ui/console/outputlevel.rb
|
38
39
|
lib/test/unit/ui/console/testrunner.rb
|
39
40
|
lib/test/unit/ui/emacs/testrunner.rb
|
41
|
+
lib/test/unit/ui/tap/testrunner.rb
|
40
42
|
lib/test/unit/ui/testrunner.rb
|
41
43
|
lib/test/unit/ui/testrunnermediator.rb
|
42
44
|
lib/test/unit/ui/testrunnerutilities.rb
|
data/test-unit/README.txt
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
Test::Unit 2.x - Improved version of Test::Unit bundled in
|
8
8
|
Ruby 1.8.x.
|
9
9
|
|
10
|
-
Ruby 1.9.x bundles
|
10
|
+
Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit
|
11
11
|
bundled in Ruby 1.8.x had not been improved but unbundled
|
12
12
|
Test::Unit (Test::Unit 2.x) will be improved actively.
|
13
13
|
|
@@ -880,7 +880,7 @@ EOT
|
|
880
880
|
MaybeContainer.new(value, &formatter)
|
881
881
|
end
|
882
882
|
|
883
|
-
MAX_DIFF_TARGET_STRING_SIZE =
|
883
|
+
MAX_DIFF_TARGET_STRING_SIZE = 1000
|
884
884
|
def diff_target_string?(string)
|
885
885
|
if string.respond_to?(:bytesize)
|
886
886
|
string.bytesize < MAX_DIFF_TARGET_STRING_SIZE
|
@@ -102,15 +102,23 @@ module Test
|
|
102
102
|
@to_run = []
|
103
103
|
@color_scheme = ColorScheme.default
|
104
104
|
@runner_options = {}
|
105
|
+
@default_arguments = []
|
105
106
|
@workdir = nil
|
106
|
-
|
107
|
-
|
107
|
+
config_file = "test-unit.yml"
|
108
|
+
if File.exist?(config_file)
|
109
|
+
load_config(config_file)
|
110
|
+
else
|
111
|
+
global_config_file = File.expand_path("~/.test-unit.xml")
|
112
|
+
load_config(global_config_file) if File.exist?(global_config_file)
|
113
|
+
end
|
108
114
|
yield(self) if block_given?
|
109
115
|
end
|
110
116
|
|
111
117
|
def process_args(args = ARGV)
|
118
|
+
default_arguments = @default_arguments.dup
|
112
119
|
begin
|
113
|
-
|
120
|
+
@default_arguments.concat(args)
|
121
|
+
options.order!(@default_arguments) {|arg| @to_run << arg}
|
114
122
|
rescue OptionParser::ParseError => e
|
115
123
|
puts e
|
116
124
|
puts options
|
@@ -119,6 +127,8 @@ module Test
|
|
119
127
|
@filters << proc{false} unless(@filters.empty?)
|
120
128
|
end
|
121
129
|
not @to_run.empty?
|
130
|
+
ensure
|
131
|
+
@default_arguments = default_arguments
|
122
132
|
end
|
123
133
|
|
124
134
|
def options
|
@@ -304,7 +314,11 @@ module Test
|
|
304
314
|
(config["#{runner_name}_options"] || {}).each do |key, value|
|
305
315
|
key = key.to_sym
|
306
316
|
value = ColorScheme[value] if key == :color_scheme
|
307
|
-
|
317
|
+
if key == :arguments
|
318
|
+
@default_arguments.concat(value.split)
|
319
|
+
else
|
320
|
+
runner_options[key.to_sym] = value
|
321
|
+
end
|
308
322
|
end
|
309
323
|
@runner_options = @runner_options.merge(runner_options)
|
310
324
|
end
|
@@ -327,3 +341,4 @@ end
|
|
327
341
|
|
328
342
|
require 'test/unit/runner/console'
|
329
343
|
require 'test/unit/runner/emacs'
|
344
|
+
require 'test/unit/runner/tap'
|
@@ -76,7 +76,9 @@ module Test
|
|
76
76
|
sub_test_suites << sub_test_suite unless sub_test_suite.empty?
|
77
77
|
end
|
78
78
|
else
|
79
|
-
|
79
|
+
unless excluded_file?(path.basename.to_s)
|
80
|
+
collect_file(path, sub_test_suites, already_gathered)
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
test_suite = TestSuite.new(path.basename.to_s)
|
@@ -14,7 +14,11 @@ module Test
|
|
14
14
|
"omission" => Color.new("blue", :bold => true),
|
15
15
|
"notification" => Color.new("cyan", :bold => true),
|
16
16
|
"error" => Color.new("yellow", :bold => true) +
|
17
|
-
Color.new("black", :foreground => false)
|
17
|
+
Color.new("black", :foreground => false),
|
18
|
+
"case" => Color.new("white", :bold => true) +
|
19
|
+
Color.new("blue", :foreground => false),
|
20
|
+
"suite" => Color.new("white", :bold => true) +
|
21
|
+
Color.new("green", :foreground => false))
|
18
22
|
end
|
19
23
|
|
20
24
|
@@schemes = {}
|
@@ -69,18 +69,20 @@ module Test
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
NOT_PASS_THROUGH_EXCEPTIONS = []
|
72
73
|
PASS_THROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
|
73
74
|
SystemExit]
|
74
75
|
private
|
75
76
|
def handle_all_exception(exception)
|
76
77
|
case exception
|
78
|
+
when *NOT_PASS_THROUGH_EXCEPTIONS
|
77
79
|
when *PASS_THROUGH_EXCEPTIONS
|
78
|
-
false
|
79
|
-
else
|
80
|
-
problem_occurred
|
81
|
-
add_error(exception)
|
82
|
-
true
|
80
|
+
return false
|
83
81
|
end
|
82
|
+
|
83
|
+
problem_occurred
|
84
|
+
add_error(exception)
|
85
|
+
true
|
84
86
|
end
|
85
87
|
|
86
88
|
def add_error(exception)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
#--
|
2
2
|
#
|
3
3
|
# Author:: Nathaniel Talbott.
|
4
|
-
# Copyright::
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
6
|
+
# * Copyright (c) 2008-2009 Kouhei Sutou <kou@clear-code.com>
|
5
7
|
# License:: Ruby license.
|
6
8
|
|
7
9
|
require 'test/unit/color-scheme'
|
@@ -36,6 +38,9 @@ module Test
|
|
36
38
|
@progress_row_max = @options[:progress_row_max]
|
37
39
|
@progress_row_max ||= guess_progress_row_max
|
38
40
|
@already_outputted = false
|
41
|
+
@n_successes = 0
|
42
|
+
@indent = 0
|
43
|
+
@top_level = true
|
39
44
|
@faults = []
|
40
45
|
end
|
41
46
|
|
@@ -68,6 +73,8 @@ module Test
|
|
68
73
|
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
69
74
|
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
70
75
|
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
|
76
|
+
@mediator.add_listener(TestSuite::STARTED, &method(:test_suite_started))
|
77
|
+
@mediator.add_listener(TestSuite::FINISHED, &method(:test_suite_finished))
|
71
78
|
end
|
72
79
|
|
73
80
|
def start_mediator
|
@@ -91,8 +98,6 @@ module Test
|
|
91
98
|
|
92
99
|
def finished(elapsed_time)
|
93
100
|
nl if output?(NORMAL) and !output?(VERBOSE)
|
94
|
-
nl
|
95
|
-
output("Finished in #{elapsed_time} seconds.")
|
96
101
|
@faults.each_with_index do |fault, index|
|
97
102
|
nl
|
98
103
|
output_single("%3d) " % (index + 1))
|
@@ -101,25 +106,75 @@ module Test
|
|
101
106
|
output(detail)
|
102
107
|
end
|
103
108
|
nl
|
109
|
+
output("Finished in #{elapsed_time} seconds.")
|
110
|
+
nl
|
104
111
|
output(@result, result_color)
|
112
|
+
n_tests = @result.run_count
|
113
|
+
if n_tests.zero?
|
114
|
+
pass_percentage = 0
|
115
|
+
else
|
116
|
+
pass_percentage = 100.0 * (@n_successes / n_tests.to_f)
|
117
|
+
end
|
118
|
+
output("%g%% passed" % pass_percentage, result_color)
|
105
119
|
end
|
106
120
|
|
107
121
|
def format_fault(fault)
|
108
122
|
fault.long_display
|
109
123
|
end
|
110
|
-
|
124
|
+
|
111
125
|
def test_started(name)
|
112
|
-
|
126
|
+
return unless output?(VERBOSE)
|
127
|
+
|
128
|
+
name = name.sub(/\(.+?\)\z/, '')
|
129
|
+
right_space = 8 * 2
|
130
|
+
left_space = @progress_row_max - right_space
|
131
|
+
left_space = left_space - indent.size - name.size
|
132
|
+
tab_stop = "\t" * ((left_space - 1) / 8)
|
133
|
+
output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
|
134
|
+
@test_start = Time.now
|
113
135
|
end
|
114
|
-
|
136
|
+
|
115
137
|
def test_finished(name)
|
116
138
|
unless @already_outputted
|
139
|
+
@n_successes += 1
|
117
140
|
output_progress(".", color("success"))
|
118
141
|
end
|
119
|
-
nl(VERBOSE)
|
120
142
|
@already_outputted = false
|
143
|
+
|
144
|
+
return unless output?(VERBOSE)
|
145
|
+
|
146
|
+
output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
|
121
147
|
end
|
122
|
-
|
148
|
+
|
149
|
+
def test_suite_started(name)
|
150
|
+
if @top_level
|
151
|
+
@top_level = false
|
152
|
+
return
|
153
|
+
end
|
154
|
+
|
155
|
+
output_single(indent, nil, VERBOSE)
|
156
|
+
if /\A[A-Z]/ =~ name
|
157
|
+
_color = color("case")
|
158
|
+
else
|
159
|
+
_color = color("suite")
|
160
|
+
end
|
161
|
+
output_single(name, _color, VERBOSE)
|
162
|
+
output(": ", nil, VERBOSE)
|
163
|
+
@indent += 2
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_suite_finished(name)
|
167
|
+
@indent -= 2
|
168
|
+
end
|
169
|
+
|
170
|
+
def indent
|
171
|
+
if output?(VERBOSE)
|
172
|
+
" " * @indent
|
173
|
+
else
|
174
|
+
""
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
123
178
|
def nl(level=NORMAL)
|
124
179
|
output("", nil, level)
|
125
180
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Kouhei Sutou.
|
4
|
+
# Copyright:: Copyright (c) 2009 Kouhei Sutou <kou@clear-code.com>.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
require 'test/unit/ui/testrunner'
|
8
|
+
require 'test/unit/ui/testrunnermediator'
|
9
|
+
|
10
|
+
module Test
|
11
|
+
module Unit
|
12
|
+
module UI
|
13
|
+
module Tap
|
14
|
+
|
15
|
+
# Runs a Test::Unit::TestSuite and outputs result
|
16
|
+
# as TAP format.
|
17
|
+
class TestRunner < UI::TestRunner
|
18
|
+
def initialize(suite, options={})
|
19
|
+
super
|
20
|
+
@output = @options[:output] || STDOUT
|
21
|
+
@n_tests = 0
|
22
|
+
@already_outputted = false
|
23
|
+
end
|
24
|
+
|
25
|
+
# Begins the test run.
|
26
|
+
def start
|
27
|
+
setup_mediator
|
28
|
+
result = start_mediator
|
29
|
+
def result.passed?
|
30
|
+
true # for prove commend :<
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def setup_mediator
|
37
|
+
@mediator = TestRunnerMediator.new(@suite)
|
38
|
+
attach_to_mediator
|
39
|
+
end
|
40
|
+
|
41
|
+
def attach_to_mediator
|
42
|
+
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
|
43
|
+
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
|
44
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
45
|
+
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
46
|
+
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_mediator
|
50
|
+
@mediator.run_suite
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_fault(fault)
|
54
|
+
puts("not ok #{@n_tests} - #{fault.short_display}")
|
55
|
+
fault.long_display.each_line do |line|
|
56
|
+
puts("# #{line}")
|
57
|
+
end
|
58
|
+
@already_outputted = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def started(result)
|
62
|
+
@result = result
|
63
|
+
puts("1..#{@suite.size}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def finished(elapsed_time)
|
67
|
+
puts("# Finished in #{elapsed_time} seconds.")
|
68
|
+
@result.to_s.each_line do |line|
|
69
|
+
puts("# #{line}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_started(name)
|
74
|
+
@n_tests += 1
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_finished(name)
|
78
|
+
unless @already_outputted
|
79
|
+
puts("ok #{@n_tests} - #{name}")
|
80
|
+
end
|
81
|
+
@already_outputted = false
|
82
|
+
end
|
83
|
+
|
84
|
+
def puts(*args)
|
85
|
+
@output.puts(*args)
|
86
|
+
@output.flush
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -240,11 +240,7 @@ EOT
|
|
240
240
|
[:test, {:name => "test1_2"}]]],
|
241
241
|
@test_case1.to_s)
|
242
242
|
|
243
|
-
assert_collect(
|
244
|
-
[:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
|
245
|
-
[:test, {:name => "test5_1"}],
|
246
|
-
[:test, {:name => "test5_2"}]]],
|
247
|
-
@no_load_sub_test_case5.to_s)
|
243
|
+
assert_collect(nil, @no_load_sub_test_case5.to_s)
|
248
244
|
end
|
249
245
|
|
250
246
|
def test_nil_pattern
|
@@ -8,6 +8,10 @@ class TestUnitColorScheme < Test::Unit::TestCase
|
|
8
8
|
"notification" => color("cyan", :bold => true),
|
9
9
|
"error" => color("yellow", :bold => true) +
|
10
10
|
color("black", :foreground => false),
|
11
|
+
"case" => color("white", :bold => true) +
|
12
|
+
color("blue", :foreground => false),
|
13
|
+
"suite" => color("white", :bold => true) +
|
14
|
+
color("green", :foreground => false),
|
11
15
|
},
|
12
16
|
Test::Unit::ColorScheme.default.to_hash)
|
13
17
|
end
|
data/test/al-test-utils.rb
CHANGED
@@ -16,6 +16,7 @@ module AlTestUtils
|
|
16
16
|
def self.included(base)
|
17
17
|
base.class_eval do
|
18
18
|
include ActiveLdap::GetTextSupport
|
19
|
+
include Utilities
|
19
20
|
include Assertions
|
20
21
|
include Config
|
21
22
|
include Connection
|
@@ -26,6 +27,12 @@ module AlTestUtils
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
module Utilities
|
31
|
+
def dn(string)
|
32
|
+
ActiveLdap::DN.parse(string)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
29
36
|
module Assertions
|
30
37
|
def assert_true(actual, *args)
|
31
38
|
assert_equal(true, actual, *args)
|
@@ -183,12 +190,29 @@ module AlTestUtils
|
|
183
190
|
|
184
191
|
def ou_class(prefix="")
|
185
192
|
ou_class = Class.new(ActiveLdap::Base)
|
186
|
-
ou_class.ldap_mapping
|
193
|
+
ou_class.ldap_mapping(:dn_attribute => "ou",
|
187
194
|
:prefix => prefix,
|
188
|
-
:classes => ["top", "organizationalUnit"]
|
195
|
+
:classes => ["top", "organizationalUnit"])
|
189
196
|
ou_class
|
190
197
|
end
|
191
198
|
|
199
|
+
def dc_class(prefix="")
|
200
|
+
dc_class = Class.new(ActiveLdap::Base)
|
201
|
+
dc_class.ldap_mapping(:dn_attribute => "dc",
|
202
|
+
:prefix => prefix,
|
203
|
+
:classes => ["top", "dcObject", "organization"])
|
204
|
+
dc_class
|
205
|
+
end
|
206
|
+
|
207
|
+
def entry_class(prefix="")
|
208
|
+
entry_class = Class.new(ActiveLdap::Base)
|
209
|
+
entry_class.ldap_mapping(:prefix => prefix,
|
210
|
+
:scope => :sub,
|
211
|
+
:classes => ["top"])
|
212
|
+
entry_class.dn_attribute = nil
|
213
|
+
entry_class
|
214
|
+
end
|
215
|
+
|
192
216
|
def populate_ou
|
193
217
|
%w(Users Groups).each do |name|
|
194
218
|
make_ou(name)
|
@@ -199,6 +223,10 @@ module AlTestUtils
|
|
199
223
|
ActiveLdap::Populate.ensure_ou(name)
|
200
224
|
end
|
201
225
|
|
226
|
+
def make_dc(name)
|
227
|
+
ActiveLdap::Populate.ensure_dc(name)
|
228
|
+
end
|
229
|
+
|
202
230
|
def populate_user_class
|
203
231
|
@user_class = Class.new(ActiveLdap::Base)
|
204
232
|
@user_class_classes = ["posixAccount", "person"]
|