Sha256: 0c9361c9b11a8c77576d7b240c0cc41c86cb4b10ed6258e3efe388ae7b0c62b2

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

#test user subclass used in tests. Works with ADAM. Change the GUID
#and recordscope to your server's config
#
require 'passiveldap'

class TestUser < PassiveLDAP::Base
  # change the recordbase to your recordbase!
  passive_ldap \
    :id_attribute => :uidnumber,
    :record_base => "cn=Users,dc=eotvos,dc=elte,dc=hu"
  passive_ldap_attr \
    :cn => {:name => :common_name, :default_value => Proc.new {|s| "test_#{s.id}" } },
    :sn => {:name => :surname},
    :mail => {},
    :othermailbox => {:multi_valued => true, :name => :other_mailbox},
    :dn => { :default_value => Proc.new { |s| "cn=test_#{s.id},#{s.class.settings[:record_base]}" }, :hidden => true },
    :objectclass => { :default_value => %w{top person organizationalPerson user}, :multi_valued => true, :hidden => true }
end

class ValidatedUser < PassiveLDAP::Base
  # change the recordbase to your recordbase!
  passive_ldap \
    :id_attribute => :uidnumber,
    :record_base => "cn=Users,dc=eotvos,dc=elte,dc=hu",
    :default_array_separator => "\n"
  passive_ldap_attr \
    :cn => {:name => :common_name, :default_value => Proc.new {|s| "test_#{s.id}" } },
    :sn => {:name => :surname},
    :mail => {},
    :description => {},
    :othermailbox => {:multi_valued => true, :name => :other_mailbox},
    :givenname => { :type => { :from => Proc.new { |s| "Mr. #{s}" }, :to => Proc.new { |s| s[4..-1] } } }, # Adds or cuts the "Mr. " prefix
    :dn => { :default_value => Proc.new { |s| "cn=test_#{s.id},#{s.class.settings[:record_base]}" }, :hidden => true },
    :objectclass => { :default_value => %w{top person organizationalPerson user}, :multi_valued => true, :hidden => true }

  validates_presence_of :description
  validates_format_of :mail, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
  validates_format_of_each :other_mailbox, :with => /\A(?:(?:[^@;\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,}))\Z/i, :unless => Proc.new { |s| s.other_mailbox.nil? or s.other_mailbox == "" }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
passiveldap-0.1 tests/user.rb