tester.rb 3.79 KB
require 'ds_admin'
require 'yaml'

DsAdmin::Model.storage = DsAdmin::Storage::Ldap.new(
  DsAdmin::Storage::Config.new(
    YAML.load_file(File.dirname(__FILE__) + '/config/storage.yml')
))

user         = DsAdmin::Model::User.new
group        = DsAdmin::Model::Group.new
site         = DsAdmin::Model::Site.new
alias_role   = DsAdmin::Model::MailAliasRole.new
alias_person = DsAdmin::Model::MailAliasPerson.new
account      = DsAdmin::Model::MailAccount.new

puts '=== base objects ==='
puts 'base: ' + user.inspect
puts 'base: ' + group.inspect
puts 'base: ' + site.inspect
puts 'base: ' + alias_role.inspect
puts 'base: ' + alias_person.inspect
puts 'base: ' + account.inspect

puts
puts '=== Model#all ==='
puts user.all.inspect
puts 'base: ' + user.inspect
puts group.all.inspect
puts 'base: ' + group.inspect
puts site.all.inspect
puts 'base: ' + site.inspect
puts alias_role.all.inspect
puts 'base: ' + alias_role.inspect
puts alias_person.all.inspect
puts 'base: ' + alias_person.inspect
puts account.all.inspect
puts 'base: ' + account.inspect

puts
puts '=== DsAdmin each ==='
user.each {|u| puts u.inspect}
puts 'base: ' + user.inspect
puts '---'
group.each {|g| puts g.inspect}
puts 'base: ' + group.inspect
puts '---'
site.each {|s| puts s.inspect}
puts 'base: ' + site.inspect
puts '---'
alias_role.each {|mar| puts mar.inspect}
puts 'base: ' + alias_role.inspect
puts '---'
alias_person.each {|map| puts map.inspect}
puts 'base: ' + alias_person.inspect
puts '---'
account.each {|macc| puts macc.inspect}
puts 'base: ' + account.inspect

puts
puts '=== DsAdmin Enumerable ==='
puts user.find {|u| u.uid == '1000'}.inspect
puts 'base: ' + user.inspect
puts '---'
puts group.find {|g| g.gid == '10'}.inspect
puts 'base: ' + group.inspect
puts '---'
puts site.find {|s| s.name == 'steffers.org'}.inspect
puts 'base: ' + site.inspect
puts '---'
puts alias_role.find_all {|mar| mar.maildrop == 'abuse'}.inspect
puts 'base: ' + alias_role.inspect
puts '---'
puts alias_person.find {|map| map.mail == 'georg@steffers.org'}.inspect
puts 'base: ' + alias_person.inspect
puts '---'
puts account.find {|macc| macc.mail == 'drachenfrau@steffers.org'}.inspect
puts 'base: ' + account.inspect

puts
puts '=== Model#load ==='
puts user.load('uid=georg,ou=user,o=system,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + user.inspect
puts '---'
puts group.load('cn=wheel,ou=group,o=system,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + group.inspect
puts '---'
puts site.load('o=steffers.org,o=hosting,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + site.inspect
puts '---'
puts alias_role.load('cn=abuse,o=weird-web-workers.org,o=hosting,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + alias_role.inspect
puts '---'
puts alias_person.load('mail=georg@steffers.org,o=steffers.org,o=hosting,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + alias_person.inspect
puts '---'
puts account.load('mail=drachenfrau@steffers.org,o=steffers.org,o=hosting,dc=weird-web-workers,dc=org').inspect
puts 'base: ' + account.inspect

puts
puts '=== Model#load! ==='
user.load!('uid=georg,ou=user,o=system,dc=weird-web-workers,dc=org')
puts 'base: ' + user.inspect
puts '---'
group.load!('cn=wheel,ou=group,o=system,dc=weird-web-workers,dc=org')
puts 'base: ' + group.inspect
puts '---'
site.load!('o=steffers.org,o=hosting,dc=weird-web-workers,dc=org')
puts 'base: ' + site.inspect
puts '---'
alias_role.load!('cn=abuse,o=weird-web-workers.org,o=hosting,dc=weird-web-workers,dc=org')
puts 'base: ' + alias_role.inspect
puts '---'
alias_person.load!('mail=georg@steffers.org,o=steffers.org,o=hosting,dc=weird-web-workers,dc=org')
puts 'base: ' + alias_person.inspect
puts '---'
account.load!('mail=drachenfrau@steffers.org,o=steffers.org,o=hosting,dc=weird-web-workers,dc=org')
puts 'base: ' + account.inspect

puts
puts 'Memory useage: ' + `ps -o rss= -p #{Process.pid}`