ruby-activeldap 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/test/test_adapter.rb +17 -0
  2. data/test/test_associations.rb +19 -0
  3. data/test/test_attributes.rb +2 -1
  4. data/test/test_base.rb +28 -1
  5. data/test/test_base_per_instance.rb +2 -1
  6. data/test/test_callback.rb +2 -2
  7. data/test/test_connection.rb +2 -1
  8. data/test/test_connection_per_dn.rb +81 -0
  9. data/test/test_dn.rb +3 -2
  10. data/test/test_find.rb +35 -1
  11. data/test/test_object_class.rb +12 -1
  12. data/test/test_reflection.rb +16 -10
  13. data/test/test_schema.rb +141 -2
  14. data/test/test_user.rb +14 -4
  15. metadata +7 -104
  16. data/CHANGES +0 -397
  17. data/COPYING +0 -340
  18. data/LICENSE +0 -58
  19. data/Manifest.txt +0 -99
  20. data/README +0 -85
  21. data/Rakefile +0 -70
  22. data/TODO +0 -23
  23. data/benchmark/bench-al.rb +0 -152
  24. data/examples/config.yaml.example +0 -5
  25. data/examples/example.der +0 -0
  26. data/examples/example.jpg +0 -0
  27. data/examples/groupadd +0 -41
  28. data/examples/groupdel +0 -35
  29. data/examples/groupls +0 -49
  30. data/examples/groupmod +0 -42
  31. data/examples/lpasswd +0 -55
  32. data/examples/objects/group.rb +0 -13
  33. data/examples/objects/ou.rb +0 -4
  34. data/examples/objects/user.rb +0 -20
  35. data/examples/ouadd +0 -38
  36. data/examples/useradd +0 -45
  37. data/examples/useradd-binary +0 -50
  38. data/examples/userdel +0 -34
  39. data/examples/userls +0 -50
  40. data/examples/usermod +0 -42
  41. data/examples/usermod-binary-add +0 -47
  42. data/examples/usermod-binary-add-time +0 -51
  43. data/examples/usermod-binary-del +0 -48
  44. data/examples/usermod-lang-add +0 -43
  45. data/lib/active_ldap.rb +0 -964
  46. data/lib/active_ldap/adapter/base.rb +0 -461
  47. data/lib/active_ldap/adapter/ldap.rb +0 -232
  48. data/lib/active_ldap/adapter/ldap_ext.rb +0 -69
  49. data/lib/active_ldap/adapter/net_ldap.rb +0 -288
  50. data/lib/active_ldap/adapter/net_ldap_ext.rb +0 -29
  51. data/lib/active_ldap/association/belongs_to.rb +0 -40
  52. data/lib/active_ldap/association/belongs_to_many.rb +0 -39
  53. data/lib/active_ldap/association/collection.rb +0 -80
  54. data/lib/active_ldap/association/has_many.rb +0 -40
  55. data/lib/active_ldap/association/has_many_wrap.rb +0 -55
  56. data/lib/active_ldap/association/proxy.rb +0 -89
  57. data/lib/active_ldap/associations.rb +0 -162
  58. data/lib/active_ldap/attributes.rb +0 -203
  59. data/lib/active_ldap/base.rb +0 -1510
  60. data/lib/active_ldap/callbacks.rb +0 -19
  61. data/lib/active_ldap/command.rb +0 -46
  62. data/lib/active_ldap/configuration.rb +0 -106
  63. data/lib/active_ldap/connection.rb +0 -142
  64. data/lib/active_ldap/distinguished_name.rb +0 -246
  65. data/lib/active_ldap/ldap_error.rb +0 -74
  66. data/lib/active_ldap/object_class.rb +0 -74
  67. data/lib/active_ldap/schema.rb +0 -299
  68. data/lib/active_ldap/timeout.rb +0 -75
  69. data/lib/active_ldap/timeout_stub.rb +0 -17
  70. data/lib/active_ldap/user_password.rb +0 -92
  71. data/lib/active_ldap/validations.rb +0 -76
  72. data/rails/plugin/active_ldap/README +0 -54
  73. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +0 -7
  74. data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +0 -21
  75. data/rails/plugin/active_ldap/init.rb +0 -12
  76. data/test/TODO +0 -2
  77. data/test/al-test-utils.rb +0 -381
  78. data/test/command.rb +0 -62
  79. data/test/config.yaml.sample +0 -6
  80. data/test/run-test.rb +0 -29
  81. data/test/test-unit-ext.rb +0 -2
  82. data/test/test-unit-ext/always-show-result.rb +0 -28
  83. data/test/test-unit-ext/priority.rb +0 -163
data/test/command.rb DELETED
@@ -1,62 +0,0 @@
1
- require "thread"
2
- require "socket"
3
- require "shellwords"
4
-
5
- module Command
6
- class Error < StandardError
7
- attr_reader :command, :result
8
- def initialize(command, result)
9
- @command = command
10
- @result = result
11
- super("#{command}: #{result}")
12
- end
13
- end
14
-
15
- module_function
16
- def detach_io
17
- require 'fcntl'
18
- [TCPSocket, ::File].each do |c|
19
- ObjectSpace.each_object(c) do |io|
20
- begin
21
- unless io.closed?
22
- io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
23
- end
24
- rescue SystemCallError,IOError => e
25
- end
26
- end
27
- end
28
- end
29
-
30
- def run(cmd, *args)
31
- raise ArgumentError, "command isn't specified" if cmd.nil?
32
- if args.any? {|x| x.nil?}
33
- raise ArgumentError, "args has nil: #{args.inspect}"
34
- end
35
- in_r, in_w = IO.pipe
36
- out_r, out_w = IO.pipe
37
- pid = exit_status = nil
38
- Thread.exclusive do
39
- verbose = $VERBOSE
40
- # ruby(>=1.8)'s fork terminates other threads with warning messages
41
- $VERBOSE = nil
42
- pid = fork do
43
- $VERBOSE = verbose
44
- detach_io
45
- out = STDERR.dup
46
- STDIN.reopen(in_r)
47
- in_r.close
48
- STDOUT.reopen(out_w)
49
- STDERR.reopen(out_w)
50
- out_w.close
51
- exec(cmd, *args.collect {|arg| arg.to_s})
52
- exit!(-1)
53
- end
54
- $VERBOSE = verbose
55
- end
56
- yield(out_r, in_w) if block_given?
57
- in_r.close unless in_r.closed?
58
- out_w.close unless out_w.closed?
59
- pid, status = Process.waitpid2(pid)
60
- [status.exited? && status.exitstatus.zero?, out_r.read]
61
- end
62
- end
@@ -1,6 +0,0 @@
1
- test:
2
- host: 127.0.0.1
3
- base: dc=test,dc=localdomain
4
- method: :tls
5
- bind_dn: cn=user-name,dc=localdomain
6
- password: secret
data/test/run-test.rb DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'yaml'
4
- require "test/unit"
5
-
6
- base_dir = File.expand_path(File.dirname(__FILE__))
7
- top_dir = File.expand_path(File.join(base_dir, ".."))
8
- $LOAD_PATH.unshift(File.join(top_dir, "lib"))
9
- $LOAD_PATH.unshift(File.join(top_dir, "test"))
10
-
11
- require 'test-unit-ext'
12
-
13
- test_file = "test/test_*.rb"
14
- Dir.glob(test_file) do |file|
15
- require file
16
- end
17
-
18
- [nil, "ldap", "net-ldap"].each do |adapter|
19
- ENV["ACTIVE_LDAP_TEST_ADAPTER"] = adapter
20
- puts "using adapter: #{adapter ? adapter : 'default'}"
21
- args = [File.dirname($0), ARGV.dup]
22
- if Test::Unit::AutoRunner.respond_to?(:standalone?)
23
- args.unshift(false)
24
- else
25
- args.unshift($0)
26
- end
27
- Test::Unit::AutoRunner.run(*args)
28
- puts
29
- end
@@ -1,2 +0,0 @@
1
- require "test-unit-ext/always-show-result"
2
- require "test-unit-ext/priority"
@@ -1,28 +0,0 @@
1
- require "test/unit/ui/testrunnermediator"
2
-
3
- module Test
4
- module Unit
5
- module UI
6
- class TestRunnerMediator
7
- alias_method :original_run_suite, :run_suite
8
- def run_suite
9
- @notified_finished = false
10
- begin_time = Time.now
11
- original_run_suite
12
- rescue Interrupt
13
- unless @notified_finished
14
- end_time = Time.now
15
- elapsed_time = end_time - begin_time
16
- notify_listeners(FINISHED, elapsed_time)
17
- end
18
- raise
19
- end
20
-
21
- def notify_listeners(channel_name, *arguments)
22
- @notified_finished = true if channel_name == FINISHED
23
- super
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,163 +0,0 @@
1
- require "test/unit"
2
-
3
- require "fileutils"
4
-
5
- module Test
6
- module Unit
7
- class TestCase
8
- class << self
9
- def inherited(sub)
10
- super
11
- sub.instance_variable_set("@priority_initialized", true)
12
- sub.instance_variable_set("@priority_table", {})
13
- sub.priority :normal
14
- end
15
-
16
- def include(*args)
17
- args.reverse_each do |mod|
18
- super(mod)
19
- next unless defined?(@priority_initialized)
20
- mod.instance_methods(false).each do |name|
21
- set_priority(name)
22
- end
23
- end
24
- end
25
-
26
- def method_added(name)
27
- set_priority(name) if defined?(@priority_initialized)
28
- end
29
-
30
- def priority(name, *tests)
31
- unless private_methods.include?(priority_check_method_name(name))
32
- raise ArgumentError, "unknown priority: #{name}"
33
- end
34
- if tests.empty?
35
- @current_priority = name
36
- else
37
- tests.each do |test|
38
- set_priority(test, name)
39
- end
40
- end
41
- end
42
-
43
- def need_to_run?(test_name)
44
- normalized_test_name = normalize_test_name(test_name)
45
- priority = @priority_table[normalized_test_name]
46
- return true unless priority
47
- __send__(priority_check_method_name(priority), test_name)
48
- end
49
-
50
- private
51
- def priority_check_method_name(priority_name)
52
- "run_priority_#{priority_name}?"
53
- end
54
-
55
- def normalize_test_name(test_name)
56
- "test_#{test_name.to_s.sub(/^test_/, '')}"
57
- end
58
-
59
- def set_priority(name, priority=@current_priority)
60
- @priority_table[normalize_test_name(name)] = priority
61
- end
62
-
63
- def run_priority_must?(test_name)
64
- true
65
- end
66
-
67
- def run_priority_important?(test_name)
68
- rand > 0.1
69
- end
70
-
71
- def run_priority_high?(test_name)
72
- rand > 0.3
73
- end
74
-
75
- def run_priority_normal?(test_name)
76
- rand > 0.5
77
- end
78
-
79
- def run_priority_low?(test_name)
80
- rand > 0.75
81
- end
82
-
83
- def run_priority_never?(test_name)
84
- false
85
- end
86
- end
87
-
88
- def need_to_run?
89
- !previous_test_success? or self.class.need_to_run?(@method_name)
90
- end
91
-
92
- alias_method :original_run, :run
93
- def run(result, &block)
94
- original_run(result, &block)
95
- ensure
96
- if passed?
97
- FileUtils.rm_f(not_passed_file)
98
- else
99
- FileUtils.touch(not_passed_file)
100
- end
101
- end
102
-
103
- private
104
- def previous_test_success?
105
- not File.exist?(not_passed_file)
106
- end
107
-
108
- def result_dir
109
- dir = File.join(File.dirname($0), ".test-result",
110
- self.class.name, @method_name.to_s)
111
- dir = File.expand_path(dir)
112
- FileUtils.mkdir_p(dir)
113
- dir
114
- end
115
-
116
- def not_passed_file
117
- File.join(result_dir, "not-passed")
118
- end
119
- end
120
-
121
- class TestSuite
122
- @@priority_mode = false
123
-
124
- class << self
125
- def priority_mode=(bool)
126
- @@priority_mode = bool
127
- end
128
- end
129
-
130
- alias_method :original_run, :run
131
- def run(*args, &block)
132
- priority_mode = @@priority_mode
133
- if priority_mode
134
- @original_tests = @tests
135
- apply_priority
136
- end
137
- original_run(*args, &block)
138
- ensure
139
- @tests = @original_tests if priority_mode
140
- end
141
-
142
- def apply_priority
143
- @tests = @tests.reject {|test| !test.need_to_run?}
144
- end
145
-
146
- def need_to_run?
147
- apply_priority
148
- !@tests.empty?
149
- end
150
- end
151
-
152
- class AutoRunner
153
- alias_method :original_options, :options
154
- def options
155
- opts = original_options
156
- opts.on("--[no-]priority", "use priority mode") do |bool|
157
- TestSuite.priority_mode = bool
158
- end
159
- opts
160
- end
161
- end
162
- end
163
- end