From codesite-noreply at google.com Sat Sep 1 00:06:05 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 21:06:05 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r342 - in trunk: po/en po/ja rails/plugin/active_ldap/generators/scaffold_al Message-ID: Author: koutou Date: Fri Aug 31 21:05:15 2007 New Revision: 342 Added: trunk/rails/plugin/active_ldap/generators/scaffold_al/ trunk/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb Modified: trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po Log: * added backward compatibility generator: scaffold_al. Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Fri Aug 31 21:05:15 2007 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-08-31 21:53+0900\n" +"POT-Creation-Date: 2007-09-01 13:03+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -3530,6 +3530,10 @@ #: rails/plugin/active_ldap/init.rb:19 msgid "You should run 'script/generator scaffold_al' to make %s." +msgstr "" + +#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 +msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." msgstr "" #: benchmark/bench-al.rb:14 Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Fri Aug 31 21:05:15 2007 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-08-31 21:53+0900\n" -"PO-Revision-Date: 2007-08-31 21:51+0900\n" +"POT-Creation-Date: 2007-09-01 13:03+0900\n" +"PO-Revision-Date: 2007-09-01 13:04+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -3552,6 +3552,10 @@ #: rails/plugin/active_ldap/init.rb:19 msgid "You should run 'script/generator scaffold_al' to make %s." msgstr "%s??????'script/generator scaffold_al'??????????" + +#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 +msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." +msgstr "scaffold_al????????????scaffold_active_ldap?????????" #: benchmark/bench-al.rb:14 msgid "Specify prefix for benchmarking" Added: trunk/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb ============================================================================== --- (empty file) +++ trunk/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb Fri Aug 31 21:05:15 2007 @@ -0,0 +1,20 @@ +class ScaffoldAlGenerator < Rails::Generator::Base + include ActiveLdap::GetTextSupport + + def initialize(*args) + duped_args = args.collect {|arg| arg.dup} + super + logger.warning(_("scaffold_al is deprecated. " \ + "Use scaffold_active_ldap instead.")) + generator_class = self.class.lookup("scaffold_active_ldap").klass + @generator = generator_class.new(duped_args) + end + + def manifest + @generator.manifest + end + + def source_path(*args) + @generator.source_path(*args) + end +end From codesite-noreply at google.com Sat Sep 1 00:10:06 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 21:10:06 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r343 - in trunk/rails/plugin/active_ldap/generators: model_active_ldap model_activeldap Message-ID: <163600d1b504390b1d5897d64c54e5@google.com> Author: koutou Date: Fri Aug 31 21:06:29 2007 New Revision: 343 Added: trunk/rails/plugin/active_ldap/generators/model_active_ldap/ - copied from r338, /trunk/rails/plugin/active_ldap/generators/model_activeldap/ Removed: trunk/rails/plugin/active_ldap/generators/model_activeldap/ Log: * model_activeldap -> model_active_ldap. From codesite-noreply at google.com Sat Sep 1 00:14:07 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 21:14:07 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r344 - trunk/rails/plugin/active_ldap/generators/model_active_ldap Message-ID: Author: koutou Date: Fri Aug 31 21:08:05 2007 New Revision: 344 Added: trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb - copied, changed from r343, /trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_activeldap_generator.rb Removed: trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_activeldap_generator.rb Log: * model_activeldap -> model_active_ldap. Copied: trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb (from r343, /trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_activeldap_generator.rb) ============================================================================== --- /trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_activeldap_generator.rb (original) +++ trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb Fri Aug 31 21:08:05 2007 @@ -1,4 +1,4 @@ -class ModelActiveldapGenerator < Rails::Generator::NamedBase +class ModelActiveLdapGenerator < Rails::Generator::NamedBase default_options :skip_migration => true def manifest From codesite-noreply at google.com Sat Sep 1 00:18:10 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 21:18:10 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r345 - trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates Message-ID: Author: koutou Date: Fri Aug 31 21:15:40 2007 New Revision: 345 Added: trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb - copied unchanged from r343, /trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_activeldap.rb Removed: trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_activeldap.rb Log: * activeldap -> active_ldap. From codesite-noreply at google.com Sat Sep 1 00:38:12 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 21:38:12 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r346 - in trunk: po/en po/ja rails/plugin/active_ldap/generators/model_active_ldap rails/plugin/a... Message-ID: Author: koutou Date: Fri Aug 31 21:37:30 2007 New Revision: 346 Modified: trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb Log: * removed needless codes for migration. * added some usefull options: --dn-attribute, --prefix and --classes. Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Fri Aug 31 21:37:30 2007 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-01 13:03+0900\n" +"POT-Creation-Date: 2007-09-01 13:34+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -3536,12 +3536,22 @@ msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." msgstr "" -#: benchmark/bench-al.rb:14 -msgid "Specify prefix for benchmarking" +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:32 +msgid "Use ATTRIBUTE as default DN attribute for instances of this model" msgstr "" +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:34 +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:40 #: benchmark/bench-al.rb:15 msgid "(default: %s)" +msgstr "" + +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:39 +msgid "Use PREFIX as prefix for this model" +msgstr "" + +#: benchmark/bench-al.rb:14 +msgid "Specify prefix for benchmarking" msgstr "" #: benchmark/bench-al.rb:154 Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Fri Aug 31 21:37:30 2007 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-01 13:03+0900\n" -"PO-Revision-Date: 2007-09-01 13:04+0900\n" +"POT-Creation-Date: 2007-09-01 13:34+0900\n" +"PO-Revision-Date: 2007-09-01 13:36+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -3555,15 +3555,26 @@ #: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." -msgstr "scaffold_al????????????scaffold_active_ldap?????????" +msgstr "" +"scaffold_al????????????scaffold_active_ldap?????????" -#: benchmark/bench-al.rb:14 -msgid "Specify prefix for benchmarking" -msgstr "????????????????????????" +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:32 +msgid "Use ATTRIBUTE as default DN attribute for instances of this model" +msgstr "???????????????????DN??????ATTRIBUTE??????" +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:34 +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:40 #: benchmark/bench-al.rb:15 msgid "(default: %s)" msgstr "(?????: %s)" + +#: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:39 +msgid "Use PREFIX as prefix for this model" +msgstr "????????????????PREFIX??????" + +#: benchmark/bench-al.rb:14 +msgid "Specify prefix for benchmarking" +msgstr "????????????????????????" #: benchmark/bench-al.rb:154 msgid "Populating..." Modified: trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb ============================================================================== --- trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb (original) +++ trunk/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb Fri Aug 31 21:37:30 2007 @@ -1,5 +1,7 @@ class ModelActiveLdapGenerator < Rails::Generator::NamedBase - default_options :skip_migration => true + include ActiveLdap::GetTextSupport + + default_options :dn_attribute => "cn", :classes => nil def manifest record do |m| @@ -12,27 +14,57 @@ m.directory File.join('test/fixtures', class_path) # Model class, unit test, and fixtures. - m.template 'model_activeldap.rb', File.join('app/models', class_path, "#{file_name}.rb") - m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb") - m.template 'fixtures.yml', File.join('test/fixtures', class_path, "#{table_name}.yml") - - unless options[:skip_migration] - m.migration_template 'migration.rb', 'db/migrate', :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}" - }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - end + m.template('model_active_ldap.rb', + File.join('app/models', class_path, "#{file_name}.rb"), + :assigns => {:ldap_mapping => ldap_mapping}) + m.template('unit_test.rb', + File.join('test/unit', class_path, "#{file_name}_test.rb")) + m.template('fixtures.yml', + File.join('test/fixtures', class_path, "#{table_name}.yml")) end end - protected - def banner - "Usage: #{$0} generate ModelAlName [field:type, field:type]" + private + def add_options!(opt) + opt.separator '' + opt.separator 'Options:' + opt.on("--dn-attribute=ATTRIBUTE", + _("Use ATTRIBUTE as default DN attribute for " \ + "instances of this model"), + _("(default: %s)") % options[:dn_attribute]) do |attribute| + options[:dn_attribute] = attribute + end + + opt.on("--prefix=PREFIX", + _("Use PREFIX as prefix for this model"), + _("(default: %s)") % default_prefix) do |prefix| + options[:prefix] = prefix end - def add_options!(opt) - opt.separator '' - opt.separator 'Options:' - opt.on("--skip-migration", - "Don't generate a migration file for this model") { |v| options[:skip_migration] = v } + opt.on("--classes=CLASS,CLASS,...", + Array, + "Use CLASSES as required objectClass for instances of this model", + "(default: %s)" % options[:classes]) do |classes| + options[:classes] = classes end + end + + def prefix + options[:prefix] || default_prefix + end + + def default_prefix + "ou=#{Inflector.pluralize(Inflector.demodulize(name))}" + end + + def ldap_mapping(indent=' ') + mapping = "ldap_mapping " + mapping_options = [":dn_attribute => #{options[:dn_attribute].dump}"] + mapping_options << ":prefix => #{prefix.dump}" + if options[:classes] + mapping_options << ":classes => #{options[:classes].inspect}" + end + mapping_options = mapping_options.join(",\n#{indent}#{' ' * mapping.size}") + "#{indent}#{mapping}#{mapping_options}" + end end Modified: trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb ============================================================================== --- trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb (original) +++ trunk/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb Fri Aug 31 21:37:30 2007 @@ -1,3 +1,3 @@ class <%= class_name %> < ActiveLdap::Base - ldap_mapping +<%= ldap_mapping %> end From codesite-noreply at google.com Sat Sep 1 01:05:13 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 22:05:13 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r347 - in trunk: lib/active_ldap rails/plugin/active_ldap Message-ID: <163600d6b304390be26d711d4c89b8@google.com> Author: koutou Date: Fri Aug 31 22:04:05 2007 New Revision: 347 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/configuration.rb trunk/rails/plugin/active_ldap/init.rb Log: * added a new establich_connection option: :initial_connection_check. This option is true by default because of backward compatibility. But the Rails plugin set this value to false to work script/* without LDAP server. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Fri Aug 31 22:04:05 2007 @@ -251,9 +251,8 @@ def establish_connection(config=nil) super ensure_logger - connection.connect - # Make irb users happy with a 'true' - true + connection.connect if configuration[:initial_connection_check] + nil end def create(attributes=nil, &block) Modified: trunk/lib/active_ldap/configuration.rb ============================================================================== --- trunk/lib/active_ldap/configuration.rb (original) +++ trunk/lib/active_ldap/configuration.rb Fri Aug 31 22:04:05 2007 @@ -32,6 +32,8 @@ # Whether or not to retry on timeouts DEFAULT_CONFIG[:retry_on_timeout] = true + DEFAULT_CONFIG[:initial_connection_check] = true + DEFAULT_CONFIG[:logger] = nil module ClassMethods @@ -80,7 +82,8 @@ @@defined_configurations.delete_if {|key, value| value == config} end - CONNECTION_CONFIGURATION_KEYS = [:base, :adapter] + CONNECTION_CONFIGURATION_KEYS = [:base, :adapter, + :initial_connection_check] def remove_connection_related_configuration(config) config.reject do |key, value| CONNECTION_CONFIGURATION_KEYS.include?(key) Modified: trunk/rails/plugin/active_ldap/init.rb ============================================================================== --- trunk/rails/plugin/active_ldap/init.rb (original) +++ trunk/rails/plugin/active_ldap/init.rb Fri Aug 31 22:04:05 2007 @@ -13,7 +13,9 @@ if File.exist?(ldap_configuration_file) configurations = YAML::load(ERB.new(IO.read(ldap_configuration_file)).result) ActiveLdap::Base.configurations = configurations - ActiveLdap::Base.establish_connection + configuration = configurations[RAILS_ENV] + configuration = configuration.merge(:initial_connection_check => false) + ActiveLdap::Base.establish_connection(configuration) else ActiveLdap::Base.class_eval do format = _("You should run 'script/generator scaffold_al' to make %s.") From codesite-noreply at google.com Sat Sep 1 01:09:13 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 22:09:13 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r348 - trunk/rails/plugin/active_ldap Message-ID: Author: koutou Date: Fri Aug 31 22:08:02 2007 New Revision: 348 Modified: trunk/rails/plugin/active_ldap/init.rb Log: * updated required ActiveLdap version: 0.8.3 -> 0.8.4. Modified: trunk/rails/plugin/active_ldap/init.rb ============================================================================== --- trunk/rails/plugin/active_ldap/init.rb (original) +++ trunk/rails/plugin/active_ldap/init.rb Fri Aug 31 22:08:02 2007 @@ -1,7 +1,7 @@ require_library_or_gem 'active_ldap' ActiveLdap::Base.logger ||= RAILS_DEFAULT_LOGGER -required_version = ["0", "8", "3"] +required_version = ["0", "8", "4"] if (ActiveLdap::VERSION.split(".") <=> required_version) < 0 ActiveLdap::Base.class_eval do format = _("You need ActiveLdap %s or later") From codesite-noreply at google.com Sat Sep 1 01:13:13 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 22:13:13 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r349 - trunk/rails/plugin/active_ldap Message-ID: Author: koutou Date: Fri Aug 31 22:08:33 2007 New Revision: 349 Modified: trunk/rails/plugin/active_ldap/init.rb Log: * removed needless version check. Modified: trunk/rails/plugin/active_ldap/init.rb ============================================================================== --- trunk/rails/plugin/active_ldap/init.rb (original) +++ trunk/rails/plugin/active_ldap/init.rb Fri Aug 31 22:08:33 2007 @@ -23,8 +23,6 @@ end end -if ActiveLdap.const_defined?(:Helper) - class ActionView::Base - include ActiveLdap::Helper - end +class ActionView::Base + include ActiveLdap::Helper end From codesite-noreply at google.com Sat Sep 1 01:40:15 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 31 Aug 2007 22:40:15 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r350 - in trunk: examples/al-admin/app/models lib/active_ldap rails/plugin/active_ldap test Message-ID: Author: koutou Date: Fri Aug 31 22:39:44 2007 New Revision: 350 Modified: trunk/examples/al-admin/app/models/ldap_user.rb trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/configuration.rb trunk/rails/plugin/active_ldap/init.rb trunk/test/test_bind.rb trunk/test/test_connection_per_class.rb trunk/test/test_connection_per_dn.rb Log: * [API CHANGE]: establish_connection doesn't connect LDAP server, just store configuration for connection. (This behavior is same as ActiveRecord.) You need to change your code like the following if your codes depend on this feature: before: begin ActiveLdap::Base.establish_connection(...) rescue ActiveLdap::ConnectionError ... end after: begin ActiveLdap::Base.establish_connection(...) ActiveLdap::Base.connection.connect rescue ActiveLdap::ConnectionError ... end * [API CHANGE]: added ActiveLdap::Base#bind method instead. This is usuful method to setup connection per instance. You need to change your code like the followings if your codes depend on establish_connection: before: begin ldap_entry.establish_connection(:password => password) rescue ActiveLdap::AuthenticationError ... end after: begin ldap_entry.bind(password) rescue ActiveLdap::AuthenticationError ... end Modified: trunk/examples/al-admin/app/models/ldap_user.rb ============================================================================== --- trunk/examples/al-admin/app/models/ldap_user.rb (original) +++ trunk/examples/al-admin/app/models/ldap_user.rb Fri Aug 31 22:39:44 2007 @@ -26,7 +26,7 @@ end def authenticated?(password) - establish_connection(:password => password) + bind(password) true rescue ActiveLdap::AuthenticationError, ActiveLdap::LdapError::UnwillingToPerform Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Fri Aug 31 22:39:44 2007 @@ -251,7 +251,6 @@ def establish_connection(config=nil) super ensure_logger - connection.connect if configuration[:initial_connection_check] nil end @@ -734,11 +733,18 @@ end end - def establish_connection(config={}) - if config.is_a?(Hash) - config = {:bind_dn => dn, :allow_anonymous => false}.merge(config) + def bind(config_or_password={}, &block) + if config_or_password.is_a?(String) + config = {:password => config_or_password} + elsif config_or_password.respond_to?(:call) + config = {:password_block => config_or_password} + else + config = config_or_password end - super(config) + config = {:bind_dn => dn, :allow_anonymous => false}.merge(config) + config[:password_block] ||= block if block_given? + establish_connection(config) + before_connection = @connection begin @connection = nil Modified: trunk/lib/active_ldap/configuration.rb ============================================================================== --- trunk/lib/active_ldap/configuration.rb (original) +++ trunk/lib/active_ldap/configuration.rb Fri Aug 31 22:39:44 2007 @@ -32,8 +32,6 @@ # Whether or not to retry on timeouts DEFAULT_CONFIG[:retry_on_timeout] = true - DEFAULT_CONFIG[:initial_connection_check] = true - DEFAULT_CONFIG[:logger] = nil module ClassMethods @@ -82,8 +80,7 @@ @@defined_configurations.delete_if {|key, value| value == config} end - CONNECTION_CONFIGURATION_KEYS = [:base, :adapter, - :initial_connection_check] + CONNECTION_CONFIGURATION_KEYS = [:base, :adapter] def remove_connection_related_configuration(config) config.reject do |key, value| CONNECTION_CONFIGURATION_KEYS.include?(key) Modified: trunk/rails/plugin/active_ldap/init.rb ============================================================================== --- trunk/rails/plugin/active_ldap/init.rb (original) +++ trunk/rails/plugin/active_ldap/init.rb Fri Aug 31 22:39:44 2007 @@ -13,9 +13,7 @@ if File.exist?(ldap_configuration_file) configurations = YAML::load(ERB.new(IO.read(ldap_configuration_file)).result) ActiveLdap::Base.configurations = configurations - configuration = configurations[RAILS_ENV] - configuration = configuration.merge(:initial_connection_check => false) - ActiveLdap::Base.establish_connection(configuration) + ActiveLdap::Base.establish_connection else ActiveLdap::Base.class_eval do format = _("You should run 'script/generator scaffold_al' to make %s.") Modified: trunk/test/test_bind.rb ============================================================================== --- trunk/test/test_bind.rb (original) +++ trunk/test/test_bind.rb Fri Aug 31 22:39:44 2007 @@ -18,7 +18,7 @@ config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys config.delete(:bind_dn) config[:allow_anonymous] = true - ActiveLdap::Base.establish_connection(config) + connect(config) end assert(ActiveLdap::Base.connected?, "Checking is the connection was established.") @@ -33,7 +33,7 @@ end assert_nothing_raised do config[:allow_anonymous] = false - ActiveLdap::Base.establish_connection(config) + connect(config) end assert(ActiveLdap::Base.connected?, "Checking is the connection was established.") @@ -46,8 +46,14 @@ config = ActiveLdap::Base.configurations[LDAP_ENV].symbolize_keys config.delete(:bind_dn) config[:allow_anonymous] = false - ActiveLdap::Base.establish_connection(config) + connect(config) end assert(!ActiveLdap::Base.connection.bound?) + end + + private + def connect(config) + ActiveLdap::Base.establish_connection(config) + ActiveLdap::Base.connection.connect end end Modified: trunk/test/test_connection_per_class.rb ============================================================================== --- trunk/test/test_connection_per_class.rb (original) +++ trunk/test/test_connection_per_class.rb Fri Aug 31 22:39:44 2007 @@ -19,9 +19,10 @@ assert(anon_class.connection.bound?) assert_raises(ActiveLdap::AuthenticationError) do - non_anon_class.establish_connection(:bind_dn => nil, - :allow_anonymous => false, - :retry_limit => 0) + connect(non_anon_class, + :bind_dn => nil, + :allow_anonymous => false, + :retry_limit => 0) end assert(!non_anon_class.connection.bound?) @@ -40,11 +41,18 @@ assert(!anon_class.connection.bound?) assert_nothing_raised do - anon_class.establish_connection(:bind_dn => nil, - :allow_anonymous => true) + connect(anon_class, + :bind_dn => nil, + :allow_anonymous => true) end assert(!non_anon_class.connection.bound?) assert(anon_class.connection.bound?) + end + + private + def connect(klass, config) + klass.establish_connection(config) + klass.connection.connect end end Modified: trunk/test/test_connection_per_dn.rb ============================================================================== --- trunk/test/test_connection_per_dn.rb (original) +++ trunk/test/test_connection_per_dn.rb Fri Aug 31 22:39:44 2007 @@ -10,15 +10,15 @@ make_temporary_user do |user, password| assert_equal(user.class.connection, user.connection) assert_raises(ActiveLdap::AuthenticationError) do - user.establish_connection(:bind_dn => nil, - :allow_anonymous => false, - :retry_limit => 0) + user.bind(:bind_dn => nil, + :allow_anonymous => false, + :retry_limit => 0) end assert_equal(user.class.connection, user.connection) assert_nothing_raised do - user.establish_connection(:bind_dn => nil, - :allow_anonymous => true) + user.bind(:bind_dn => nil, + :allow_anonymous => true) end assert_not_equal(user.class.connection, user.connection) @@ -30,8 +30,7 @@ def test_find make_temporary_user do |user, password| make_temporary_user do |user2, password2| - user.establish_connection(:bind_dn => user.dn, - :password => password) + user.bind(password) assert_not_equal(user.class.connection, user.connection) found_user2 = user.find(user2.dn) @@ -41,8 +40,7 @@ assert_equal(found_user2.class.connection, found_user2.class.find(found_user2.dn).connection) - found_user2.establish_connection(:bind_dn => user2.dn, - :password => password2) + found_user2.bind(password2) assert_not_equal(user.connection, found_user2.connection) assert_equal(user2.connection, found_user2.connection) end @@ -56,8 +54,7 @@ user.groups = [group1] assert_equal(group1.connection, user.connection) - user.establish_connection(:bind_dn => user.dn, - :password => password) + user.bind(password) assert_not_equal(user.class.connection, user.connection) assert_not_equal(group1.connection, user.connection) assert_equal(user.groups[0].connection, user.connection) From codesite-noreply at google.com Sun Sep 2 02:29:55 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sat, 01 Sep 2007 23:29:55 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r351 - in trunk: lib/active_ldap lib/active_ldap/schema test Message-ID: Author: koutou Date: Sat Sep 1 23:29:40 2007 New Revision: 351 Added: trunk/test/test_syntax.rb Modified: trunk/lib/active_ldap/schema.rb trunk/lib/active_ldap/schema/syntaxes.rb trunk/lib/active_ldap/validations.rb trunk/test/test_connection.rb trunk/test/test_validation.rb Log: * added tests for syntax. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Sat Sep 1 23:29:40 2007 @@ -8,6 +8,7 @@ end def ids(group) + ensure_parse(group) info, ids, aliases = ensure_schema_info(group) ids.keys end @@ -288,10 +289,14 @@ end def valid?(value) + validate(value).nil? + end + + def validate(value) if @validator - @validator.valid?(value) + @validator.validate(value) else - true + nil end end @@ -347,21 +352,19 @@ end def syntax - return @syntax if @syntax - return @super_attribute.syntax if @super_attribute - nil + (@derived_syntax ||= [deriver_syntax])[0] end def valid?(value) - _syntax = syntax - return true if _syntax.nil? - _syntax.valid?(value) + validate(value).nil? + end + + def validate(value) + send_to_syntax(nil, :validate, value) end def syntax_description - _syntax = syntax - return nil if _syntax.nil? - _syntax.description + send_to_syntax(nil, :description) end private @@ -386,6 +389,21 @@ else @binary_required = false @binary = false + end + end + + def deriver_syntax + return @syntax if @syntax + return @super_attribute.syntax if @super_attribute + nil + end + + def send_to_syntax(default_value, method_name, *args) + _syntax = syntax + if _syntax + _syntax.send(method_name, *args) + else + default_value end end end Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sat Sep 1 23:29:40 2007 @@ -14,18 +14,20 @@ class Base SYNTAXES = {} + + def valid?(value) + validate(value).nil? + end end class DistinguishedName < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.12"] = self - def valid?(value) - begin - DN.parse(value) - true - rescue DistinguishedNameInvalid - false - end + def validate(value) + DN.parse(value) + nil + rescue DistinguishedNameInvalid + $!.message end end end Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Sat Sep 1 23:29:40 2007 @@ -114,13 +114,15 @@ def validate_ldap_values @attribute_schemata.each do |name, attribute| self[name, true].each do |value| - unless attribute.valid?(value) + failed_reason = attribute.validate(value) + if failed_reason params = [value, - self.class.human_syntax_description(attribute.syntax)] + self.class.human_syntax_description(attribute.syntax), + failed_reason] if ActiveLdap.get_text_supported? - format = _("%{fn} has invalid format: %s: required syntax: %s") + format = _("%{fn} has invalid format: %s: required syntax: %s: %s") else - format = _("has invalid format: %s: required syntax: %s") + format = _("has invalid format: %s: required syntax: %s: %s") end errors.add(name, format % params) end Modified: trunk/test/test_connection.rb ============================================================================== --- trunk/test/test_connection.rb (original) +++ trunk/test/test_connection.rb Sat Sep 1 23:29:40 2007 @@ -24,6 +24,7 @@ begin connector.establish_connection(:bind_format => "uid=%s,dc=test", :allow_anonymous => false) + connector.connection.connect rescue Exception exception = $! raise Added: trunk/test/test_syntax.rb ============================================================================== --- (empty file) +++ trunk/test/test_syntax.rb Sat Sep 1 23:29:40 2007 @@ -0,0 +1,77 @@ +require 'al-test-utils' + +class TestSyntax < Test::Unit::TestCase + include AlTestUtils + include ActiveLdap::Helper + + SYNTAXES = \ + [ + "( 1.3.6.1.1.16.1 DESC 'UUID' )", + "( 1.3.6.1.1.1.0.1 DESC 'RFC2307 Boot Parameter' )", + "( 1.3.6.1.1.1.0.0 DESC 'RFC2307 NIS Netgroup Triple' )", + "( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )", + "( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )", + "( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' " + + "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' )", + "( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )", + "( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )", + "( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )", + "( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )", + "( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )", + "( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )", + "( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )", + "( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )", + "( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )", + "( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )", + "( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )", + "( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )", + "( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )", + "( 1.2.36.79672281.1.5.0 DESC 'RDN' )", + "( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )", + "( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )", + "( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' " + + "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' " + + "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' " + + "X-BINARY-TRANSFER-REQUIRED 'TRUE' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )", + "( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )", + "( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' X-NOT-HUMAN-READABLE 'TRUE' )", + "( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' X-NOT-HUMAN-READABLE 'TRUE' )" + ] + + def setup + @schema = ActiveLdap::Schema.new("ldapSyntaxes" => SYNTAXES.dup) + @syntaxes = {} + @schema.ldap_syntaxes.each do |syntax| + @syntaxes[syntax.description] = syntax + end + end + + def teardown + end + + priority :must + def test_dn + assert_valid('Distinguished Name', "cn=test") + + value = "test" + params = [value, _("attribute value is missing")] + assert_invalid(_('%s is invalid distinguished name (DN): %s') % params, + 'Distinguished Name', value) + end + + priority :normal + + private + def assert_valid(syntax_name, value) + assert_nil(@syntaxes[syntax_name].validate(value)) + end + + def assert_invalid(reason, syntax_name, value) + assert_equal(reason, @syntaxes[syntax_name].validate(value)) + end +end Modified: trunk/test/test_validation.rb ============================================================================== --- trunk/test/test_validation.rb (original) +++ trunk/test/test_validation.rb Sat Sep 1 23:29:40 2007 @@ -12,19 +12,23 @@ user.see_also = "cn=test,dc=example,dc=com" assert(user.save) - user.see_also = "test" + value = "test" + user.see_also = value assert(!user.save) assert(user.errors.invalid?(:seeAlso)) assert_equal(1, user.errors.size) + syntax_description = lsd_("1.3.6.1.4.1.1466.115.121.1.12") assert_not_nil(syntax_description) - params = ["test", syntax_description] + reason_params = [value, _("attribute value is missing")] + reason = _('%s is invalid distinguished name (DN): %s') % reason_params + params = [value, syntax_description, reason] if ActiveLdap.get_text_supported? - format = _("%{fn} has invalid format: %s: required syntax: %s") + format = _("%{fn} has invalid format: %s: required syntax: %s: %s") format = format % {:fn => la_("seeAlso")} assert_equal([format % params], user.errors.full_messages) else - format = _("has invalid value: %s: required syntax: %s") + format = _("has invalid value: %s: required syntax: %s: %s") assert_equal([format % params], user.errors.full_messages) end end From codesite-noreply at google.com Sun Sep 2 02:56:57 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sat, 01 Sep 2007 23:56:57 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r352 - in trunk: lib/active_ldap lib/active_ldap/schema test Message-ID: <163600d1b50439218fe7186c503ecc@google.com> Author: koutou Date: Sat Sep 1 23:55:55 2007 New Revision: 352 Modified: trunk/lib/active_ldap/schema.rb trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * added some syntaxes: bit string and boolean. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Sat Sep 1 23:55:55 2007 @@ -352,7 +352,7 @@ end def syntax - (@derived_syntax ||= [deriver_syntax])[0] + (@derived_syntax ||= [derived_syntax])[0] end def valid?(value) @@ -392,7 +392,7 @@ end end - def deriver_syntax + def derived_syntax return @syntax if @syntax return @super_attribute.syntax if @super_attribute nil Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sat Sep 1 23:55:55 2007 @@ -13,10 +13,43 @@ end class Base + include GetTextSupport SYNTAXES = {} def valid?(value) validate(value).nil? + end + end + + class BitString < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.6"] = self + + def validate(value) + if /\A'/ !~ value + return _("%s doesn't have the first \"'\"" % value.inspect) + end + + if /'B\z/ !~ value + return _("%s doesn't have the last \"'B\"" % value.inspect) + end + + if /([^01])/ =~ value[1..-3] + return _("%s has invalid character '%s'" % [value.inspect, $1]) + end + + nil + end + end + + class Boolean < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.7"] = self + + def validate(value) + if %w(TRUE FALSE).include?(value) + nil + else + _("%s should be TRUE or FALSE") % value.inspect + end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sat Sep 1 23:55:55 2007 @@ -56,22 +56,52 @@ priority :must def test_dn - assert_valid('Distinguished Name', "cn=test") + assert_valid("cn=test", 'Distinguished Name') value = "test" params = [value, _("attribute value is missing")] assert_invalid(_('%s is invalid distinguished name (DN): %s') % params, - 'Distinguished Name', value) + value, 'Distinguished Name') + end + + def test_bit_string + assert_valid("'0101111101'B", 'Bit String') + assert_valid("''B", 'Bit String') + + value = "0101111101" + assert_invalid(_("%s doesn't have the first \"'\"") % value.inspect, + value, 'Bit String') + + value = "'0101111101'" + assert_invalid(_("%s doesn't have the last \"'B\"") % value.inspect, + value, 'Bit String') + + value = "'0101111101B" + assert_invalid(_("%s doesn't have the last \"'B\"") % value.inspect, + value, 'Bit String') + + value = "'0A'B" + assert_invalid(_("%s has invalid character '%s'") % [value.inspect, "A"], + value, 'Bit String') + end + + def test_boolean + assert_valid("TRUE", "Boolean") + assert_valid("FALSE", "Boolean") + + value = "true" + assert_invalid(_("%s should be TRUE or FALSE") % value.inspect, + value, "Boolean") end priority :normal private - def assert_valid(syntax_name, value) + def assert_valid(value, syntax_name) assert_nil(@syntaxes[syntax_name].validate(value)) end - def assert_invalid(reason, syntax_name, value) + def assert_invalid(reason, value, syntax_name) assert_equal(reason, @syntaxes[syntax_name].validate(value)) end end From codesite-noreply at google.com Sun Sep 2 04:20:00 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 02 Sep 2007 01:20:00 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r353 - in trunk: lib/active_ldap/schema test Message-ID: <163600cf97043922b8ea6664506940@google.com> Author: koutou Date: Sun Sep 2 01:19:09 2007 New Revision: 353 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Generalized Time syntax. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sun Sep 2 01:19:09 2007 @@ -53,6 +53,18 @@ end end + class CountryString < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.11"] = self + + def validate(value) + if /\A[a-z\d"()+,\-.\/:? ]{2,2}\z/i =~ value + nil + else + _("%s should be just 2 printable characters") % value.inspect + end + end + end + class DistinguishedName < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.12"] = self @@ -61,6 +73,49 @@ nil rescue DistinguishedNameInvalid $!.message + end + end + + class DirectoryString < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.15"] = self + + def validate(value) + value.unpack("U*") + nil + rescue ArgumentError + _("%s has invalid UTF-8 character") % value.inspect + end + end + + class GeneralizedTime < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.24"] = self + + def validate(value) + match_data = /\A + (\d{4,4})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2}(?:[,.]\d+)?)? + ([+-]\d{4,4}|Z)? + \z/x.match(value) + if match_data + year, month, day, hour, minute, second, time_zone = + match_data.to_a[1..-1] + missing_components = [] + %w(year month day hour minute).each do |component| + missing_components << component unless eval(component) + end + if missing_components.empty? + nil + else + params = [value.inspect, missing_components.join(", ")] + _("%s has missing components: %s") % params + end + else + _("%s is invalid time format") + end end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sun Sep 2 01:19:09 2007 @@ -55,15 +55,6 @@ end priority :must - def test_dn - assert_valid("cn=test", 'Distinguished Name') - - value = "test" - params = [value, _("attribute value is missing")] - assert_invalid(_('%s is invalid distinguished name (DN): %s') % params, - value, 'Distinguished Name') - end - def test_bit_string assert_valid("'0101111101'B", 'Bit String') assert_valid("''B", 'Bit String') @@ -92,6 +83,54 @@ value = "true" assert_invalid(_("%s should be TRUE or FALSE") % value.inspect, value, "Boolean") + end + + def test_country_string + assert_valid("ja", "Country String") + assert_valid("JA", "Country String") + + value = "japan" + assert_invalid(_("%s should be just 2 printable characters") % value.inspect, + value, "Country String") + end + + def test_dn + assert_valid("cn=test", 'Distinguished Name') + assert_valid("CN=Steve Kille,O=Isode Limited,C=GB", 'Distinguished Name') + assert_valid("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US", 'Distinguished Name') + assert_valid("CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB", + 'Distinguished Name') + assert_valid("CN=Before\\0DAfter,O=Test,C=GB", 'Distinguished Name') + assert_valid("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB", + 'Distinguished Name') + assert_valid("SN=Lu\\C4\\8Di\\C4\\87", 'Distinguished Name') + + value = "test" + params = [value, _("attribute value is missing")] + assert_invalid(_('%s is invalid distinguished name (DN): %s') % params, + value, 'Distinguished Name') + end + + def test_directory_string + assert_valid("This is a string of DirectoryString containing \#!%\#@", + "Directory String") + assert_valid(" DirectoryString ", + "Directory String") + + value = NKF.nkf("-We", " DirectoryString ") + assert_invalid(_("%s has invalid UTF-8 character") % value.inspect, + value, "Directory String") + end + + def test_generalized_time + assert_valid("199412161032", "Generalized Time") + assert_valid("199412161032Z", "Generalized Time") + assert_valid("199412161032+0900", "Generalized Time") + + value = "1994" + params = [value.inspect, %w(month day hour minute).join(", ")] + assert_invalid("%s has missing components: %s" % params, + value, "Generalized Time") end priority :normal From codesite-noreply at google.com Sun Sep 2 04:54:04 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 02 Sep 2007 01:54:04 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r354 - in trunk: lib/active_ldap/schema po/ja test Message-ID: Author: koutou Date: Sun Sep 2 01:53:41 2007 New Revision: 354 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/po/ja/active-ldap.po trunk/test/test_syntax.rb Log: * supported integer and JPEG syntaxes. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sun Sep 2 01:53:41 2007 @@ -118,6 +118,29 @@ end end end + + class Integer < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.27"] = self + + def validate(value) + Integer(value) + nil + rescue ArgumentError + _("%s is invalid integer format") % value.inspect + end + end + + class JPEG < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.28"] = self + + def validate(value) + if value.unpack("n")[0] == 0xffd8 + nil + else + _("invalid JPEG format") + end + end + end end end end Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Sun Sep 2 01:53:41 2007 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" "POT-Creation-Date: 2007-09-01 13:34+0900\n" -"PO-Revision-Date: 2007-09-01 13:36+0900\n" +"PO-Revision-Date: 2007-09-02 17:24+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -2698,7 +2698,7 @@ #: -:- msgid "LDAP|Description|Syntax|1.3.6.1.4.1.1466.115.121.1.15|Directory String" -msgstr "???????????????????????" +msgstr "??????????UTF-8???" #: -:- msgid "" @@ -2712,7 +2712,7 @@ #: -:- msgid "LDAP|Description|Syntax|1.3.6.1.4.1.1466.115.121.1.26|IA5 String" -msgstr "IA5????????????????" +msgstr "IA5???????????" #: -:- msgid "LDAP|Description|Syntax|1.3.6.1.4.1.1466.115.121.1.27|Integer" Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sun Sep 2 01:53:41 2007 @@ -133,6 +133,20 @@ value, "Generalized Time") end + def test_integer + assert_valid("1321", "Integer") + + assert_invalid_integer("13.5") + assert_invalid_integer("string") + end + + def test_jpeg + assert_valid([0xffd8].pack("n"), "JPEG") + + assert_invalid(_("invalid JPEG format"), "", "JPEG") + assert_invalid(_("invalid JPEG format"), "jpeg", "JPEG") + end + priority :normal private @@ -142,5 +156,10 @@ def assert_invalid(reason, value, syntax_name) assert_equal(reason, @syntaxes[syntax_name].validate(value)) + end + + def assert_invalid_integer(value) + assert_invalid(_("%s is invalid integer format") % value.inspect, + value, "Integer") end end From codesite-noreply at google.com Sun Sep 2 07:06:20 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 02 Sep 2007 04:06:20 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r355 - in trunk: lib/active_ldap/schema test Message-ID: <163600d06e0439250bb8003c509fee@google.com> Author: koutou Date: Sun Sep 2 04:06:05 2007 New Revision: 355 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported some syntaxes: Name and Optional UID, Numeric String, OID and Other Mailbox Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sun Sep 2 04:06:05 2007 @@ -16,6 +16,10 @@ include GetTextSupport SYNTAXES = {} + printable_character_source = "a-zA-Z\\d\"()+,\\-.\\/:? " + PRINTABLE_CHARACTER = /[#{printable_character_source}]/ # + UNPRINTABLE_CHARACTER = /[^#{printable_character_source}]/ # + def valid?(value) validate(value).nil? end @@ -57,7 +61,7 @@ SYNTAXES["1.3.6.1.4.1.1466.115.121.1.11"] = self def validate(value) - if /\A[a-z\d"()+,\-.\/:? ]{2,2}\z/i =~ value + if /\A#{PRINTABLE_CHARACTER}{2,2}\z/i =~ value nil else _("%s should be just 2 printable characters") % value.inspect @@ -139,6 +143,79 @@ else _("invalid JPEG format") end + end + end + + class NameAndOptionalUID < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.34"] = self + + def validate(value) + separator_index = value.rindex("#") + if separator_index + dn = value[0, separator_index] + bit_string = value[(separator_index + 1)..-1] + bit_string_reason = BitString.new.validate(bit_string) + dn_reason = DistinguishedName.new.validate(dn) + if bit_string_reason + if dn_reason + value_reason = DistinguishedName.new.validate(value) + return nil unless value_reason + dn_reason + else + bit_string_reason + end + else + dn_reason + end + else + DistinguishedName.new.validate(value) + end + end + end + + class NumericString < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.36"] = self + + def validate(value) + if /\A\d+\z/ =~ value + nil + else + _("%s is invalid numeric format") % value.inspect + end + end + end + + class OID < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.38"] = self + + def validate(value) + DN.parse("#{value}=dummy") + nil + rescue DistinguishedNameInvalid + _("%s is invalid OID format") % value.inspect + end + end + + class OtherMailbox < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.39"] = self + + def validate(value) + type, mailbox = value.split('$', 2) + + if type.empty? + return _("%s has no mailbox type") % value.inspect + end + + if /(#{UNPRINTABLE_CHARACTER})/i =~ type + format = _("%s has unprintable character in mailbox type: '%s'") + return format % [value.inspect, $1] + end + + if mailbox.blank? + return _("%s has no mailbox") % value.inspect + end + + nil end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sun Sep 2 04:06:05 2007 @@ -147,6 +147,59 @@ assert_invalid(_("invalid JPEG format"), "jpeg", "JPEG") end + def test_name_and_optional_uid + assert_valid("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B", + "Name And Optional UID") + assert_valid("cn=test", "Name And Optional UID") + + value = "test" + params = [value, _("attribute value is missing")] + assert_invalid(_('%s is invalid distinguished name (DN): %s') % params, + value, "Name And Optional UID") + + bit_string = "'00x'B" + params = [bit_string.inspect, "x"] + assert_invalid(_("%s has invalid character '%s'") % params, + "cn=test\##{bit_string}", "Name And Optional UID") + end + + def test_numeric_string + assert_valid("1997", "Numeric String") + + assert_invalid_numeric_string("-3") + assert_invalid_numeric_string("-3.5") + assert_invalid_numeric_string("string") + end + + def test_oid + assert_valid("1.2.3.4", "OID") + assert_valid("cn", "OID") + + assert_invalid_oid("\#@!") + end + + def test_other_mailbox + assert_valid("smtp$bob at example.com", "Other Mailbox") + + + value = "smtp" + assert_invalid(_("%s has no mailbox") % value.inspect, + value, "Other Mailbox") + + value = "smtp$" + assert_invalid(_("%s has no mailbox") % value.inspect, + value, "Other Mailbox") + + value = "$bob at example.com" + assert_invalid(_("%s has no mailbox type") % value.inspect, + value, "Other Mailbox") + + value = "!$bob at example.com" + params = [value.inspect, "!"] + reason = _("%s has unprintable character in mailbox type: '%s'") % params + assert_invalid(reason, value, "Other Mailbox") + end + priority :normal private @@ -161,5 +214,15 @@ def assert_invalid_integer(value) assert_invalid(_("%s is invalid integer format") % value.inspect, value, "Integer") + end + + def assert_invalid_numeric_string(value) + assert_invalid(_("%s is invalid numeric format") % value.inspect, + value, "Numeric String") + end + + def assert_invalid_oid(value) + assert_invalid(_("%s is invalid OID format") % value.inspect, + value, "OID") end end From codesite-noreply at google.com Sun Sep 2 07:42:24 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 02 Sep 2007 04:42:24 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r356 - in trunk: lib lib/active_ldap test Message-ID: Author: koutou Date: Sun Sep 2 04:41:21 2007 New Revision: 356 Added: trunk/lib/active_ldap/get_text.rb Modified: trunk/lib/active_ldap.rb trunk/lib/active_ldap/get_text_fallback.rb trunk/lib/active_ldap/get_text_support.rb trunk/test/test_validation.rb Log: * improved non-gettext environement support. Modified: trunk/lib/active_ldap.rb ============================================================================== --- trunk/lib/active_ldap.rb (original) +++ trunk/lib/active_ldap.rb Sun Sep 2 04:41:21 2007 @@ -933,12 +933,9 @@ require_gem_if_need.call("active_record/base", "activerecord") begin require_gem_if_need.call("gettext/active_record", "gettext") - ActiveLdap.const_set("GetText", GetText) rescue LoadError - require 'active_ldap/get_text_fallback' end - -require 'active_ldap/get_text_support' +require 'active_ldap/get_text' require 'active_ldap/base' require 'active_ldap/associations' Added: trunk/lib/active_ldap/get_text.rb ============================================================================== --- (empty file) +++ trunk/lib/active_ldap/get_text.rb Sun Sep 2 04:41:21 2007 @@ -0,0 +1,8 @@ +begin + require "gettext/active_record" + ActiveLdap.const_set("GetText", GetText) +rescue LoadError + require 'active_ldap/get_text_fallback' +end + +require 'active_ldap/get_text_support' Modified: trunk/lib/active_ldap/get_text_fallback.rb ============================================================================== --- trunk/lib/active_ldap/get_text_fallback.rb (original) +++ trunk/lib/active_ldap/get_text_fallback.rb Sun Sep 2 04:41:21 2007 @@ -36,11 +36,11 @@ end def sgettext(msg_id, div='|') - index = msg.rindex(div) + index = msg_id.rindex(div) if index - msg[(index + 1)..-1] + msg_id[(index + 1)..-1] else - msg + msg_id end end Modified: trunk/lib/active_ldap/get_text_support.rb ============================================================================== --- trunk/lib/active_ldap/get_text_support.rb (original) +++ trunk/lib/active_ldap/get_text_support.rb Sun Sep 2 04:41:21 2007 @@ -1,10 +1,12 @@ module ActiveLdap - class << self - if const_defined?(:GetTextFallback) + if const_defined?(:GetTextFallback) + class << self def get_text_supported? false end - else + end + else + class << self def get_text_supported? true end Modified: trunk/test/test_validation.rb ============================================================================== --- trunk/test/test_validation.rb (original) +++ trunk/test/test_validation.rb Sun Sep 2 04:41:21 2007 @@ -28,8 +28,8 @@ format = format % {:fn => la_("seeAlso")} assert_equal([format % params], user.errors.full_messages) else - format = _("has invalid value: %s: required syntax: %s: %s") - assert_equal([format % params], user.errors.full_messages) + format = _("has invalid format: %s: required syntax: %s: %s") + assert_equal(["seeAlso #{format % params}"], user.errors.full_messages) end end end From codesite-noreply at google.com Mon Sep 3 07:52:49 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 03 Sep 2007 04:52:49 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r357 - in trunk: lib/active_ldap/schema test Message-ID: <163600d519043939cfd932163631a@google.com> Author: koutou Date: Mon Sep 3 04:52:18 2007 New Revision: 357 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Postal Address syntax. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Sep 3 04:52:18 2007 @@ -218,6 +218,24 @@ nil end end + + class PostalAddress < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.41"] = self + + def validate(value) + if value.blank? + return _("empty string") + end + + begin + value.unpack("U*") + rescue ArgumentError + return _("%s has invalid UTF-8 character") % value.inspect + end + + nil + end + end end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Sep 3 04:52:18 2007 @@ -200,6 +200,21 @@ assert_invalid(reason, value, "Other Mailbox") end + def test_postal_address + assert_valid("1234 Main St.$Anytown, CA 12345$USA", "Postal Address") + assert_valid("\\241,000,000 Sweepstakes$PO Box 1000000$Anytown, " + + "CA 12345$USA", "Postal Address") + assert_valid("$", "Postal Address") + assert_valid("1234 Main St.$", "Postal Address") + + + assert_invalid(_("empty string"), "", "Postal Address") + + value = NKF.nkf("-We", " ") + assert_invalid(_("%s has invalid UTF-8 character") % value.inspect, + value, "Postal Address") + end + priority :normal private From codesite-noreply at google.com Mon Sep 3 08:00:51 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 03 Sep 2007 05:00:51 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r358 - in trunk: lib/active_ldap/schema test Message-ID: Author: koutou Date: Mon Sep 3 05:00:33 2007 New Revision: 358 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Printable String syntax. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Sep 3 05:00:33 2007 @@ -236,6 +236,23 @@ nil end end + + class PrintableString < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.44"] = self + + def validate(value) + if value.blank? + return _("empty string") + end + + if /(#{UNPRINTABLE_CHARACTER})/i =~ value + format = _("%s has unprintable character: '%s'") + return format % [value.inspect, $1] + end + + nil + end + end end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Sep 3 05:00:33 2007 @@ -215,6 +215,23 @@ value, "Postal Address") end + def test_printable_string + assert_valid("This is a PrintableString", "Printable String") + + assert_invalid(_("empty string"), "", "Printable String") + + + value = "abc!def" + params = [value.inspect, "!"] + reason = _("%s has unprintable character: '%s'") % params + assert_invalid(reason, value, "Printable String") + + value = "abc def" + params = [value.inspect, " "] + reason = _("%s has unprintable character: '%s'") % params + assert_invalid(reason, value, "Printable String") + end + priority :normal private From codesite-noreply at google.com Mon Sep 3 08:04:51 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 03 Sep 2007 05:04:51 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r359 - in trunk: lib/active_ldap/schema test Message-ID: <163600d06e043939fadd668953ce0c@google.com> Author: koutou Date: Mon Sep 3 05:03:11 2007 New Revision: 359 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Telephone Number syntax. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Sep 3 05:03:11 2007 @@ -253,6 +253,14 @@ nil end end + + class TelephoneNumber < Base + SYNTAXES["1.3.6.1.4.1.1466.115.121.1.50"] = self + + def validate(value) + PrintableString.new.validate(value) + end + end end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Sep 3 05:03:11 2007 @@ -232,6 +232,17 @@ assert_invalid(reason, value, "Printable String") end + def test_telephone_number + assert_valid("+1 512 305 0280", "Telephone Number") + + assert_invalid(_("empty string"), "", "Telephone Number") + + value = "+1 5!2 305 0280" + params = [value.inspect, "!"] + reason = _("%s has unprintable character: '%s'") % params + assert_invalid(reason, value, "Telephone Number") + end + priority :normal private From codesite-noreply at google.com Mon Sep 3 08:11:55 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 03 Sep 2007 05:11:55 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r360 - in trunk/po: en ja Message-ID: <163600d1b504393a1420eda953daf0@google.com> Author: koutou Date: Mon Sep 3 05:11:51 2007 New Revision: 360 Modified: trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po Log: * updated messages. Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Mon Sep 3 05:11:51 2007 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-01 13:34+0900\n" +"POT-Creation-Date: 2007-09-03 21:03+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -3331,12 +3331,12 @@ msgid "%{fn} is required attribute by objectClass '%s': aliases: %s" msgstr "" -#: lib/active_ldap/validations.rb:121 -msgid "%{fn} has invalid format: %s: required syntax: %s" +#: lib/active_ldap/validations.rb:123 +msgid "%{fn} has invalid format: %s: required syntax: %s: %s" msgstr "" -#: lib/active_ldap/validations.rb:123 -msgid "has invalid format: %s: required syntax: %s" +#: lib/active_ldap/validations.rb:125 +msgid "has invalid format: %s: required syntax: %s: %s" msgstr "" #: lib/active_ldap/command.rb:16 @@ -3407,7 +3407,7 @@ msgid "salt size must be == 4: %s" msgstr "" -#: lib/active_ldap/schema.rb:49 +#: lib/active_ldap/schema.rb:50 msgid "Unknown schema group: %s" msgstr "" @@ -3435,36 +3435,36 @@ msgid "%s is unknown attribute" msgstr "" -#: lib/active_ldap/base.rb:323 +#: lib/active_ldap/base.rb:321 msgid "scope '%s' must be a Symbol" msgstr "" -#: lib/active_ldap/base.rb:427 +#: lib/active_ldap/base.rb:425 msgid "" "'%s' must be either nil, DN value as String or Array or attributes as Hash" msgstr "" -#: lib/active_ldap/base.rb:509 +#: lib/active_ldap/base.rb:507 msgid "%s's DN attribute (%s) isn't set" msgstr "" -#: lib/active_ldap/base.rb:542 +#: lib/active_ldap/base.rb:540 msgid "Failed to delete LDAP entry: %s" msgstr "" -#: lib/active_ldap/base.rb:561 +#: lib/active_ldap/base.rb:559 msgid "entry %s can't be saved" msgstr "" -#: lib/active_ldap/base.rb:582 lib/active_ldap/base.rb:593 +#: lib/active_ldap/base.rb:580 lib/active_ldap/base.rb:591 msgid "wrong number of arguments (%d for 1)" msgstr "" -#: lib/active_ldap/base.rb:709 +#: lib/active_ldap/base.rb:707 msgid "Can't find DN '%s' to reload" msgstr "" -#: lib/active_ldap/base.rb:1132 +#: lib/active_ldap/base.rb:1137 msgid "dn_attribute isn't set for this class: %s" msgstr "" @@ -3522,6 +3522,76 @@ #: lib/active_ldap/operations.rb:283 msgid "Couldn't find all %s: DNs (%s)" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:33 +msgid "%s doesn't have the first \"'\"" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:37 +msgid "%s doesn't have the last \"'B\"" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:41 +msgid "%s has invalid character '%s'" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:55 +msgid "%s should be TRUE or FALSE" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:67 +msgid "%s should be just 2 printable characters" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:90 +#: lib/active_ldap/schema/syntaxes.rb:233 +msgid "%s has invalid UTF-8 character" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:118 +msgid "%s has missing components: %s" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:121 +msgid "%s is invalid time format" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:133 +msgid "%s is invalid integer format" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:144 +msgid "invalid JPEG format" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:183 +msgid "%s is invalid numeric format" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:195 +msgid "%s is invalid OID format" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:206 +msgid "%s has no mailbox type" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:210 +msgid "%s has unprintable character in mailbox type: '%s'" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:215 +msgid "%s has no mailbox" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:227 +#: lib/active_ldap/schema/syntaxes.rb:245 +msgid "empty string" +msgstr "" + +#: lib/active_ldap/schema/syntaxes.rb:249 +msgid "%s has unprintable character: '%s'" msgstr "" #: rails/plugin/active_ldap/init.rb:7 Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Mon Sep 3 05:11:51 2007 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-01 13:34+0900\n" -"PO-Revision-Date: 2007-09-02 17:24+0900\n" +"POT-Creation-Date: 2007-09-03 21:03+0900\n" +"PO-Revision-Date: 2007-09-03 21:11+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -3345,13 +3345,13 @@ msgid "%{fn} is required attribute by objectClass '%s': aliases: %s" msgstr "%{fn}?objectClass'%s'????????: ??: %s" -#: lib/active_ldap/validations.rb:121 -msgid "%{fn} has invalid format: %s: required syntax: %s" -msgstr "%{fn}????????: %s: ?????????: %s" - #: lib/active_ldap/validations.rb:123 -msgid "has invalid format: %s: required syntax: %s" -msgstr "???????: %s: ?????????: %s" +msgid "%{fn} has invalid format: %s: required syntax: %s: %s" +msgstr "%{fn}????????: %s: ?????????: %s: %s" + +#: lib/active_ldap/validations.rb:125 +msgid "has invalid format: %s: required syntax: %s: %s" +msgstr "???????: %s: ?????????: %s: %s" #: lib/active_ldap/command.rb:16 msgid "Common options:" @@ -3424,7 +3424,7 @@ msgid "salt size must be == 4: %s" msgstr "salt?4????????????: %s" -#: lib/active_ldap/schema.rb:49 +#: lib/active_ldap/schema.rb:50 msgid "Unknown schema group: %s" msgstr "?????????????: %s" @@ -3453,38 +3453,38 @@ msgid "%s is unknown attribute" msgstr "%s?????????" -#: lib/active_ldap/base.rb:323 +#: lib/active_ldap/base.rb:321 msgid "scope '%s' must be a Symbol" msgstr "????'%s'????????????????" -#: lib/active_ldap/base.rb:427 +#: lib/active_ldap/base.rb:425 msgid "" "'%s' must be either nil, DN value as String or Array or attributes as Hash" msgstr "" "'%s'?nil?String???DN?DN????Hash??????????????????" "??" -#: lib/active_ldap/base.rb:509 +#: lib/active_ldap/base.rb:507 msgid "%s's DN attribute (%s) isn't set" msgstr "%s?DN??(%s)???????????" -#: lib/active_ldap/base.rb:542 +#: lib/active_ldap/base.rb:540 msgid "Failed to delete LDAP entry: %s" msgstr "LDAP??????????????: %s" -#: lib/active_ldap/base.rb:561 +#: lib/active_ldap/base.rb:559 msgid "entry %s can't be saved" msgstr "????%s?????????" -#: lib/active_ldap/base.rb:582 lib/active_ldap/base.rb:593 +#: lib/active_ldap/base.rb:580 lib/active_ldap/base.rb:591 msgid "wrong number of arguments (%d for 1)" msgstr "??????????(1???????%d???????)" -#: lib/active_ldap/base.rb:709 +#: lib/active_ldap/base.rb:707 msgid "Can't find DN '%s' to reload" msgstr "???????DN '%s'?????????" -#: lib/active_ldap/base.rb:1132 +#: lib/active_ldap/base.rb:1137 msgid "dn_attribute isn't set for this class: %s" msgstr "??????dn_attribute??????????: %s" @@ -3545,6 +3545,76 @@ msgid "Couldn't find all %s: DNs (%s)" msgstr "????%s????????????: DN (%s)" +#: lib/active_ldap/schema/syntaxes.rb:33 +msgid "%s doesn't have the first \"'\"" +msgstr "%s?????\"'\"???????" + +#: lib/active_ldap/schema/syntaxes.rb:37 +msgid "%s doesn't have the last \"'B\"" +msgstr "%s?????\"'B\"???????" + +#: lib/active_ldap/schema/syntaxes.rb:41 +msgid "%s has invalid character '%s'" +msgstr "%s??????'%s'????????" + +#: lib/active_ldap/schema/syntaxes.rb:55 +msgid "%s should be TRUE or FALSE" +msgstr "%s?TRUE???FALSE????????????????" + +#: lib/active_ldap/schema/syntaxes.rb:67 +msgid "%s should be just 2 printable characters" +msgstr "%s?????2??????????????????????" + +#: lib/active_ldap/schema/syntaxes.rb:90 +#: lib/active_ldap/schema/syntaxes.rb:233 +msgid "%s has invalid UTF-8 character" +msgstr "%s????UTF-8??????????" + +#: lib/active_ldap/schema/syntaxes.rb:118 +msgid "%s has missing components: %s" +msgstr "%s???????????: %s" + +#: lib/active_ldap/schema/syntaxes.rb:121 +msgid "%s is invalid time format" +msgstr "%s????????????" + +#: lib/active_ldap/schema/syntaxes.rb:133 +msgid "%s is invalid integer format" +msgstr "%s????????????" + +#: lib/active_ldap/schema/syntaxes.rb:144 +msgid "invalid JPEG format" +msgstr "???JPEG?????" + +#: lib/active_ldap/schema/syntaxes.rb:183 +msgid "%s is invalid numeric format" +msgstr "%s????????????" + +#: lib/active_ldap/schema/syntaxes.rb:195 +msgid "%s is invalid OID format" +msgstr "%s????OID??????" + +#: lib/active_ldap/schema/syntaxes.rb:206 +msgid "%s has no mailbox type" +msgstr "%s??????????????????" + +#: lib/active_ldap/schema/syntaxes.rb:210 +msgid "%s has unprintable character in mailbox type: '%s'" +msgstr "%s???????????????????????????: '%s'" + +#: lib/active_ldap/schema/syntaxes.rb:215 +msgid "%s has no mailbox" +msgstr "%s????????????????" + +#: lib/active_ldap/schema/syntaxes.rb:227 +#: lib/active_ldap/schema/syntaxes.rb:245 +msgid "empty string" +msgstr "????????" + +#: lib/active_ldap/schema/syntaxes.rb:249 +msgid "%s has unprintable character: '%s'" +msgstr "%s????????????????: '%s'" + #: rails/plugin/active_ldap/init.rb:7 msgid "You need ActiveLdap %s or later" msgstr "ActiveLdap %s????????" @@ -3560,7 +3630,8 @@ #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:32 msgid "Use ATTRIBUTE as default DN attribute for instances of this model" -msgstr "???????????????????DN??????ATTRIBUTE??????" +msgstr "" +"???????????????????DN??????ATTRIBUTE??????" #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:34 #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:40 From codesite-noreply at google.com Mon Sep 3 08:48:58 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 03 Sep 2007 05:48:58 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r361 - trunk/lib/active_ldap/adapter Message-ID: <163600d51904393a989e41ed37330@google.com> Author: koutou Date: Mon Sep 3 05:48:02 2007 New Revision: 361 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/adapter/net_ldap.rb Log: * handled an exception caused by Net::LDAP::Connection.new. * retried again if an operation is failed. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Mon Sep 3 05:48:02 2007 @@ -15,6 +15,7 @@ :scope] def initialize(configuration={}) @connection = nil + @disconnected = false @configuration = configuration.dup @logger = @configuration.delete(:logger) @configuration.assert_valid_keys(VALID_ADAPTER_CONFIGURATION_KEYS) @@ -27,6 +28,7 @@ host = options[:host] || @host port = options[:port] || @port method = ensure_method(options[:method] || @method) + @disconnected = false @connection = yield(host, port, method) prepare_connection(options) bind(options) @@ -78,7 +80,7 @@ end def connecting? - not @connection.nil? + !@connection.nil? and !@disconnected end def schema(options={}) @@ -198,11 +200,22 @@ end def operation(options) - reconnect_if_need - try_reconnect = !options.has_key?(:try_reconnect) || - options[:try_reconnect] - with_timeout(try_reconnect, options) do - yield + retried = false + begin + reconnect_if_need + try_reconnect = !options.has_key?(:try_reconnect) || + options[:try_reconnect] + with_timeout(try_reconnect, options) do + yield + end + rescue Errno::EPIPE + if retried or !try_reconnect + raise + else + retried = true + @disconnected = true + retry + end end end Modified: trunk/lib/active_ldap/adapter/net_ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/net_ldap.rb (original) +++ trunk/lib/active_ldap/adapter/net_ldap.rb Mon Sep 3 05:48:02 2007 @@ -30,7 +30,11 @@ :port => port, } config[:encryption] = {:method => method} if method - Net::LDAP::Connection.new(config) + begin + Net::LDAP::Connection.new(config) + rescue Net::LDAP::LdapError + raise ConnectionError, $!.message + end end end From codesite-noreply at google.com Tue Sep 4 07:13:17 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 04 Sep 2007 04:13:17 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r362 - trunk/rails/plugin/active_ldap Message-ID: <163600cf9704394d60454d7c576407@google.com> Author: acesuares Date: Tue Sep 4 04:12:19 2007 New Revision: 362 Modified: trunk/rails/plugin/active_ldap/init.rb Log: Renamed scaffold_al to scaffold_active_ldap Modified: trunk/rails/plugin/active_ldap/init.rb ============================================================================== --- trunk/rails/plugin/active_ldap/init.rb (original) +++ trunk/rails/plugin/active_ldap/init.rb Tue Sep 4 04:12:19 2007 @@ -16,7 +16,7 @@ ActiveLdap::Base.establish_connection else ActiveLdap::Base.class_eval do - format = _("You should run 'script/generator scaffold_al' to make %s.") + format = _("You should run 'script/generator scaffold_active_ldap' to make %s.") logger.error(format % ldap_configuration_file) end end From codesite-noreply at google.com Sun Sep 16 10:01:26 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 16 Sep 2007 07:01:26 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r363 - trunk/lib/active_ldap Message-ID: <00163600d1b5043a411fb5f0e75c360a@google.com> Author: koutou Date: Sun Sep 16 07:00:48 2007 New Revision: 363 Modified: trunk/lib/active_ldap/connection.rb Log: * remove_connection clear @connection too. Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Sun Sep 16 07:00:48 2007 @@ -192,6 +192,7 @@ def remove_connection self.class.remove_connection(dn) + @connection = nil end def connection From codesite-noreply at google.com Sun Sep 16 23:36:08 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 16 Sep 2007 20:36:08 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r364 - trunk/lib/active_ldap Message-ID: <00163600d1b5043a4c815533946a9b00@google.com> Author: koutou Date: Sun Sep 16 20:35:58 2007 New Revision: 364 Modified: trunk/lib/active_ldap/base.rb Log: * improved inspect. * supported pretty print. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Sun Sep 16 20:35:58 2007 @@ -765,20 +765,41 @@ end def inspect + abbreviate_instance_variables do + super + end + end + + def pretty_print(q) + abbreviate_instance_variables do + q.pp_object(self) + end + end + + private + def abbreviate_instance_variables + @abbreviating ||= nil + connection, @connection = @connection, nil schema, @schema = @schema, nil + attribute_schemata, @attribute_schemata = @attribute_schemata, nil must, may = @must, @may object_classes = @object_classes - @must, @may = @must.collect(&:name), @may.collect(&:name) - @object_classes = @object_classes.collect(&:name) - super + unless @abbreviating + @abbreviating = true + @must, @may = @must.collect(&:name), @may.collect(&:name) + @object_classes = @object_classes.collect(&:name) + end + yield ensure + @connection = connection @schema = schema + @attribute_schemata = attribute_schemata @must = must @may = may @object_classes = object_classes + @abbreviating = false end - private def extract_object_class(attributes) classes = [] attrs = attributes.stringify_keys.reject do |key, value| From codesite-noreply at google.com Sun Sep 16 23:44:11 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 16 Sep 2007 20:44:11 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r365 - trunk/lib/active_ldap Message-ID: <00163600d1b5043a4c9e183ccc6acd4d@google.com> Author: koutou Date: Sun Sep 16 20:43:48 2007 New Revision: 365 Modified: trunk/lib/active_ldap/base.rb Log: * exported base/base=/scope/scope=. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Sun Sep 16 20:43:48 2007 @@ -764,6 +764,27 @@ @schema ||= super end + alias_method :base_of_class, :base + def base + [@base, base_of_class].compact.join(",") + end + + undef_method :base= + def base=(object_local_base) + @base = object_local_base + end + + alias_method :scope_of_class, :scope + def scope + @scope || scope_of_class + end + + undef_method :scope= + def scope=(scope) + self.class.validate_scope(scope) + @scope = scope + end + def inspect abbreviate_instance_variables do super @@ -932,27 +953,6 @@ # Update attr_method with appropriate define_attribute_methods(attr) end - end - - alias_method :base_of_class, :base - def base - [@base, base_of_class].compact.join(",") - end - - undef_method :base= - def base=(object_local_base) - @base = object_local_base - end - - alias_method :scope_of_class, :scope - def scope - @scope || scope_of_class - end - - undef_method :scope= - def scope=(scope) - self.class.validate_scope(scope) - @scope = scope end # get_attribute From codesite-noreply at google.com Sun Sep 16 23:59:11 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 16 Sep 2007 20:59:11 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r366 - trunk/lib/active_ldap Message-ID: <00163600d06e043a4cd3c39e0672e7d8@google.com> Author: koutou Date: Sun Sep 16 20:58:39 2007 New Revision: 366 Modified: trunk/lib/active_ldap/operations.rb Log: * find_one/find_some works for an object. Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Sun Sep 16 20:58:39 2007 @@ -246,7 +246,8 @@ if result result else - args = [name, dn] + args = [self.is_a?(Class) ? name : self.class.name, + dn] if options[:filter] format = _("Couldn't find %s: DN: %s: filter: %s") args << options[:filter].inspect @@ -275,7 +276,8 @@ if result.size == dns.size result else - args = [name, dns.join(', ')] + args = [self.is_a?(Class) ? name : self.class.name, + dns.join(", ")] if options[:filter] format = _("Couldn't find all %s: DNs (%s): filter: %s") args << options[:filter].inspect From codesite-noreply at google.com Mon Sep 17 05:15:43 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 17 Sep 2007 02:15:43 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r367 - in trunk: lib lib/active_ldap lib/active_ldap/acts lib/active_ldap/association test Message-ID: <00163600d06e043a513fbeb6597964c7@google.com> Author: koutou Date: Mon Sep 17 02:15:09 2007 New Revision: 367 Added: trunk/lib/active_ldap/acts/ trunk/lib/active_ldap/acts/tree.rb trunk/lib/active_ldap/association/children.rb trunk/test/test_acts_as_tree.rb Modified: trunk/lib/active_ldap.rb trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/operations.rb Log: * supported implicit acts_as_tree. Modified: trunk/lib/active_ldap.rb ============================================================================== --- trunk/lib/active_ldap.rb (original) +++ trunk/lib/active_ldap.rb Mon Sep 17 02:15:09 2007 @@ -938,13 +938,15 @@ require 'active_ldap/get_text' require 'active_ldap/base' + require 'active_ldap/associations' +require 'active_ldap/attributes' require 'active_ldap/configuration' require 'active_ldap/connection' require 'active_ldap/operations' require 'active_ldap/human_readable' -require 'active_ldap/attributes' -require 'active_ldap/object_class' + +require 'active_ldap/acts/tree' require 'active_ldap/distinguished_name' require 'active_ldap/populate' @@ -956,13 +958,16 @@ ActiveLdap::Base.class_eval do + include ActiveLdap::Associations + include ActiveLdap::Attributes include ActiveLdap::Configuration include ActiveLdap::Connection include ActiveLdap::Operations - include ActiveLdap::Attributes include ActiveLdap::ObjectClass - include ActiveLdap::Associations include ActiveLdap::HumanReadable + + include ActiveLdap::Acts::Tree + include ActiveLdap::Validations include ActiveLdap::Callbacks end Added: trunk/lib/active_ldap/acts/tree.rb ============================================================================== --- (empty file) +++ trunk/lib/active_ldap/acts/tree.rb Mon Sep 17 02:15:09 2007 @@ -0,0 +1,47 @@ +module ActiveLdap + module Acts + module Tree + def self.included(base) + base.class_eval do + extend(ClassMethods) + association_accessor(:children) do |target| + Association::Children.new(target, {}) + end + end + end + + module ClassMethods + def roots + find(:all, :scope => :one) + end + + def root + find(:first, :scope => :one) + end + end + + include ActiveRecord::Acts::Tree::InstanceMethods + + def parent + find(:first, :base => base, :scope => :base) + end + + def parent=(entry) + if entry.is_a?(String) + base = entry + elsif entry.respond_to?(:dn) + base = entry.dn + if entry.respond_to?(:clear_association_cache) + entry.clear_association_cache + end + else + message = _("parent must be an entry or parent DN: %s") % entry.inspect + raise ArgumentError, message + end + destroy unless new_entry? + self.dn = "#{dn_attribute}=#{id},#{base}" + save + end + end + end +end Added: trunk/lib/active_ldap/association/children.rb ============================================================================== --- (empty file) +++ trunk/lib/active_ldap/association/children.rb Mon Sep 17 02:15:09 2007 @@ -0,0 +1,21 @@ +require 'active_ldap/association/collection' + +module ActiveLdap + module Association + class Children < Collection + private + def insert_entry(entry) + entry.dn = [entry.id, @owner.dn].join(",") + entry.save + end + + def find_target + @owner.find(:all, :base => @owner.dn, :scope => :one) + end + + def delete_entries(entries) + entries.each(&:destroy) + end + end + end +end Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Sep 17 02:15:09 2007 @@ -175,7 +175,8 @@ end VALID_LDAP_MAPPING_OPTIONS = [:dn_attribute, :prefix, :scope, - :classes, :recommended_classes] + :classes, :recommended_classes, + :sort_by, :order] cattr_accessor :logger cattr_accessor :configurations @@ -208,8 +209,8 @@ end end - class_local_attr_accessor false, :prefix, :base, :dn_attribute - class_local_attr_accessor true, :scope + class_local_attr_accessor false, :prefix, :base + class_local_attr_accessor true, :dn_attribute, :scope, :sort_by, :order class_local_attr_accessor true, :required_classes, :recommended_classes class << self @@ -272,18 +273,16 @@ # :classes => ['top', 'posixAccount'], # :scope => :sub def ldap_mapping(options={}) + options = options.symbolize_keys validate_ldap_mapping_options(options) - dn_attribute = options[:dn_attribute] || default_dn_attribute - prefix = options[:prefix] || default_prefix - classes = options[:classes] - recommended_classes = options[:recommended_classes] - scope = options[:scope] - - self.dn_attribute = dn_attribute - self.prefix = prefix - self.scope = scope - self.required_classes = classes - self.recommended_classes = recommended_classes + + self.dn_attribute = options[:dn_attribute] || default_dn_attribute + self.prefix = options[:prefix] || default_prefix + self.scope = options[:scope] + self.required_classes = options[:classes] + self.recommended_classes = options[:recommended_classes] + self.sort_by = options[:sort_by] + self.order = options[:order] public_class_method :new end @@ -304,7 +303,7 @@ _base = configuration[:base] if _base.nil? and configuration _base ||= base_inheritable(true) [prefix, _base].find_all do |component| - component and !component.empty? + !component.blank? end.join(",") end Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Mon Sep 17 02:15:09 2007 @@ -22,7 +22,7 @@ module Common VALID_SEARCH_OPTIONS = [:attribute, :value, :filter, :prefix, :classes, :scope, :limit, :attributes, - :sort_by, :order, :connection] + :sort_by, :order, :connection, :base] def search(options={}, &block) validate_search_options(options) @@ -43,7 +43,8 @@ prefix ||= _prefix filter ||= [attr, value] filter = [:and, filter, *object_class_filters(classes)] - _base = [prefix, base].compact.reject{|x| x.empty?}.join(",") + _base = options[:base] + _base ||= [prefix, base].compact.reject{|x| x.empty?}.join(",") if options.has_key?(:ldap_scope) logger.warning do _(":ldap_scope search option is deprecated. Use :scope instead.") @@ -56,8 +57,8 @@ :filter => filter, :limit => options[:limit], :attributes => options[:attributes], - :sort_by => options[:sort_by], - :order => options[:order], + :sort_by => options[:sort_by] || sort_by, + :order => options[:order] || order, } conn = options[:connection] || connection @@ -199,8 +200,8 @@ def find_every(options) options = options.dup - sort_by = options.delete(:sort_by) - order = options.delete(:order) + sort_by = options.delete(:sort_by) || sort_by + order = options.delete(:order) || order limit = options.delete(:limit) if sort_by or order results = search(options).collect do |dn, attrs| Added: trunk/test/test_acts_as_tree.rb ============================================================================== --- (empty file) +++ trunk/test/test_acts_as_tree.rb Mon Sep 17 02:15:09 2007 @@ -0,0 +1,57 @@ +require 'al-test-utils' + +class TestActsAsTree < Test::Unit::TestCase + include AlTestUtils + + priority :must + + priority :normal + def test_children + users = ou_class.find("Users") + assert_equal([], users.children.collect(&:ou)) + + sub_users = users.class.new("SubUsers") + users.children << sub_users + assert_equal(["SubUsers"], users.children.collect(&:ou)) + + users = ou_class.find("Users") + assert_equal(["SubUsers"], users.children.collect(&:ou)) + + assert_equal("ou=SubUsers,#{users.dn}", sub_users.dn) + + assert(ou_class.exists?("SubUsers")) + users.children.replace([]) + assert(!ou_class.exists?("SubUsers")) + assert_equal([], users.children.collect(&:ou)) + end + + def test_parent + users = ou_class.find("Users") + assert_equal([], users.children.collect(&:ou)) + + sub_users = users.class.new("SubUsers") + sub_users.parent = users + assert_equal("ou=SubUsers,#{users.dn}", sub_users.dn) + assert_equal(["SubUsers"], users.children.collect(&:ou)) + + sub_users = ou_class.find("SubUsers") + assert_equal(users.dn, sub_users.parent.dn) + + assert_raises(ArgumentError) do + sub_users.parent = nil + end + + make_ou("OtherUsers") + other_users = ou_class.find("OtherUsers") + assert_equal([], other_users.children.collect(&:ou)) + + sub_users.parent = other_users.dn + assert_equal("ou=SubUsers,#{other_users.dn}", sub_users.dn) + + other_users.clear_association_cache + assert_equal(["SubUsers"], other_users.children.collect(&:ou)) + + users.clear_association_cache + assert_equal([], users.children.collect(&:ou)) + end +end From codesite-noreply at google.com Mon Sep 17 05:19:44 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 17 Sep 2007 02:19:44 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r368 - in trunk/po: en ja Message-ID: <00c09ffb51ed043a514e1e0e7471c994@google.com> Author: koutou Date: Mon Sep 17 02:18:23 2007 New Revision: 368 Modified: trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po Log: * updated messages. Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Mon Sep 17 02:18:23 2007 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-03 21:03+0900\n" +"POT-Creation-Date: 2007-09-17 18:15+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -2462,6 +2462,10 @@ msgstr "" #: -:- +msgid "LDAP|Description|ObjectClass|olcBdbConfig|BDB backend configuration" +msgstr "" + +#: -:- msgid "LDAP|Description|ObjectClass|olcConfig|OpenLDAP configuration object" msgstr "" @@ -2483,10 +2487,6 @@ msgstr "" #: -:- -msgid "LDAP|Description|ObjectClass|olcHdbConfig|HDB backend configuration" -msgstr "" - -#: -:- msgid "" "LDAP|Description|ObjectClass|olcIncludeFile|OpenLDAP configuration include " "file" @@ -2939,6 +2939,10 @@ msgstr "" #: -:- +msgid "LDAP|ObjectClass|olcBdbConfig" +msgstr "" + +#: -:- msgid "LDAP|ObjectClass|olcConfig" msgstr "" @@ -2955,10 +2959,6 @@ msgstr "" #: -:- -msgid "LDAP|ObjectClass|olcHdbConfig" -msgstr "" - -#: -:- msgid "LDAP|ObjectClass|olcIncludeFile" msgstr "" @@ -3242,6 +3242,18 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "" +#: lib/active_ldap/object_class.rb:51 +msgid "Value in objectClass array is not a String: %s" +msgstr "" + +#: lib/active_ldap/object_class.rb:65 +msgid "unknown objectClass in LDAP server: %s" +msgstr "" + +#: lib/active_ldap/object_class.rb:83 +msgid "Can't remove required objectClass: %s" +msgstr "" + #: lib/active_ldap/adapter/ldap.rb:84 msgid "No matches: filter: %s: attributes: %s" msgstr "" @@ -3250,173 +3262,169 @@ msgid "LDAP server is down: %s" msgstr "" -#: lib/active_ldap/adapter/ldap.rb:169 lib/active_ldap/adapter/net_ldap.rb:159 +#: lib/active_ldap/adapter/ldap.rb:169 lib/active_ldap/adapter/net_ldap.rb:163 msgid "%s is not one of the available connect methods: %s" msgstr "" -#: lib/active_ldap/adapter/ldap.rb:182 lib/active_ldap/adapter/net_ldap.rb:172 +#: lib/active_ldap/adapter/ldap.rb:182 lib/active_ldap/adapter/net_ldap.rb:176 msgid "%s is not one of the available LDAP scope: %s" msgstr "" -#: lib/active_ldap/adapter/ldap.rb:228 lib/active_ldap/adapter/net_ldap.rb:285 +#: lib/active_ldap/adapter/ldap.rb:228 lib/active_ldap/adapter/net_ldap.rb:289 msgid "unknown type: %s" msgstr "" -#: lib/active_ldap/adapter/net_ldap.rb:205 +#: lib/active_ldap/adapter/net_ldap.rb:209 msgid "unsupported qops: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:60 +#: lib/active_ldap/adapter/base.rb:62 msgid "Bound by SASL as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:64 msgid "Bound by simple as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:66 msgid "Bound as anonymous" msgstr "" -#: lib/active_ldap/adapter/base.rb:67 +#: lib/active_ldap/adapter/base.rb:69 msgid "All authentication methods exhausted." msgstr "" -#: lib/active_ldap/adapter/base.rb:142 +#: lib/active_ldap/adapter/base.rb:144 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:160 lib/active_ldap/adapter/base.rb:170 +#: lib/active_ldap/adapter/base.rb:162 lib/active_ldap/adapter/base.rb:172 msgid "No such entry: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:174 lib/active_ldap/adapter/base.rb:176 -#: lib/active_ldap/adapter/base.rb:178 lib/active_ldap/adapter/base.rb:180 -#: lib/active_ldap/adapter/base.rb:192 +#: lib/active_ldap/adapter/base.rb:176 lib/active_ldap/adapter/base.rb:178 +#: lib/active_ldap/adapter/base.rb:180 lib/active_ldap/adapter/base.rb:182 +#: lib/active_ldap/adapter/base.rb:194 msgid "%s: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:223 +#: lib/active_ldap/adapter/base.rb:236 msgid "password_block not nil or Proc object. Ignoring." msgstr "" -#: lib/active_ldap/adapter/base.rb:242 +#: lib/active_ldap/adapter/base.rb:255 msgid "Requested action timed out." msgstr "" -#: lib/active_ldap/adapter/base.rb:446 +#: lib/active_ldap/adapter/base.rb:459 msgid "invalid logical operator: %s: available operators: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:476 msgid "Giving up trying to reconnect to LDAP server." msgstr "" -#: lib/active_ldap/adapter/base.rb:466 +#: lib/active_ldap/adapter/base.rb:479 msgid "Attempting to reconnect" msgstr "" -#: lib/active_ldap/adapter/base.rb:477 +#: lib/active_ldap/adapter/base.rb:490 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" "%s" msgstr "" -#: lib/active_ldap/validations.rb:93 -msgid "%{fn} is required attribute by objectClass '%s'" -msgstr "" - -#: lib/active_ldap/validations.rb:95 -msgid "%{fn} is required attribute by objectClass '%s': aliases: %s" +#: lib/active_ldap/acts/tree.rb:38 +msgid "parent must be an entry or parent DN: %s" msgstr "" -#: lib/active_ldap/validations.rb:123 -msgid "%{fn} has invalid format: %s: required syntax: %s: %s" +#: lib/active_ldap/operations.rb:37 +msgid "Search value must be a String: %s" msgstr "" -#: lib/active_ldap/validations.rb:125 -msgid "has invalid format: %s: required syntax: %s: %s" +#: lib/active_ldap/operations.rb:50 +msgid ":ldap_scope search option is deprecated. Use :scope instead." msgstr "" -#: lib/active_ldap/command.rb:16 -msgid "Common options:" +#: lib/active_ldap/operations.rb:197 +msgid "Invalid order: %s" msgstr "" -#: lib/active_ldap/command.rb:19 -msgid "Specify configuration file written as YAML" +#: lib/active_ldap/operations.rb:232 +msgid "Couldn't find %s without a DN" msgstr "" -#: lib/active_ldap/command.rb:25 -msgid "Show this message" +#: lib/active_ldap/operations.rb:253 +msgid "Couldn't find %s: DN: %s: filter: %s" msgstr "" -#: lib/active_ldap/command.rb:30 -msgid "Show version" +#: lib/active_ldap/operations.rb:256 +msgid "Couldn't find %s: DN: %s" msgstr "" -#: lib/active_ldap/get_text/parser.rb:94 -msgid "Ignored '%{file}'. Solve dependencies first." +#: lib/active_ldap/operations.rb:283 +msgid "Couldn't find all %s: DNs (%s): filter: %s" msgstr "" -#: lib/active_ldap/attributes.rb:34 -msgid "The first argument, name, must not be nil. Please report this as a bug!" +#: lib/active_ldap/operations.rb:286 +msgid "Couldn't find all %s: DNs (%s)" msgstr "" -#: lib/active_ldap/attributes.rb:79 -msgid "Attribute %s can only have a single value" +#: lib/active_ldap/distinguished_name.rb:131 +msgid "name component is missing" msgstr "" -#: lib/active_ldap/attributes.rb:98 -msgid "Hashes must have one key-value pair only: %s" +#: lib/active_ldap/distinguished_name.rb:135 +msgid "relative distinguished name (RDN) is missing" msgstr "" -#: lib/active_ldap/attributes.rb:103 -msgid "unknown option did not match lang-* or binary: %s" +#: lib/active_ldap/distinguished_name.rb:139 +msgid "attribute type is missing" msgstr "" -#: lib/active_ldap/object_class.rb:51 -msgid "Value in objectClass array is not a String: %s" +#: lib/active_ldap/distinguished_name.rb:143 +msgid "attribute value is missing" msgstr "" -#: lib/active_ldap/object_class.rb:65 -msgid "unknown objectClass in LDAP server: %s" +#: lib/active_ldap/distinguished_name.rb:147 +msgid "found unmatched quotation" msgstr "" -#: lib/active_ldap/object_class.rb:83 -msgid "Can't remove required objectClass: %s" +#: lib/active_ldap/distinguished_name.rb:172 +msgid "%s isn't sub DN of %s" msgstr "" -#: lib/active_ldap/connection.rb:99 -msgid ":ldap_scope connection option is deprecated. Use :scope instead." +#: lib/active_ldap/validations.rb:93 +msgid "%{fn} is required attribute by objectClass '%s'" msgstr "" -#: lib/active_ldap/user_password.rb:11 -msgid "Invalid hashed password: %s" +#: lib/active_ldap/validations.rb:95 +msgid "%{fn} is required attribute by objectClass '%s': aliases: %s" msgstr "" -#: lib/active_ldap/user_password.rb:17 -msgid "Unknown Hash type: %s" +#: lib/active_ldap/validations.rb:123 +msgid "%{fn} has invalid format: %s: required syntax: %s: %s" msgstr "" -#: lib/active_ldap/user_password.rb:24 -msgid "Can't extract salt from hashed password: %s" +#: lib/active_ldap/validations.rb:125 +msgid "has invalid format: %s: required syntax: %s: %s" msgstr "" -#: lib/active_ldap/user_password.rb:52 lib/active_ldap/user_password.rb:69 -msgid "salt size must be == 4: %s" +#: lib/active_ldap/command.rb:16 +msgid "Common options:" msgstr "" -#: lib/active_ldap/schema.rb:50 -msgid "Unknown schema group: %s" +#: lib/active_ldap/command.rb:19 +msgid "Specify configuration file written as YAML" msgstr "" -#: lib/active_ldap/configuration.rb:59 -msgid "%s connection is not configured" +#: lib/active_ldap/command.rb:25 +msgid "Show this message" msgstr "" -#: lib/active_ldap/configuration.rb:100 -msgid ":ldap_scope configuration option is deprecated. Use :scope instead." +#: lib/active_ldap/command.rb:30 +msgid "Show version" msgstr "" #: lib/active_ldap/base.rb:114 @@ -3435,93 +3443,77 @@ msgid "%s is unknown attribute" msgstr "" -#: lib/active_ldap/base.rb:321 +#: lib/active_ldap/base.rb:320 msgid "scope '%s' must be a Symbol" msgstr "" -#: lib/active_ldap/base.rb:425 +#: lib/active_ldap/base.rb:424 msgid "" "'%s' must be either nil, DN value as String or Array or attributes as Hash" msgstr "" -#: lib/active_ldap/base.rb:507 +#: lib/active_ldap/base.rb:506 msgid "%s's DN attribute (%s) isn't set" msgstr "" -#: lib/active_ldap/base.rb:540 +#: lib/active_ldap/base.rb:539 msgid "Failed to delete LDAP entry: %s" msgstr "" -#: lib/active_ldap/base.rb:559 +#: lib/active_ldap/base.rb:558 msgid "entry %s can't be saved" msgstr "" -#: lib/active_ldap/base.rb:580 lib/active_ldap/base.rb:591 +#: lib/active_ldap/base.rb:579 lib/active_ldap/base.rb:590 msgid "wrong number of arguments (%d for 1)" msgstr "" -#: lib/active_ldap/base.rb:707 +#: lib/active_ldap/base.rb:706 msgid "Can't find DN '%s' to reload" msgstr "" -#: lib/active_ldap/base.rb:1137 +#: lib/active_ldap/base.rb:1157 msgid "dn_attribute isn't set for this class: %s" msgstr "" -#: lib/active_ldap/distinguished_name.rb:131 -msgid "name component is missing" -msgstr "" - -#: lib/active_ldap/distinguished_name.rb:135 -msgid "relative distinguished name (RDN) is missing" -msgstr "" - -#: lib/active_ldap/distinguished_name.rb:139 -msgid "attribute type is missing" -msgstr "" - -#: lib/active_ldap/distinguished_name.rb:143 -msgid "attribute value is missing" -msgstr "" - -#: lib/active_ldap/distinguished_name.rb:147 -msgid "found unmatched quotation" +#: lib/active_ldap/attributes.rb:34 +msgid "The first argument, name, must not be nil. Please report this as a bug!" msgstr "" -#: lib/active_ldap/distinguished_name.rb:172 -msgid "%s isn't sub DN of %s" +#: lib/active_ldap/attributes.rb:79 +msgid "Attribute %s can only have a single value" msgstr "" -#: lib/active_ldap/operations.rb:37 -msgid "Search value must be a String: %s" +#: lib/active_ldap/attributes.rb:98 +msgid "Hashes must have one key-value pair only: %s" msgstr "" -#: lib/active_ldap/operations.rb:49 -msgid ":ldap_scope search option is deprecated. Use :scope instead." +#: lib/active_ldap/attributes.rb:103 +msgid "unknown option did not match lang-* or binary: %s" msgstr "" -#: lib/active_ldap/operations.rb:196 -msgid "Invalid order: %s" +#: lib/active_ldap/schema.rb:50 +msgid "Unknown schema group: %s" msgstr "" -#: lib/active_ldap/operations.rb:231 -msgid "Couldn't find %s without a DN" +#: lib/active_ldap/connection.rb:99 +msgid ":ldap_scope connection option is deprecated. Use :scope instead." msgstr "" -#: lib/active_ldap/operations.rb:251 -msgid "Couldn't find %s: DN: %s: filter: %s" +#: lib/active_ldap/user_password.rb:11 +msgid "Invalid hashed password: %s" msgstr "" -#: lib/active_ldap/operations.rb:254 -msgid "Couldn't find %s: DN: %s" +#: lib/active_ldap/user_password.rb:17 +msgid "Unknown Hash type: %s" msgstr "" -#: lib/active_ldap/operations.rb:280 -msgid "Couldn't find all %s: DNs (%s): filter: %s" +#: lib/active_ldap/user_password.rb:24 +msgid "Can't extract salt from hashed password: %s" msgstr "" -#: lib/active_ldap/operations.rb:283 -msgid "Couldn't find all %s: DNs (%s)" +#: lib/active_ldap/user_password.rb:52 lib/active_ldap/user_password.rb:69 +msgid "salt size must be == 4: %s" msgstr "" #: lib/active_ldap/schema/syntaxes.rb:33 @@ -3594,16 +3586,24 @@ msgid "%s has unprintable character: '%s'" msgstr "" +#: lib/active_ldap/get_text/parser.rb:94 +msgid "Ignored '%{file}'. Solve dependencies first." +msgstr "" + +#: lib/active_ldap/configuration.rb:59 +msgid "%s connection is not configured" +msgstr "" + +#: lib/active_ldap/configuration.rb:100 +msgid ":ldap_scope configuration option is deprecated. Use :scope instead." +msgstr "" + #: rails/plugin/active_ldap/init.rb:7 msgid "You need ActiveLdap %s or later" msgstr "" #: rails/plugin/active_ldap/init.rb:19 -msgid "You should run 'script/generator scaffold_al' to make %s." -msgstr "" - -#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 -msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." +msgid "You should run 'script/generator scaffold_active_ldap' to make %s." msgstr "" #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:32 @@ -3618,6 +3618,10 @@ #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:39 msgid "Use PREFIX as prefix for this model" +msgstr "" + +#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 +msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." msgstr "" #: benchmark/bench-al.rb:14 Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Mon Sep 17 02:18:23 2007 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.8.4\n" -"POT-Creation-Date: 2007-09-03 21:03+0900\n" -"PO-Revision-Date: 2007-09-03 21:11+0900\n" +"POT-Creation-Date: 2007-09-17 18:15+0900\n" +"PO-Revision-Date: 2007-09-17 18:17+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -2473,6 +2473,10 @@ msgstr "OpenLDAP???????????????" #: -:- +msgid "LDAP|Description|ObjectClass|olcBdbConfig|BDB backend configuration" +msgstr "BDB?????????" + +#: -:- msgid "LDAP|Description|ObjectClass|olcConfig|OpenLDAP configuration object" msgstr "OpenLDAP?????????" @@ -2494,10 +2498,6 @@ msgstr "OpenLDAP??????????????" #: -:- -msgid "LDAP|Description|ObjectClass|olcHdbConfig|HDB backend configuration" -msgstr "HDB?????????" - -#: -:- msgid "" "LDAP|Description|ObjectClass|olcIncludeFile|OpenLDAP configuration include " "file" @@ -2950,6 +2950,10 @@ msgstr "OpenLDAP??: ????????(olcBackendConfig)" #: -:- +msgid "LDAP|ObjectClass|olcBdbConfig" +msgstr "OpenLDAP??: BDB??(olcBdbConfig)" + +#: -:- msgid "LDAP|ObjectClass|olcConfig" msgstr "OpenLDAP??: ??(olcConfig)" @@ -2966,10 +2970,6 @@ msgstr "OpenLDAP??: ?????(olcGlobal)" #: -:- -msgid "LDAP|ObjectClass|olcHdbConfig" -msgstr "OpenLDAP??: HDB??(olcHdbConfig)" - -#: -:- msgid "LDAP|ObjectClass|olcIncludeFile" msgstr "OpenLDAP??: ????????(olcIncludeFile)" @@ -3253,6 +3253,18 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "?????(1.3.6.1.4.1.1466.115.121.1.9)" +#: lib/active_ldap/object_class.rb:51 +msgid "Value in objectClass array is not a String: %s" +msgstr "objectClass???????String???????: %s" + +#: lib/active_ldap/object_class.rb:65 +msgid "unknown objectClass in LDAP server: %s" +msgstr "LDAP????????objectClass??: %s" + +#: lib/active_ldap/object_class.rb:83 +msgid "Can't remove required objectClass: %s" +msgstr "???objectClass????????: %s" + #: lib/active_ldap/adapter/ldap.rb:84 msgid "No matches: filter: %s: attributes: %s" msgstr "??????????: ????: %s: ??: %s" @@ -3261,82 +3273,143 @@ msgid "LDAP server is down: %s" msgstr "LDAP????????????: %s" -#: lib/active_ldap/adapter/ldap.rb:169 lib/active_ldap/adapter/net_ldap.rb:159 +#: lib/active_ldap/adapter/ldap.rb:169 lib/active_ldap/adapter/net_ldap.rb:163 msgid "%s is not one of the available connect methods: %s" msgstr "%s???????????????: %s" -#: lib/active_ldap/adapter/ldap.rb:182 lib/active_ldap/adapter/net_ldap.rb:172 +#: lib/active_ldap/adapter/ldap.rb:182 lib/active_ldap/adapter/net_ldap.rb:176 msgid "%s is not one of the available LDAP scope: %s" msgstr "%s????LDAP???????????: %s" -#: lib/active_ldap/adapter/ldap.rb:228 lib/active_ldap/adapter/net_ldap.rb:285 +#: lib/active_ldap/adapter/ldap.rb:228 lib/active_ldap/adapter/net_ldap.rb:289 msgid "unknown type: %s" msgstr "???????: %s" -#: lib/active_ldap/adapter/net_ldap.rb:205 +#: lib/active_ldap/adapter/net_ldap.rb:209 msgid "unsupported qops: %s" msgstr "???????qops??: %s" -#: lib/active_ldap/adapter/base.rb:60 +#: lib/active_ldap/adapter/base.rb:62 msgid "Bound by SASL as %s" msgstr "%s???SASL????????" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:64 msgid "Bound by simple as %s" msgstr "%s?????????????????" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:66 msgid "Bound as anonymous" msgstr "???????????????" -#: lib/active_ldap/adapter/base.rb:67 +#: lib/active_ldap/adapter/base.rb:69 msgid "All authentication methods exhausted." msgstr "?????????????????" -#: lib/active_ldap/adapter/base.rb:142 +#: lib/active_ldap/adapter/base.rb:144 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "???%s(%s)??????: ???? %s: ??: %s" -#: lib/active_ldap/adapter/base.rb:160 lib/active_ldap/adapter/base.rb:170 +#: lib/active_ldap/adapter/base.rb:162 lib/active_ldap/adapter/base.rb:172 msgid "No such entry: %s" msgstr "???????????????: %s" -#: lib/active_ldap/adapter/base.rb:174 lib/active_ldap/adapter/base.rb:176 -#: lib/active_ldap/adapter/base.rb:178 lib/active_ldap/adapter/base.rb:180 -#: lib/active_ldap/adapter/base.rb:192 +#: lib/active_ldap/adapter/base.rb:176 lib/active_ldap/adapter/base.rb:178 +#: lib/active_ldap/adapter/base.rb:180 lib/active_ldap/adapter/base.rb:182 +#: lib/active_ldap/adapter/base.rb:194 msgid "%s: %s" msgstr "%s: %s" -#: lib/active_ldap/adapter/base.rb:223 +#: lib/active_ldap/adapter/base.rb:236 msgid "password_block not nil or Proc object. Ignoring." msgstr "password_block?nil??Proc??????????????" -#: lib/active_ldap/adapter/base.rb:242 +#: lib/active_ldap/adapter/base.rb:255 msgid "Requested action timed out." msgstr "?????????????????????" -#: lib/active_ldap/adapter/base.rb:446 +#: lib/active_ldap/adapter/base.rb:459 msgid "invalid logical operator: %s: available operators: %s" msgstr "??????????: %s: ??????: %s\n" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:476 msgid "Giving up trying to reconnect to LDAP server." msgstr "LDAP???????????????" -#: lib/active_ldap/adapter/base.rb:466 +#: lib/active_ldap/adapter/base.rb:479 msgid "Attempting to reconnect" msgstr "???????????" -#: lib/active_ldap/adapter/base.rb:477 +#: lib/active_ldap/adapter/base.rb:490 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" "%s" msgstr "" -"???????????????: %s\\n\n" -"???????????????????:\\n\n" +"???????????????: %s\n" +"???????????????????:\n" "%s" +#: lib/active_ldap/acts/tree.rb:38 +msgid "parent must be an entry or parent DN: %s" +msgstr "???????DN??????????: %s" + +#: lib/active_ldap/operations.rb:37 +msgid "Search value must be a String: %s" +msgstr "??????String??????????: %s" + +#: lib/active_ldap/operations.rb:50 +msgid ":ldap_scope search option is deprecated. Use :scope instead." +msgstr "" +":ldap_search???????????????????:scope?????????" + +#: lib/active_ldap/operations.rb:197 +msgid "Invalid order: %s" +msgstr "???????: %s" + +#: lib/active_ldap/operations.rb:232 +msgid "Couldn't find %s without a DN" +msgstr "DN?????%s?????????" + +#: lib/active_ldap/operations.rb:253 +msgid "Couldn't find %s: DN: %s: filter: %s" +msgstr "%s????????: DN: %s: ????: %s" + +#: lib/active_ldap/operations.rb:256 +msgid "Couldn't find %s: DN: %s" +msgstr "%s????????: DN: %s" + +#: lib/active_ldap/operations.rb:283 +msgid "Couldn't find all %s: DNs (%s): filter: %s" +msgstr "????%s????????????: DN (%s): ????: %s" + +#: lib/active_ldap/operations.rb:286 +msgid "Couldn't find all %s: DNs (%s)" +msgstr "????%s????????????: DN (%s)" + +#: lib/active_ldap/distinguished_name.rb:131 +msgid "name component is missing" +msgstr "???????????" + +#: lib/active_ldap/distinguished_name.rb:135 +msgid "relative distinguished name (RDN) is missing" +msgstr "?????(RDN)???????" + +#: lib/active_ldap/distinguished_name.rb:139 +msgid "attribute type is missing" +msgstr "????????????" + +#: lib/active_ldap/distinguished_name.rb:143 +msgid "attribute value is missing" +msgstr "???????????" + +#: lib/active_ldap/distinguished_name.rb:147 +msgid "found unmatched quotation" +msgstr "????????????????" + +#: lib/active_ldap/distinguished_name.rb:172 +msgid "%s isn't sub DN of %s" +msgstr "%s?%s???DN????????" + #: lib/active_ldap/validations.rb:93 msgid "%{fn} is required attribute by objectClass '%s'" msgstr "%{fn}?objectClass'%s'?????????" @@ -3369,74 +3442,6 @@ msgid "Show version" msgstr "????????????" -#: lib/active_ldap/get_text/parser.rb:94 -msgid "Ignored '%{file}'. Solve dependencies first." -msgstr "'%{file}'???????????????????????" - -#: lib/active_ldap/attributes.rb:34 -msgid "The first argument, name, must not be nil. Please report this as a bug!" -msgstr "" -"?????name?nil????????????????????????????" -"??" - -#: lib/active_ldap/attributes.rb:79 -msgid "Attribute %s can only have a single value" -msgstr "??%s?????????????" - -#: lib/active_ldap/attributes.rb:98 -msgid "Hashes must have one key-value pair only: %s" -msgstr "????????????????????????????: %s" - -#: lib/active_ldap/attributes.rb:103 -msgid "unknown option did not match lang-* or binary: %s" -msgstr "lang-*??binary??????????????????: %s" - -#: lib/active_ldap/object_class.rb:51 -msgid "Value in objectClass array is not a String: %s" -msgstr "objectClass???????String???????: %s" - -#: lib/active_ldap/object_class.rb:65 -msgid "unknown objectClass in LDAP server: %s" -msgstr "LDAP????????objectClass??: %s" - -#: lib/active_ldap/object_class.rb:83 -msgid "Can't remove required objectClass: %s" -msgstr "???objectClass????????: %s" - -#: lib/active_ldap/connection.rb:99 -msgid ":ldap_scope connection option is deprecated. Use :scope instead." -msgstr "" -":ldap_scope???????????????????:scope?????????" - -#: lib/active_ldap/user_password.rb:11 -msgid "Invalid hashed password: %s" -msgstr "???????????????????: %s" - -#: lib/active_ldap/user_password.rb:17 -msgid "Unknown Hash type: %s" -msgstr "????????????: %s" - -#: lib/active_ldap/user_password.rb:24 -msgid "Can't extract salt from hashed password: %s" -msgstr "???????????????salt?????????????: %s" - -#: lib/active_ldap/user_password.rb:52 lib/active_ldap/user_password.rb:69 -msgid "salt size must be == 4: %s" -msgstr "salt?4????????????: %s" - -#: lib/active_ldap/schema.rb:50 -msgid "Unknown schema group: %s" -msgstr "?????????????: %s" - -#: lib/active_ldap/configuration.rb:59 -msgid "%s connection is not configured" -msgstr "%s??????????????" - -#: lib/active_ldap/configuration.rb:100 -msgid ":ldap_scope configuration option is deprecated. Use :scope instead." -msgstr "" -":ldap_scope???????????????????:scope?????????" - #: lib/active_ldap/base.rb:114 msgid "%s is invalid distinguished name (DN): %s" msgstr "%s???????(DN)??: %s" @@ -3453,97 +3458,83 @@ msgid "%s is unknown attribute" msgstr "%s?????????" -#: lib/active_ldap/base.rb:321 +#: lib/active_ldap/base.rb:320 msgid "scope '%s' must be a Symbol" msgstr "????'%s'????????????????" -#: lib/active_ldap/base.rb:425 +#: lib/active_ldap/base.rb:424 msgid "" "'%s' must be either nil, DN value as String or Array or attributes as Hash" msgstr "" "'%s'?nil?String???DN?DN????Hash??????????????????" "??" -#: lib/active_ldap/base.rb:507 +#: lib/active_ldap/base.rb:506 msgid "%s's DN attribute (%s) isn't set" msgstr "%s?DN??(%s)???????????" -#: lib/active_ldap/base.rb:540 +#: lib/active_ldap/base.rb:539 msgid "Failed to delete LDAP entry: %s" msgstr "LDAP??????????????: %s" -#: lib/active_ldap/base.rb:559 +#: lib/active_ldap/base.rb:558 msgid "entry %s can't be saved" msgstr "????%s?????????" -#: lib/active_ldap/base.rb:580 lib/active_ldap/base.rb:591 +#: lib/active_ldap/base.rb:579 lib/active_ldap/base.rb:590 msgid "wrong number of arguments (%d for 1)" msgstr "??????????(1???????%d???????)" -#: lib/active_ldap/base.rb:707 +#: lib/active_ldap/base.rb:706 msgid "Can't find DN '%s' to reload" msgstr "???????DN '%s'?????????" -#: lib/active_ldap/base.rb:1137 +#: lib/active_ldap/base.rb:1157 msgid "dn_attribute isn't set for this class: %s" msgstr "??????dn_attribute??????????: %s" -#: lib/active_ldap/distinguished_name.rb:131 -msgid "name component is missing" -msgstr "???????????" - -#: lib/active_ldap/distinguished_name.rb:135 -msgid "relative distinguished name (RDN) is missing" -msgstr "?????(RDN)???????" - -#: lib/active_ldap/distinguished_name.rb:139 -msgid "attribute type is missing" -msgstr "????????????" +#: lib/active_ldap/attributes.rb:34 +msgid "The first argument, name, must not be nil. Please report this as a bug!" +msgstr "" +"?????name?nil????????????????????????????" +"??" -#: lib/active_ldap/distinguished_name.rb:143 -msgid "attribute value is missing" -msgstr "???????????" +#: lib/active_ldap/attributes.rb:79 +msgid "Attribute %s can only have a single value" +msgstr "??%s?????????????" -#: lib/active_ldap/distinguished_name.rb:147 -msgid "found unmatched quotation" -msgstr "????????????????" +#: lib/active_ldap/attributes.rb:98 +msgid "Hashes must have one key-value pair only: %s" +msgstr "????????????????????????????: %s" -#: lib/active_ldap/distinguished_name.rb:172 -msgid "%s isn't sub DN of %s" -msgstr "%s?%s???DN????????" +#: lib/active_ldap/attributes.rb:103 +msgid "unknown option did not match lang-* or binary: %s" +msgstr "lang-*??binary??????????????????: %s" -#: lib/active_ldap/operations.rb:37 -msgid "Search value must be a String: %s" -msgstr "??????String??????????: %s" +#: lib/active_ldap/schema.rb:50 +msgid "Unknown schema group: %s" +msgstr "?????????????: %s" -#: lib/active_ldap/operations.rb:49 -msgid ":ldap_scope search option is deprecated. Use :scope instead." +#: lib/active_ldap/connection.rb:99 +msgid ":ldap_scope connection option is deprecated. Use :scope instead." msgstr "" -":ldap_search???????????????????:scope?????????" - -#: lib/active_ldap/operations.rb:196 -msgid "Invalid order: %s" -msgstr "???????: %s" - -#: lib/active_ldap/operations.rb:231 -msgid "Couldn't find %s without a DN" -msgstr "DN?????%s?????????" +":ldap_scope???????????????????:scope?????????" -#: lib/active_ldap/operations.rb:251 -msgid "Couldn't find %s: DN: %s: filter: %s" -msgstr "%s????????: DN: %s: ????: %s" +#: lib/active_ldap/user_password.rb:11 +msgid "Invalid hashed password: %s" +msgstr "???????????????????: %s" -#: lib/active_ldap/operations.rb:254 -msgid "Couldn't find %s: DN: %s" -msgstr "%s????????: DN: %s" +#: lib/active_ldap/user_password.rb:17 +msgid "Unknown Hash type: %s" +msgstr "????????????: %s" -#: lib/active_ldap/operations.rb:280 -msgid "Couldn't find all %s: DNs (%s): filter: %s" -msgstr "????%s????????????: DN (%s): ????: %s" +#: lib/active_ldap/user_password.rb:24 +msgid "Can't extract salt from hashed password: %s" +msgstr "???????????????salt?????????????: %s" -#: lib/active_ldap/operations.rb:283 -msgid "Couldn't find all %s: DNs (%s)" -msgstr "????%s????????????: DN (%s)" +#: lib/active_ldap/user_password.rb:52 lib/active_ldap/user_password.rb:69 +msgid "salt size must be == 4: %s" +msgstr "salt?4????????????: %s" #: lib/active_ldap/schema/syntaxes.rb:33 msgid "%s doesn't have the first \"'\"" @@ -3615,18 +3606,26 @@ msgid "%s has unprintable character: '%s'" msgstr "%s????????????????: '%s'" +#: lib/active_ldap/get_text/parser.rb:94 +msgid "Ignored '%{file}'. Solve dependencies first." +msgstr "'%{file}'???????????????????????" + +#: lib/active_ldap/configuration.rb:59 +msgid "%s connection is not configured" +msgstr "%s??????????????" + +#: lib/active_ldap/configuration.rb:100 +msgid ":ldap_scope configuration option is deprecated. Use :scope instead." +msgstr "" +":ldap_scope???????????????????:scope?????????" + #: rails/plugin/active_ldap/init.rb:7 msgid "You need ActiveLdap %s or later" msgstr "ActiveLdap %s????????" #: rails/plugin/active_ldap/init.rb:19 -msgid "You should run 'script/generator scaffold_al' to make %s." -msgstr "%s??????'script/generator scaffold_al'??????????" - -#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 -msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." -msgstr "" -"scaffold_al????????????scaffold_active_ldap?????????" +msgid "You should run 'script/generator scaffold_active_ldap' to make %s." +msgstr "%s??????'script/generator scaffold_active_ldap'??????????" #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:32 msgid "Use ATTRIBUTE as default DN attribute for instances of this model" @@ -3642,6 +3641,11 @@ #: rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb:39 msgid "Use PREFIX as prefix for this model" msgstr "????????????????PREFIX??????" + +#: rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb:7 +msgid "scaffold_al is deprecated. Use scaffold_active_ldap instead." +msgstr "" +"scaffold_al????????????scaffold_active_ldap?????????" #: benchmark/bench-al.rb:14 msgid "Specify prefix for benchmarking" From codesite-noreply at google.com Tue Sep 18 08:25:29 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 18 Sep 2007 05:25:29 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r369 - trunk/lib Message-ID: <00163600d519043a68043e7e1393d17f@google.com> Author: koutou Date: Tue Sep 18 05:24:28 2007 New Revision: 369 Modified: trunk/lib/active_ldap.rb Log: * require 'active_record' not 'active_record/base'. Modified: trunk/lib/active_ldap.rb ============================================================================== --- trunk/lib/active_ldap.rb (original) +++ trunk/lib/active_ldap.rb Tue Sep 18 05:24:28 2007 @@ -930,7 +930,7 @@ require 'active_ldap/timeout_stub' end -require_gem_if_need.call("active_record/base", "activerecord") +require_gem_if_need.call("active_record", "activerecord") begin require_gem_if_need.call("gettext/active_record", "gettext") rescue LoadError From codesite-noreply at google.com Fri Sep 21 06:36:37 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 03:36:37 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r370 - wiki Message-ID: <00163600cf97043aa2d875d02a23500c@google.com> Author: koutou Date: Fri Sep 21 03:36:07 2007 New Revision: 370 Added: wiki/UsingTrunkWithRails.wiki Log: Created wiki page through web user interface. Added: wiki/UsingTrunkWithRails.wiki ============================================================================== --- (empty file) +++ wiki/UsingTrunkWithRails.wiki Fri Sep 21 03:36:07 2007 @@ -0,0 +1,16 @@ +# How to use trunk with Rails + += Introduction = + +If you want to try ActiveLdap on the edge with your Rails application, the following instructionis will help you. + += Details = + +{{{ +% rails sample +% cd sample +% script/plugin install http://ruby-activeldap.googlecode.com/svn/trunk +% mv vendor/plugins/{trunk,active_ldap} +% cd vendor/plugins/active_ldap +% ln -s rails/plugin/active_ldap/init.rb ./ +}}} \ No newline at end of file From codesite-noreply at google.com Fri Sep 21 23:00:44 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:00:44 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r371 - in trunk: lib/active_ldap lib/active_ldap/schema test Message-ID: <00c09ffb50dd043ab097f3416e3353ab@google.com> Author: koutou Date: Fri Sep 21 20:00:23 2007 New Revision: 371 Modified: trunk/lib/active_ldap/schema.rb trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * started type casting support. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Fri Sep 21 20:00:23 2007 @@ -300,6 +300,14 @@ end end + def type_cast(value) + if @validator + @validator.type_cast(value) + else + value + end + end + private def attribute(attribute_name, name=@name) @schema.ldap_syntax_attribute(name, attribute_name) Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:00:23 2007 @@ -23,22 +23,48 @@ def valid?(value) validate(value).nil? end + + def validate(value) + validate_normalized_value(normalize_value(value), value) + end + + def normalize_value(value) + value + end end class BitString < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.6"] = self - def validate(value) + def type_cast(value) + return nil if value.nil? + if /\A'([01]*)'B\z/ =~ value.to_s + $1 + else + value + end + end + + def normalize_value(value) + if value.is_a?(String) and /\A[01]*\z/ =~ value + "'#{value}'B" + else + value + end + end + + private + def validate_normalized_value(value, original_value) if /\A'/ !~ value - return _("%s doesn't have the first \"'\"" % value.inspect) + return _("%s doesn't have the first \"'\"") % original_value.inspect end if /'B\z/ !~ value - return _("%s doesn't have the last \"'B\"" % value.inspect) + return _("%s doesn't have the last \"'B\"") % original_value.inspect end if /([^01])/ =~ value[1..-3] - return _("%s has invalid character '%s'" % [value.inspect, $1]) + return _("%s has invalid character '%s'") % [value.inspect, $1] end nil @@ -48,11 +74,12 @@ class Boolean < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.7"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if %w(TRUE FALSE).include?(value) nil else - _("%s should be TRUE or FALSE") % value.inspect + _("%s should be TRUE or FALSE") % original_value.inspect end end end @@ -60,11 +87,13 @@ class CountryString < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.11"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if /\A#{PRINTABLE_CHARACTER}{2,2}\z/i =~ value nil else - _("%s should be just 2 printable characters") % value.inspect + format = _("%s should be just 2 printable characters") + format % original_value.inspect end end end @@ -72,7 +101,8 @@ class DistinguishedName < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.12"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) DN.parse(value) nil rescue DistinguishedNameInvalid @@ -83,18 +113,20 @@ class DirectoryString < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.15"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) value.unpack("U*") nil rescue ArgumentError - _("%s has invalid UTF-8 character") % value.inspect + _("%s has invalid UTF-8 character") % original_value.inspect end end class GeneralizedTime < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.24"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) match_data = /\A (\d{4,4})? (\d{2,2})? @@ -126,18 +158,20 @@ class Integer < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.27"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) Integer(value) nil rescue ArgumentError - _("%s is invalid integer format") % value.inspect + _("%s is invalid integer format") % original_value.inspect end end class JPEG < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.28"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if value.unpack("n")[0] == 0xffd8 nil else @@ -149,7 +183,8 @@ class NameAndOptionalUID < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.34"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) separator_index = value.rindex("#") if separator_index dn = value[0, separator_index] @@ -176,11 +211,12 @@ class NumericString < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.36"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if /\A\d+\z/ =~ value nil else - _("%s is invalid numeric format") % value.inspect + _("%s is invalid numeric format") % original_value.inspect end end end @@ -188,31 +224,33 @@ class OID < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.38"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) DN.parse("#{value}=dummy") nil rescue DistinguishedNameInvalid - _("%s is invalid OID format") % value.inspect + _("%s is invalid OID format") % original_value.inspect end end class OtherMailbox < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.39"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) type, mailbox = value.split('$', 2) if type.empty? - return _("%s has no mailbox type") % value.inspect + return _("%s has no mailbox type") % original_value.inspect end if /(#{UNPRINTABLE_CHARACTER})/i =~ type format = _("%s has unprintable character in mailbox type: '%s'") - return format % [value.inspect, $1] + return format % [original_value.inspect, $1] end if mailbox.blank? - return _("%s has no mailbox") % value.inspect + return _("%s has no mailbox") % original_value.inspect end nil @@ -222,7 +260,8 @@ class PostalAddress < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.41"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if value.blank? return _("empty string") end @@ -230,7 +269,7 @@ begin value.unpack("U*") rescue ArgumentError - return _("%s has invalid UTF-8 character") % value.inspect + return _("%s has invalid UTF-8 character") % original_value.inspect end nil @@ -240,14 +279,15 @@ class PrintableString < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.44"] = self - def validate(value) + private + def validate_normalized_value(value, original_value) if value.blank? return _("empty string") end if /(#{UNPRINTABLE_CHARACTER})/i =~ value format = _("%s has unprintable character: '%s'") - return format % [value.inspect, $1] + return format % [original_value.inspect, $1] end nil @@ -257,8 +297,9 @@ class TelephoneNumber < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.50"] = self - def validate(value) - PrintableString.new.validate(value) + private + def validate_normalized_value(value, original_value) + PrintableString.new.validate(original_value) end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Fri Sep 21 20:00:23 2007 @@ -55,11 +55,16 @@ end priority :must - def test_bit_string + def test_bit_string_type_cast + assert_type_cast("0101111101", "'0101111101'B", 'Bit String') + end + + priority :normal + def test_bit_string_validate assert_valid("'0101111101'B", 'Bit String') assert_valid("''B", 'Bit String') - value = "0101111101" + value = "0101111101'B" assert_invalid(_("%s doesn't have the first \"'\"") % value.inspect, value, 'Bit String') @@ -76,7 +81,7 @@ value, 'Bit String') end - def test_boolean + def test_boolean_validate assert_valid("TRUE", "Boolean") assert_valid("FALSE", "Boolean") @@ -85,7 +90,7 @@ value, "Boolean") end - def test_country_string + def test_country_string_validate assert_valid("ja", "Country String") assert_valid("JA", "Country String") @@ -94,7 +99,7 @@ value, "Country String") end - def test_dn + def test_dn_validate assert_valid("cn=test", 'Distinguished Name') assert_valid("CN=Steve Kille,O=Isode Limited,C=GB", 'Distinguished Name') assert_valid("OU=Sales+CN=J. Smith,O=Widget Inc.,C=US", 'Distinguished Name') @@ -111,7 +116,7 @@ value, 'Distinguished Name') end - def test_directory_string + def test_directory_string_validate assert_valid("This is a string of DirectoryString containing \#!%\#@", "Directory String") assert_valid("???DirectoryString??????", @@ -122,32 +127,32 @@ value, "Directory String") end - def test_generalized_time + def test_generalized_time_validate assert_valid("199412161032", "Generalized Time") assert_valid("199412161032Z", "Generalized Time") assert_valid("199412161032+0900", "Generalized Time") value = "1994" params = [value.inspect, %w(month day hour minute).join(", ")] - assert_invalid("%s has missing components: %s" % params, + assert_invalid(_("%s has missing components: %s") % params, value, "Generalized Time") end - def test_integer + def test_integer_validate assert_valid("1321", "Integer") assert_invalid_integer("13.5") assert_invalid_integer("string") end - def test_jpeg + def test_jpeg_validate assert_valid([0xffd8].pack("n"), "JPEG") assert_invalid(_("invalid JPEG format"), "", "JPEG") assert_invalid(_("invalid JPEG format"), "jpeg", "JPEG") end - def test_name_and_optional_uid + def test_name_and_optional_uid_validate assert_valid("1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B", "Name And Optional UID") assert_valid("cn=test", "Name And Optional UID") @@ -163,7 +168,7 @@ "cn=test\##{bit_string}", "Name And Optional UID") end - def test_numeric_string + def test_numeric_string_validate assert_valid("1997", "Numeric String") assert_invalid_numeric_string("-3") @@ -171,14 +176,14 @@ assert_invalid_numeric_string("string") end - def test_oid + def test_oid_validate assert_valid("1.2.3.4", "OID") assert_valid("cn", "OID") assert_invalid_oid("\#@!") end - def test_other_mailbox + def test_other_mailbox_validate assert_valid("smtp$bob at example.com", "Other Mailbox") @@ -200,7 +205,7 @@ assert_invalid(reason, value, "Other Mailbox") end - def test_postal_address + def test_postal_address_validate assert_valid("1234 Main St.$Anytown, CA 12345$USA", "Postal Address") assert_valid("\\241,000,000 Sweepstakes$PO Box 1000000$Anytown, " + "CA 12345$USA", "Postal Address") @@ -215,7 +220,7 @@ value, "Postal Address") end - def test_printable_string + def test_printable_string_validate assert_valid("This is a PrintableString", "Printable String") assert_invalid(_("empty string"), "", "Printable String") @@ -232,7 +237,7 @@ assert_invalid(reason, value, "Printable String") end - def test_telephone_number + def test_telephone_number_validate assert_valid("+1 512 305 0280", "Telephone Number") assert_invalid(_("empty string"), "", "Telephone Number") @@ -243,8 +248,6 @@ assert_invalid(reason, value, "Telephone Number") end - priority :normal - private def assert_valid(value, syntax_name) assert_nil(@syntaxes[syntax_name].validate(value)) @@ -267,5 +270,11 @@ def assert_invalid_oid(value) assert_invalid(_("%s is invalid OID format") % value.inspect, value, "OID") + end + + def assert_type_cast(type_casted_value, original_value, syntax_name) + syntax = @syntaxes[syntax_name] + assert_equal(type_casted_value, syntax.type_cast(original_value)) + assert_valid(type_casted_value, syntax_name) end end From codesite-noreply at google.com Fri Sep 21 23:04:45 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:04:45 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r372 - trunk/lib/active_ldap/schema Message-ID: <00163600cf97043ab0a6458e7433896f@google.com> Author: koutou Date: Fri Sep 21 20:02:26 2007 New Revision: 372 Modified: trunk/lib/active_ldap/schema/syntaxes.rb Log: * simplified. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:02:26 2007 @@ -28,6 +28,7 @@ validate_normalized_value(normalize_value(value), value) end + private def normalize_value(value) value end @@ -297,9 +298,8 @@ class TelephoneNumber < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.50"] = self - private - def validate_normalized_value(value, original_value) - PrintableString.new.validate(original_value) + def validate(value) + PrintableString.new.validate(value) end end end From codesite-noreply at google.com Fri Sep 21 23:08:48 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:08:48 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r373 - in trunk: lib/active_ldap/schema test Message-ID: <00c09ffb51ed043ab0b4c63b2a33a02b@google.com> Author: koutou Date: Fri Sep 21 20:08:30 2007 New Revision: 373 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported boolean type cast. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:08:30 2007 @@ -46,6 +46,7 @@ end end + private def normalize_value(value) if value.is_a?(String) and /\A[01]*\z/ =~ value "'#{value}'B" @@ -54,7 +55,6 @@ end end - private def validate_normalized_value(value, original_value) if /\A'/ !~ value return _("%s doesn't have the first \"'\"") % original_value.inspect @@ -75,7 +75,29 @@ class Boolean < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.7"] = self + def type_cast(value) + case value + when "TRUE" + true + when "FALSE" + false + else + value + end + end + private + def normalize_value(value) + case value + when true + "TRUE" + when false + "FALSE" + else + value + end + end + def validate_normalized_value(value, original_value) if %w(TRUE FALSE).include?(value) nil Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Fri Sep 21 20:08:30 2007 @@ -59,6 +59,11 @@ assert_type_cast("0101111101", "'0101111101'B", 'Bit String') end + def test_boolean_type_cast + assert_type_cast(true, "TRUE", "Boolean") + assert_type_cast(false, "FALSE", "Boolean") + end + priority :normal def test_bit_string_validate assert_valid("'0101111101'B", 'Bit String') @@ -275,6 +280,8 @@ def assert_type_cast(type_casted_value, original_value, syntax_name) syntax = @syntaxes[syntax_name] assert_equal(type_casted_value, syntax.type_cast(original_value)) + assert_equal(type_casted_value, syntax.type_cast(type_casted_value)) + assert_valid(type_casted_value, syntax_name) end end From codesite-noreply at google.com Fri Sep 21 23:17:50 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:17:50 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r374 - in trunk: lib/active_ldap lib/active_ldap/schema test Message-ID: <00c09ffb50dd043ab0d512691d33b57c@google.com> Author: koutou Date: Fri Sep 21 20:17:19 2007 New Revision: 374 Modified: trunk/lib/active_ldap/distinguished_name.rb trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported DN type cast. Modified: trunk/lib/active_ldap/distinguished_name.rb ============================================================================== --- trunk/lib/active_ldap/distinguished_name.rb (original) +++ trunk/lib/active_ldap/distinguished_name.rb Fri Sep 21 20:17:19 2007 @@ -10,6 +10,7 @@ attr_reader :dn def initialize(source) @dn = nil + source = source.to_s if source.is_a?(DN) @source = source end Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:17:19 2007 @@ -124,6 +124,13 @@ class DistinguishedName < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.12"] = self + def type_cast(value) + return nil if value.nil? + DN.parse(value) + rescue DistinguishedNameInvalid + value + end + private def validate_normalized_value(value, original_value) DN.parse(value) Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Fri Sep 21 20:17:19 2007 @@ -56,14 +56,21 @@ priority :must def test_bit_string_type_cast + assert_type_cast_without_validation(nil, nil, 'Bit String') assert_type_cast("0101111101", "'0101111101'B", 'Bit String') end def test_boolean_type_cast + assert_type_cast_without_validation(nil, nil, 'Boolean') assert_type_cast(true, "TRUE", "Boolean") assert_type_cast(false, "FALSE", "Boolean") end + def test_dn_type_cast + assert_type_cast_without_validation(nil, nil, 'Distinguished Name') + assert_dn_type_cast("cn=test", 'Distinguished Name') + end + priority :normal def test_bit_string_validate assert_valid("'0101111101'B", 'Bit String') @@ -277,11 +284,21 @@ value, "OID") end - def assert_type_cast(type_casted_value, original_value, syntax_name) + def assert_type_cast_without_validation(type_casted_value, original_value, + syntax_name) syntax = @syntaxes[syntax_name] assert_equal(type_casted_value, syntax.type_cast(original_value)) assert_equal(type_casted_value, syntax.type_cast(type_casted_value)) + end + def assert_type_cast(type_casted_value, original_value, syntax_name) + assert_type_cast_without_validation(type_casted_value, original_value, + syntax_name) assert_valid(type_casted_value, syntax_name) + end + + def assert_dn_type_cast(original_value, syntax_name) + assert_type_cast(ActiveLdap::DN.parse(original_value), original_value, + syntax_name) end end From codesite-noreply at google.com Fri Sep 21 23:38:53 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:38:53 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r375 - in trunk: lib/active_ldap/schema test Message-ID: <00163600d6b3043ab12058c7c4340257@google.com> Author: koutou Date: Fri Sep 21 20:38:17 2007 New Revision: 375 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Genralized Time type cast. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:38:17 2007 @@ -20,6 +20,10 @@ PRINTABLE_CHARACTER = /[#{printable_character_source}]/ # UNPRINTABLE_CHARACTER = /[^#{printable_character_source}]/ # + def type_cast(value) + value + end + def valid?(value) validate(value).nil? end @@ -155,7 +159,29 @@ class GeneralizedTime < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.24"] = self + def type_cast(value) + return value if value.nil? or value.is_a?(Time) + begin + Time.parse(value) + rescue ArgumentError + value + end + end + private + def normalize_value(value) + if value.is_a?(Time) + normalized_value = value.strftime("%Y%m%d%H%M%S") + if value.gmt? + normalized_value + "Z" + else + normalized_value + ("%+03d%02d" % value.gmtoff.divmod(3600)) + end + else + value + end + end + def validate_normalized_value(value, original_value) match_data = /\A (\d{4,4})? @@ -176,11 +202,11 @@ if missing_components.empty? nil else - params = [value.inspect, missing_components.join(", ")] + params = [original_value.inspect, missing_components.join(", ")] _("%s has missing components: %s") % params end else - _("%s is invalid time format") + _("%s is invalid time format") % original_value.inspect end end end Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Fri Sep 21 20:38:17 2007 @@ -71,6 +71,16 @@ assert_dn_type_cast("cn=test", 'Distinguished Name') end + def test_generalized_time_type_cast + assert_type_cast_without_validation(nil, nil, "Generalized Time") + assert_type_cast(Time.parse("1994/12/16 10:32"), "199412161032", + "Generalized Time") + assert_type_cast(Time.parse("1994/12/16 10:32Z"), "199412161032Z", + "Generalized Time") + assert_type_cast(Time.parse("1994/12/16 10:32 +09:00"), "199412161032+0900", + "Generalized Time") + end + priority :normal def test_bit_string_validate assert_valid("'0101111101'B", 'Bit String') From codesite-noreply at google.com Fri Sep 21 23:43:53 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 20:43:53 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r376 - in trunk: lib/active_ldap/schema test Message-ID: <00163600d1b5043ab132426209342d87@google.com> Author: koutou Date: Fri Sep 21 20:43:40 2007 New Revision: 376 Modified: trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * supported Integer type cast. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 20:43:40 2007 @@ -214,7 +214,24 @@ class Integer < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.27"] = self + def type_cast(value) + return value if value.nil? + begin + Integer(value) + rescue ArgumentError + value + end + end + private + def normalize_value(value) + if value.is_a?(Integer) + value.to_s + else + value + end + end + def validate_normalized_value(value, original_value) Integer(value) nil Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Fri Sep 21 20:43:40 2007 @@ -81,6 +81,11 @@ "Generalized Time") end + def test_integer_type_cast + assert_type_cast_without_validation(nil, nil, "Generalized Time") + assert_type_cast(1321, "1321", "Integer") + end + priority :normal def test_bit_string_validate assert_valid("'0101111101'B", 'Bit String') From codesite-noreply at google.com Sat Sep 22 00:24:00 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 21:24:00 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r377 - in trunk: lib/active_ldap lib/active_ldap/adapter lib/active_ldap/schema test Message-ID: <00c09ffb50dd043ab1c1bb328f34c0e5@google.com> Author: koutou Date: Fri Sep 21 21:22:55 2007 New Revision: 377 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/schema.rb trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_base.rb trunk/test/test_user.rb trunk/test/test_useradd-binary.rb trunk/test/test_useradd.rb trunk/test/test_usermod-binary-add-time.rb trunk/test/test_usermod-binary-add.rb trunk/test/test_usermod-binary-del.rb trunk/test/test_usermod-lang-add.rb trunk/test/test_usermod.rb Log: * supported type cast. ATTENTION: This changes may break your application. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Fri Sep 21 21:22:55 2007 @@ -406,6 +406,12 @@ end def escape_filter_value(value, options={}) + case value + when Numeric + value = value.to_s + when Time + value = Schema::GeneralizedTime.new.normalize_value(value) + end value.gsub(/(?:[()\\\0]|\*\*?)/) do |s| if s == "*" s Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Fri Sep 21 21:22:55 2007 @@ -590,7 +590,7 @@ _("wrong number of arguments (%d for 1)") % args.size end if before_type_cast - return get_attribute_before_type_cast(real_key, *args) + return get_attribute_before_type_cast(real_key, *args)[1] elsif query return get_attribute_as_query(real_key, *args) else @@ -958,11 +958,30 @@ # # Return the value of the attribute called by method_missing? def get_attribute(name, force_array=false) - get_attribute_before_type_cast(name, force_array) + name, value = get_attribute_before_type_cast(name, force_array) + attribute = schema.attribute(name) + if value.is_a?(Array) + value.collect do |val| + attribute.type_cast(val) + end + else + attribute.type_cast(value) + end + end + + def get_attribute_before_type_cast(name, force_array=false) + name = to_real_attribute_name(name) + + value = @data[name] || [] + if force_array + [name, value.dup] + else + [name, array_of(value.dup, false)] + end end def get_attribute_as_query(name, force_array=false) - value = get_attribute_before_type_cast(name, force_array) + name, value = get_attribute_before_type_cast(name, force_array) if force_array value.collect {|x| !false_value?(x)} else @@ -973,17 +992,6 @@ def false_value?(value) value.nil? or value == false or value == [] or value == "false" or value == "FALSE" or value == "" - end - - def get_attribute_before_type_cast(name, force_array=false) - name = to_real_attribute_name(name) - - value = @data[name] || [] - if force_array - value.dup - else - array_of(value.dup, false) - end end # set_attribute Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Fri Sep 21 21:22:55 2007 @@ -197,7 +197,9 @@ def connection conn = @connection - conn ||= self.class.active_connections[dn] || retrieve_connection if id + if get_attribute_before_type_cast(dn_attribute)[1] + conn ||= self.class.active_connections[dn] || retrieve_connection + end conn || self.class.connection end Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Fri Sep 21 21:22:55 2007 @@ -308,6 +308,14 @@ end end + def normalize_value(value) + if @validator + @validator.normalize_value(value) + else + value + end + end + private def attribute(attribute_name, name=@name) @schema.ldap_syntax_attribute(name, attribute_name) @@ -369,6 +377,14 @@ def validate(value) send_to_syntax(nil, :validate, value) + end + + def type_cast(value) + send_to_syntax(value, :type_cast, value) + end + + def normalize_value(value) + send_to_syntax(value, :type_cast, value) end def syntax_description Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Fri Sep 21 21:22:55 2007 @@ -32,7 +32,6 @@ validate_normalized_value(normalize_value(value), value) end - private def normalize_value(value) value end @@ -50,7 +49,6 @@ end end - private def normalize_value(value) if value.is_a?(String) and /\A[01]*\z/ =~ value "'#{value}'B" @@ -59,6 +57,7 @@ end end + private def validate_normalized_value(value, original_value) if /\A'/ !~ value return _("%s doesn't have the first \"'\"") % original_value.inspect @@ -90,7 +89,6 @@ end end - private def normalize_value(value) case value when true @@ -102,6 +100,7 @@ end end + private def validate_normalized_value(value, original_value) if %w(TRUE FALSE).include?(value) nil @@ -135,6 +134,14 @@ value end + def normalize_value(value) + if value.is_a?(DN) + value.to_s + else + value + end + end + private def validate_normalized_value(value, original_value) DN.parse(value) @@ -168,7 +175,6 @@ end end - private def normalize_value(value) if value.is_a?(Time) normalized_value = value.strftime("%Y%m%d%H%M%S") @@ -182,6 +188,7 @@ end end + private def validate_normalized_value(value, original_value) match_data = /\A (\d{4,4})? @@ -223,7 +230,6 @@ end end - private def normalize_value(value) if value.is_a?(Integer) value.to_s @@ -232,6 +238,7 @@ end end + private def validate_normalized_value(value, original_value) Integer(value) nil Modified: trunk/test/test_base.rb ============================================================================== --- trunk/test/test_base.rb (original) +++ trunk/test/test_base.rb Fri Sep 21 21:22:55 2007 @@ -205,6 +205,7 @@ assert_equal([], user2.errors.to_a) assert(@user_class.exists?(uid2)) attributes.each do |key, value| + value = value.to_i if [:uid_number, :gid_number].include?(key) assert_equal(value, user2[key]) end end @@ -229,6 +230,7 @@ assert_equal([], user.errors.to_a) assert(@user_class.exists?(uid)) attributes.each do |key, value| + value = value.to_i if [:uid_number, :gid_number].include?(key) assert_equal(value, user[key]) end end Modified: trunk/test/test_user.rb ============================================================================== --- trunk/test/test_user.rb (original) +++ trunk/test/test_user.rb Fri Sep 21 21:22:55 2007 @@ -41,12 +41,14 @@ uid_number = 9000 user.uid_number = uid_number # Test to_s on Fixnums - assert_equal(uid_number.to_s, user.uid_number) + assert_equal(uid_number, user.uid_number) + assert_equal(uid_number.to_s, user.uid_number_before_type_cast) gid_number = 9000 user.gid_number = gid_number # Test to_s on Fixnums - assert_equal(gid_number.to_s, user.gid_number) + assert_equal(gid_number, user.gid_number) + assert_equal(gid_number.to_s, user.gid_number_before_type_cast) home_directory = '/home/foo' user.home_directory = home_directory Modified: trunk/test/test_useradd-binary.rb ============================================================================== --- trunk/test/test_useradd-binary.rb (original) +++ trunk/test/test_useradd-binary.rb Fri Sep 21 21:22:55 2007 @@ -39,8 +39,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) assert_equal(['person', 'posixAccount', 'shadowAccount', 'strongAuthenticationUser'].sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) Modified: trunk/test/test_useradd.rb ============================================================================== --- trunk/test/test_useradd.rb (original) +++ trunk/test/test_useradd.rb Fri Sep 21 21:22:55 2007 @@ -39,8 +39,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) end end Modified: trunk/test/test_usermod-binary-add-time.rb ============================================================================== --- trunk/test/test_usermod-binary-add-time.rb (original) +++ trunk/test/test_usermod-binary-add-time.rb Fri Sep 21 21:22:55 2007 @@ -41,8 +41,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) Modified: trunk/test/test_usermod-binary-add.rb ============================================================================== --- trunk/test/test_usermod-binary-add.rb (original) +++ trunk/test/test_usermod-binary-add.rb Fri Sep 21 21:22:55 2007 @@ -41,8 +41,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) Modified: trunk/test/test_usermod-binary-del.rb ============================================================================== --- trunk/test/test_usermod-binary-del.rb (original) +++ trunk/test/test_usermod-binary-del.rb Fri Sep 21 21:22:55 2007 @@ -45,8 +45,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) assert_equal((previous_classes - ['strongAuthenticationUser']).sort, user.classes.sort) assert(!user.respond_to?(:user_certificate)) Modified: trunk/test/test_usermod-lang-add.rb ============================================================================== --- trunk/test/test_usermod-lang-add.rb (original) +++ trunk/test/test_usermod-lang-add.rb Fri Sep 21 21:22:55 2007 @@ -41,8 +41,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal([cn, {'lang-en-us' => cn}], user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) end end Modified: trunk/test/test_usermod.rb ============================================================================== --- trunk/test/test_usermod.rb (original) +++ trunk/test/test_usermod.rb Fri Sep 21 21:22:55 2007 @@ -40,8 +40,10 @@ user = @user_class.find(name) assert_equal(name, user.uid) assert_equal(cn, user.cn) - assert_equal(uid.to_s, user.uid_number) - assert_equal(uid.to_s, user.gid_number) + assert_equal(uid.to_i, user.uid_number) + assert_equal(uid.to_i, user.gid_number) + assert_equal(uid.to_s, user.uid_number_before_type_cast) + assert_equal(uid.to_s, user.gid_number_before_type_cast) end end From codesite-noreply at google.com Sat Sep 22 00:31:16 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 21:31:16 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r378 - in trunk: lib/active_ldap test Message-ID: <00c09ffb51ed043ab1dbb1e58e34f1c3@google.com> Author: koutou Date: Fri Sep 21 21:30:55 2007 New Revision: 378 Modified: trunk/lib/active_ldap/attributes.rb trunk/test/test_user.rb Log: * used normalize_value not to_s. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Fri Sep 21 21:30:55 2007 @@ -41,7 +41,7 @@ if respond_to?(handler, true) [name, send(handler, name, value)] else - [name, [value.to_s]] + [name, [schema.attribute(name).normalize_value(value)]] end end Modified: trunk/test/test_user.rb ============================================================================== --- trunk/test/test_user.rb (original) +++ trunk/test/test_user.rb Fri Sep 21 21:30:55 2007 @@ -58,6 +58,13 @@ assert_equal([home_directory], user.home_directory(true), 'This should be [#{home_directory.dump}].') + see_also = ActiveLdap::DN.parse("cn=XXX,dc=local,dc=net") + user.see_also = see_also + assert_equal(ActiveLdap.parse(see_also), user.see_also) + + see_also = ActiveLdap::DN.parse(see_also) + user.see_also = see_also + assert_equal(see_also, user.see_also) assert(!user.valid?) assert(user.errors.invalid?(:sn)) From codesite-noreply at google.com Sat Sep 22 00:32:02 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 21:32:02 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r379 - trunk/test Message-ID: <00163600d6b3043ab1de6ae07834cb10@google.com> Author: koutou Date: Fri Sep 21 21:31:16 2007 New Revision: 379 Modified: trunk/test/test_user.rb Log: * fixed typos. Modified: trunk/test/test_user.rb ============================================================================== --- trunk/test/test_user.rb (original) +++ trunk/test/test_user.rb Fri Sep 21 21:31:16 2007 @@ -58,9 +58,9 @@ assert_equal([home_directory], user.home_directory(true), 'This should be [#{home_directory.dump}].') - see_also = ActiveLdap::DN.parse("cn=XXX,dc=local,dc=net") + see_also = "cn=XXX,dc=local,dc=net" user.see_also = see_also - assert_equal(ActiveLdap.parse(see_also), user.see_also) + assert_equal(ActiveLdap::DN.parse(see_also), user.see_also) see_also = ActiveLdap::DN.parse(see_also) user.see_also = see_also From codesite-noreply at google.com Sat Sep 22 00:38:04 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 21:38:04 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r380 - trunk/lib/active_ldap Message-ID: <00163600cf97043ab1f4071374351ae5@google.com> Author: koutou Date: Fri Sep 21 21:37:45 2007 New Revision: 380 Modified: trunk/lib/active_ldap/schema.rb Log: * fixed a typo. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Fri Sep 21 21:37:45 2007 @@ -384,7 +384,7 @@ end def normalize_value(value) - send_to_syntax(value, :type_cast, value) + send_to_syntax(value, :normalize_value, value) end def syntax_description From codesite-noreply at google.com Sat Sep 22 00:39:16 2007 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Fri, 21 Sep 2007 21:39:16 -0700 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r381 - trunk/lib/active_ldap/adapter Message-ID: <00c09ffb51ed043ab1f8531281351ff0@google.com> Author: koutou Date: Fri Sep 21 21:38:52 2007 New Revision: 381 Modified: trunk/lib/active_ldap/adapter/base.rb Log: * supported DN in filter value. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Fri Sep 21 21:38:52 2007 @@ -407,7 +407,7 @@ def escape_filter_value(value, options={}) case value - when Numeric + when Numeric, DN value = value.to_s when Time value = Schema::GeneralizedTime.new.normalize_value(value)