activesambaldap 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/NEWS.en +8 -1
  2. data/NEWS.ja +8 -1
  3. data/README.en +9 -6
  4. data/README.ja +5 -3
  5. data/Rakefile +47 -1
  6. data/bin/asl-groupadd +8 -5
  7. data/bin/asl-groupdel +6 -3
  8. data/bin/asl-groupmod +15 -11
  9. data/bin/asl-groupshow +3 -1
  10. data/bin/asl-passwd +14 -11
  11. data/bin/asl-populate +19 -14
  12. data/bin/asl-purge +3 -1
  13. data/bin/asl-samba-computeradd +8 -6
  14. data/bin/asl-samba-groupadd +4 -2
  15. data/bin/asl-samba-groupdel +4 -2
  16. data/bin/asl-samba-groupmod +8 -7
  17. data/bin/asl-samba-useradd +8 -6
  18. data/bin/asl-samba-userdel +4 -2
  19. data/bin/asl-samba-usermod +15 -8
  20. data/bin/asl-useradd +50 -49
  21. data/bin/asl-userdel +17 -8
  22. data/bin/asl-usermod +54 -49
  23. data/bin/asl-usershow +3 -1
  24. data/data/locale/ja/LC_MESSAGES/active-samba-ldap.mo +0 -0
  25. data/lib/active_samba_ldap.rb +2 -1
  26. data/lib/active_samba_ldap/account_entry.rb +13 -11
  27. data/lib/active_samba_ldap/base.rb +26 -25
  28. data/lib/active_samba_ldap/command.rb +11 -7
  29. data/lib/active_samba_ldap/configuration.rb +6 -4
  30. data/lib/active_samba_ldap/entry.rb +5 -4
  31. data/lib/active_samba_ldap/get_text_support.rb +12 -0
  32. data/lib/active_samba_ldap/group_entry.rb +4 -3
  33. data/lib/active_samba_ldap/populate.rb +1 -1
  34. data/lib/active_samba_ldap/samba_account_entry.rb +4 -4
  35. data/lib/active_samba_ldap/samba_group_entry.rb +4 -3
  36. data/lib/active_samba_ldap/user.rb +5 -4
  37. data/lib/active_samba_ldap/version.rb +1 -1
  38. data/po/active-samba-ldap.pot +463 -0
  39. data/po/ja/active-samba-ldap.po +469 -0
  40. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl/scaffold_asl_generator.rb → scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb} +1 -2
  41. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/computer.rb +0 -0
  42. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/dc.rb +0 -0
  43. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/group.rb +0 -0
  44. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/idmap.rb +0 -0
  45. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/ldap.yml +0 -0
  46. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/ou.rb +0 -0
  47. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/samba_controller.rb +0 -0
  48. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/samba_helper.rb +0 -0
  49. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/samba_index.rhtml +0 -0
  50. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/samba_populate.rhtml +0 -0
  51. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/samba_purge.rhtml +0 -0
  52. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/unix_id_pool.rb +0 -0
  53. data/rails/plugin/active_samba_ldap/generators/{scaffold_asl → scaffold_active_samba_ldap}/templates/user.rb +0 -0
  54. data/rails/plugin/active_samba_ldap/init.rb +15 -3
  55. data/test/asl-test-utils.rb +2 -1
  56. data/test/command.rb +5 -2
  57. data/test/run-test.rb +6 -2
  58. data/test/test-unit-ext.rb +4 -2
  59. data/test/test-unit-ext/backtrace-filter.rb +17 -0
  60. data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
  61. data/test/test-unit-ext/priority.rb +20 -7
  62. data/test/test_asl_groupadd.rb +2 -2
  63. data/test/test_asl_groupdel.rb +11 -11
  64. data/test/test_asl_groupmod.rb +7 -6
  65. data/test/test_asl_groupshow.rb +1 -1
  66. data/test/test_asl_passwd.rb +11 -10
  67. data/test/test_asl_populate.rb +6 -6
  68. data/test/test_asl_purge.rb +1 -1
  69. data/test/test_asl_useradd.rb +11 -9
  70. data/test/test_asl_userdel.rb +6 -4
  71. data/test/test_asl_usermod.rb +8 -8
  72. data/test/test_asl_usershow.rb +1 -1
  73. data/test/test_entry.rb +21 -0
  74. metadata +38 -30
@@ -1,7 +1,6 @@
1
- class ScaffoldAslGenerator < Rails::Generator::Base
1
+ class ScaffoldActiveSambaLdapGenerator < Rails::Generator::Base
2
2
  def manifest
3
3
  record do |m|
4
-
5
4
  m.template("ldap.yml", File.join("config", "ldap.yml"))
6
5
 
7
6
  %w(user computer group unix_id_pool idmap ou dc).each do |component|
@@ -1,6 +1,18 @@
1
1
  require_library_or_gem 'active_samba_ldap'
2
2
  ActiveSambaLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
3
3
  ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
4
- ActiveSambaLdap::Base.configurations =
5
- ActiveSambaLdap::Configuration.read(ldap_configuration_file)
6
- ActiveSambaLdap::Base.establish_connection
4
+ if File.exist?(ldap_configuration_file)
5
+ ActiveSambaLdap::Base.configurations =
6
+ ActiveSambaLdap::Configuration.read(ldap_configuration_file)
7
+ ActiveSambaLdap::Base.establish_connection
8
+ else
9
+ ActiveLdap::Base.class_eval do
10
+ format = _("You should run 'script/generator scaffold_active_samba_ldap' " \
11
+ "to make %s.")
12
+ logger.error(format % ldap_configuration_file)
13
+ end
14
+ end
15
+
16
+ class ActionView::Base
17
+ include ActiveLdap::Helper
18
+ end
@@ -12,6 +12,7 @@ require 'active_samba_ldap'
12
12
  module AslTestUtils
13
13
  def self.included(base)
14
14
  base.class_eval do
15
+ include ActiveSambaLdap::GetTextSupport
15
16
  include Configuration
16
17
  include Connection
17
18
  include Populate
@@ -245,7 +246,7 @@ module AslTestUtils
245
246
  @lib_dir = File.join(@top_dir, "lib")
246
247
  @ruby_args = [
247
248
  "-I", @lib_dir,
248
- "-I", File.join(@parent_dir, "activeldap", "lib"),
249
+ # "-I", File.join(@parent_dir, "activeldap", "lib"),
249
250
  # "-I", File.join(@parent_dir, "ldap", "lib"),
250
251
  # "-I", File.join(@parent_dir, "ldap"),
251
252
  ]
data/test/command.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "thread"
2
2
  require "socket"
3
3
  require "shellwords"
4
+ require "timeout"
4
5
 
5
6
  module Command
6
7
  class Error < StandardError
@@ -58,7 +59,9 @@ module Command
58
59
  in_r.close unless in_r.closed?
59
60
  out_w.close unless out_w.closed?
60
61
  err_w.close unless err_w.closed?
61
- pid, status = Process.waitpid2(pid)
62
- [status.exited? && status.exitstatus.zero?, out_r.read, err_r.read]
62
+ Timeout.timeout(5) do
63
+ pid, status = Process.waitpid2(pid)
64
+ [status.exited? && status.exitstatus.zero?, out_r.read, err_r.read]
65
+ end
63
66
  end
64
67
  end
data/test/run-test.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $KCODE = 'u'
4
+
3
5
  require "test/unit"
4
6
 
5
7
  top_dir = File.join(File.dirname(__FILE__), "..")
6
8
  # $LOAD_PATH.unshift(File.join(top_dir, "..", "ldap", "lib"))
7
9
  # $LOAD_PATH.unshift(File.join(top_dir, "..", "ldap"))
8
- $LOAD_PATH.unshift(File.join(top_dir, "..", "activeldap", "lib"))
10
+ # $LOAD_PATH.unshift(File.join(top_dir, "..", "activeldap", "lib"))
9
11
  $LOAD_PATH.unshift(File.join(top_dir, "lib"))
10
12
  $LOAD_PATH.unshift(File.join(top_dir, "test"))
11
13
 
12
14
  require 'test-unit-ext'
13
15
 
14
- ARGV.unshift("--priority")
16
+ unless ARGV.find {|opt| /\A--(?:no-)?priority/ =~ opt}
17
+ ARGV << "--priority"
18
+ end
15
19
 
16
20
  if Test::Unit::AutoRunner.respond_to?(:standalone?)
17
21
  exit Test::Unit::AutoRunner.run($0, File.dirname($0))
@@ -1,2 +1,4 @@
1
- require 'test-unit-ext/always-show-result'
2
- require 'test-unit-ext/priority'
1
+ require "test-unit-ext/always-show-result"
2
+ require "test-unit-ext/priority"
3
+ require "test-unit-ext/backtrace-filter"
4
+ require "test-unit-ext/long-display-for-emacs"
@@ -0,0 +1,17 @@
1
+ require 'test/unit/util/backtracefilter'
2
+
3
+ module Test
4
+ module Unit
5
+ module Util
6
+ module BacktraceFilter
7
+ TEST_UNIT_EXT_PREFIX = File.dirname(__FILE__)
8
+
9
+ alias_method :original_filter_backtrace, :filter_backtrace
10
+ def filter_backtrace(backtrace, prefix=nil)
11
+ original_result = original_filter_backtrace(backtrace, prefix)
12
+ original_filter_backtrace(original_result, TEST_UNIT_EXT_PREFIX)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'test/unit/failure'
2
+ require 'test/unit/error'
3
+
4
+ module Test
5
+ module Unit
6
+ BACKTRACE_INFO_RE = /.+:\d+:in `.+?'/
7
+ class Failure
8
+ alias_method :original_long_display, :long_display
9
+ def long_display
10
+ extract_backtraces_re =
11
+ /^ \[(#{BACKTRACE_INFO_RE}(?:\n #{BACKTRACE_INFO_RE})+)\]:$/
12
+ original_long_display.gsub(extract_backtraces_re) do |backtraces|
13
+ $1.gsub(/^ (#{BACKTRACE_INFO_RE})/, '\1') + ':'
14
+ end
15
+ end
16
+ end
17
+
18
+ class Error
19
+ alias_method :original_long_display, :long_display
20
+ def long_display
21
+ original_long_display.gsub(/^ (#{BACKTRACE_INFO_RE})/, '\1')
22
+ end
23
+ end
24
+ end
25
+ end
@@ -28,7 +28,9 @@ module Test
28
28
  end
29
29
 
30
30
  def priority(name, *tests)
31
- unless private_methods.include?(priority_check_method_name(name))
31
+ singleton_class = (class << self; self; end)
32
+ priority_check_method = priority_check_method_name(name)
33
+ unless singleton_class.private_method_defined?(priority_check_method)
32
34
  raise ArgumentError, "unknown priority: #{name}"
33
35
  end
34
36
  if tests.empty?
@@ -94,27 +96,38 @@ module Test
94
96
  original_run(result, &block)
95
97
  ensure
96
98
  if passed?
97
- FileUtils.rm_f(not_passed_file)
99
+ FileUtils.touch(passed_file)
98
100
  else
99
- FileUtils.touch(not_passed_file)
101
+ FileUtils.rm_f(passed_file)
100
102
  end
101
103
  end
102
104
 
103
105
  private
104
106
  def previous_test_success?
105
- not File.exist?(not_passed_file)
107
+ File.exist?(passed_file)
106
108
  end
107
109
 
108
110
  def result_dir
109
111
  dir = File.join(File.dirname($0), ".test-result",
110
- self.class.name, @method_name.to_s)
112
+ self.class.name, escaped_method_name)
111
113
  dir = File.expand_path(dir)
112
114
  FileUtils.mkdir_p(dir)
113
115
  dir
114
116
  end
115
117
 
116
- def not_passed_file
117
- File.join(result_dir, "not-passed")
118
+ def passed_file
119
+ File.join(result_dir, "passed")
120
+ end
121
+
122
+ def escaped_method_name
123
+ @method_name.to_s.gsub(/[!?]$/) do |matched|
124
+ case matched
125
+ when "!"
126
+ ".destructive"
127
+ when "?"
128
+ ".predicate"
129
+ end
130
+ end
118
131
  end
119
132
  end
120
133
 
@@ -9,14 +9,14 @@ class AslGroupAddTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_run_as_normal_user
12
- assert_equal([false, "", "need root authority.\n"],
12
+ assert_equal([false, "", _("need root authority.") + "\n"],
13
13
  run_command_as_normal_user("group-name"))
14
14
  end
15
15
 
16
16
  def test_exist_group
17
17
  make_dummy_group do |group|
18
18
  assert(@group_class.exists?(group.cn))
19
- assert_equal([false, "", "group '#{group.cn}' already exists.\n"],
19
+ assert_equal([false, "", _("group already exists: %s") % group.cn + "\n"],
20
20
  run_command(group.cn))
21
21
  assert(@group_class.exists?(group.cn))
22
22
  end
@@ -9,12 +9,12 @@ class AslGroupDelTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_run_as_normal_user
12
- assert_equal([false, "", "need root authority.\n"],
12
+ assert_equal([false, "", _("need root authority.") + "\n"],
13
13
  run_command_as_normal_user("group-name"))
14
14
  end
15
15
 
16
16
  def test_not_exist_group
17
- assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
17
+ assert_equal([false, "", _("group doesn't exist: %s") % 'not-exist' + "\n"],
18
18
  run_command("not-exist"))
19
19
  end
20
20
 
@@ -36,9 +36,9 @@ class AslGroupDelTest < Test::Unit::TestCase
36
36
  def test_primary_group_of_user
37
37
  make_dummy_group do |group|
38
38
  make_dummy_user(:gid_number => group.gid_number) do |user, password|
39
- message = "cannot destroy group '#{group.cn}' due to members "
40
- message << "who belong to the group as primary group"
41
- message << ": #{user.uid}\n"
39
+ format = _("cannot destroy group '%s' due to members " \
40
+ "who belong to the group as primary group: %s")
41
+ message = format % [group.cn, user.uid] + "\n"
42
42
  assert_equal([false, "", message], run_command(group.cn))
43
43
  end
44
44
  end
@@ -47,9 +47,9 @@ class AslGroupDelTest < Test::Unit::TestCase
47
47
  def test_primary_group_of_user_with_force
48
48
  make_dummy_group do |group|
49
49
  make_dummy_user(:gid_number => group.gid_number) do |user, password|
50
- message = "cannot change primary group from '#{group.cn}' "
51
- message << "to other group due to no other belonged groups"
52
- message << ": #{user.uid}\n"
50
+ format = _("cannot change primary group from '%s' " \
51
+ "to other group due to no other belonged groups: %s")
52
+ message = format % [group.cn, user.uid] + "\n"
53
53
  assert_equal([false, "", message], run_command(group.cn, "--force"))
54
54
  end
55
55
  end
@@ -75,9 +75,9 @@ class AslGroupDelTest < Test::Unit::TestCase
75
75
  make_dummy_group do |group2|
76
76
  group2.users << user
77
77
  assert_equal(group.gid_number, user.gid_number)
78
- message = "cannot destroy group '#{group.cn}' due to members "
79
- message << "who belong to the group as primary group"
80
- message << ": #{user.uid}\n"
78
+ format = _("cannot destroy group '%s' due to members " \
79
+ "who belong to the group as primary group: %s")
80
+ message = format % [group.cn, user.uid] + "\n"
81
81
  assert_equal([false, "", message], run_command(group.cn))
82
82
  user.reload
83
83
  assert_equal(group.gid_number, user.gid_number)
@@ -9,7 +9,7 @@ class AslGroupModTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_not_exist_group
12
- assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
12
+ assert_equal([false, "", _("group doesn't exist: %s") % 'not-exist' + "\n"],
13
13
  run_command("not-exist"))
14
14
  end
15
15
 
@@ -120,7 +120,7 @@ class AslGroupModTest < Test::Unit::TestCase
120
120
  new_rid = (2 * Integer(new_gid_number) + 1001).to_s
121
121
  new_samba_sid = old_samba_sid.sub(/#{Regexp.escape(old_rid)}$/, new_rid)
122
122
 
123
- message = "gid number '#{new_gid_number}' already exists\n"
123
+ message = _("gid number already exists: %s") % new_gid_number + "\n"
124
124
  args = ["--gid", new_gid_number]
125
125
  assert_asl_groupmod_failed(group.cn, message, *args)
126
126
 
@@ -225,19 +225,20 @@ class AslGroupModTest < Test::Unit::TestCase
225
225
 
226
226
  def test_duplicate_members
227
227
  make_dummy_group do |group|
228
- base = "there are duplicated members in adding and deleting members:"
228
+ format = _("there are duplicated members in " \
229
+ "adding and deleting members: %s")
229
230
  assert_asl_groupmod_failed(group.cn,
230
- "#{base} user\n",
231
+ "#{format % 'user'}\n",
231
232
  "--add-members", "user",
232
233
  "--delete-members", "user")
233
234
 
234
235
  assert_asl_groupmod_failed(group.cn,
235
- "#{base} user2\n",
236
+ "#{format % 'user2'}\n",
236
237
  "--add-members", "user1,user2,user3",
237
238
  "--delete-members", "user2")
238
239
 
239
240
  assert_asl_groupmod_failed(group.cn,
240
- "#{base} user2, user3\n",
241
+ "#{format % 'user2, user3'}\n",
241
242
  "--add-members", "user1,user2,user3",
242
243
  "--delete-members", "user2,user3,user4")
243
244
  end
@@ -15,7 +15,7 @@ class AslGroupShowTest < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_not_exist_group
18
- assert_equal([false, "", "group 'not-exist' doesn't exist.\n"],
18
+ assert_equal([false, "", _("group doesn't exist: %s") % 'not-exist' + "\n"],
19
19
  run_command("not-exist"))
20
20
  end
21
21
  end
@@ -9,7 +9,7 @@ class AslPasswdTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_unknown_user
12
- assert_equal([false, "", "user 'unknown' doesn't exist.\n"],
12
+ assert_equal([false, "", _("user doesn't exist: %s") % 'unknown' + "\n"],
13
13
  run_command("unknown"))
14
14
  end
15
15
 
@@ -103,9 +103,9 @@ class AslPasswdTest < Test::Unit::TestCase
103
103
  *args)
104
104
  assert_equal([true,
105
105
  [
106
- "Enter your current password: ",
107
- "New password: ",
108
- "Retype new password: ",
106
+ _("Enter your current password: "),
107
+ _("New password: "),
108
+ _("Retype new password: "),
109
109
  ].join("\n") + "\n",
110
110
  "",
111
111
  ],
@@ -113,13 +113,14 @@ class AslPasswdTest < Test::Unit::TestCase
113
113
  end
114
114
 
115
115
  def assert_change_password_with_wrong_current_password(name, password, *args)
116
+ input_password = Proc.new do |input, output|
117
+ output.puts(password)
118
+ output.flush
119
+ end
116
120
  assert_equal([false,
117
- "Enter your current password: \n",
118
- "password isn't match\n",
121
+ _("Enter your current password: ") + "\n",
122
+ _("password doesn't match.") + "\n",
119
123
  ],
120
- run_command_as_normal_user(name, *args) do |input, output|
121
- output.puts(password)
122
- output.flush
123
- end)
124
+ run_command_as_normal_user(name, *args, &input_password))
124
125
  end
125
126
  end
@@ -9,7 +9,7 @@ class AslPopulateTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_run_as_normal_user
12
- assert_equal([false, "", "need root authority.\n"],
12
+ assert_equal([false, "", _("need root authority.") + "\n"],
13
13
  run_command_as_normal_user)
14
14
  end
15
15
 
@@ -63,8 +63,8 @@ class AslPopulateTest < Test::Unit::TestCase
63
63
  name ||= @user_class::DOMAIN_ADMIN_NAME
64
64
  assert_equal([true,
65
65
  [
66
- "Password for #{name}: ",
67
- "Retype password for #{name}: ",
66
+ _("Password for %s: ") % name,
67
+ _("Retype password for %s: ") % name,
68
68
  ].join("\n") + "\n",
69
69
  "",
70
70
  ],
@@ -79,10 +79,10 @@ class AslPopulateTest < Test::Unit::TestCase
79
79
  password = "password"
80
80
  assert_equal([false,
81
81
  [
82
- "Password for #{name}: ",
83
- "Retype password for #{name}: ",
82
+ _("Password for %s: ") % name,
83
+ _("Retype password for %s: ") % name,
84
84
  ].join("\n") + "\n",
85
- "Passwords don't match.\n",
85
+ _("Passwords don't match.") + "\n",
86
86
  ],
87
87
  run_command(*args) do |input, output|
88
88
  output.puts(password)
@@ -9,7 +9,7 @@ class AslPurgeTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_run_as_normal_user
12
- assert_equal([false, "", "need root authority.\n"],
12
+ assert_equal([false, "", _("need root authority.") + "\n"],
13
13
  run_command_as_normal_user)
14
14
  end
15
15