tester.rb
4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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 '=== Model#to_h ==='
puts user.to_h.inspect
puts 'base: ' + user.inspect
puts '---'
puts group.to_h.inspect
puts 'base: ' + group.inspect
puts '---'
puts site.to_h.inspect
puts 'base: ' + site.inspect
puts '---'
puts alias_role.to_h.inspect
puts 'base: ' + alias_role.inspect
puts '---'
puts alias_person.to_h.inspect
puts 'base: ' + alias_person.inspect
puts '---'
puts account.to_h.inspect
puts 'base: ' + account.inspect
puts
puts '=== Storage#update ==='
user.home = '/home/user/foo'
puts 'returns: ' + user.save
puts 'base: ' + user.inspect
puts
puts '=== Storage#update(replace[delete,create]) ==='
user.name = 'brad'
puts 'returns: ' + user.save
puts 'base: ' + user.inspect
puts
puts 'Memory useage: ' + `ps -o rss= -p #{Process.pid}`