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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
# -*- tcl -*-
# ldapx.test: tests for the ldapx module.
#
# Sourcing this file into Tcl runs the tests and generates output for errors.
# No output means no errors were found.
#
# Copyright (c) 2006 by Pierre David <pdav@users.sourceforge.net>
# All rights reserved.
#
# $Id: ldapx.test,v 1.6 2007/08/19 20:20:43 pdav Exp $
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.4
testsNeedTcltest 1.0
testing {
useLocal ldapx.tcl ldapx
}
# -------------------------------------------------------------------------
set rdn1 "uid=test"
set rdn2 "uid=test2"
set sup1 "ou=mydept,o=myorg"
set sup2 "ou=x,$sup1"
set entry {a1 {v11 v12} a2 {v21} a3 {v31 v32 v33}}
# -------------------------------------------------------------------------
test ldapx-1.0 {ldapx::entry - creation} {
::ldapx::entry create t1
} {::t1}
test ldapx-1.1 {ldapx::entry - reset} {
t1 reset
t1 format
} {uninitialized}
test ldapx-1.2 {ldapx::entry - dn} {
t1 dn "$rdn1,$sup1"
t1 dn
} "$rdn1,$sup1"
test ldapx-1.3 {ldapx::entry - superior} {
t1 dn "$rdn1,$sup1"
t1 superior
} $sup1
test ldapx-1.4 {ldapx::entry - rdn} {
t1 rdn
} $rdn1
test ldapx-1.5 {ldapx::entry - print uninitialized} {
t1 print
} "dn: $rdn1,$sup1"
test ldapx-2.1 {ldapx::entry - standard} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
lsort [t1 getall]
} [lsort $entry]
test ldapx-2.2 {ldapx::entry - isempty} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
set e1 [t1 isempty]
::ldapx::entry create t2
set e2 [t2 isempty]
t2 destroy
list $e1 $e2
} {0 1}
test ldapx-2.3 {ldapx::entry - set1/get1} {
t1 set1 A4 v41
t1 get1 A4
} {v41}
test ldapx-2.4 {ldapx::entry - add1} {
t1 add1 a4 {v 42}
t1 get A4
} {v41 {v 42}}
test ldapx-2.5 {ldapx::entry - set/add/get} {
t1 set a5 {v51}
t1 add a5 {{v 52} {v 53}}
t1 get a5
} {v51 {v 52} {v 53}}
test ldapx-2.6 {ldapx::entry - del1/del} {
t1 del1 A5 {v 52}
t1 del a5 {{v 53}}
t1 get a5
} {v51}
test ldapx-2.7 {ldapx::entry - del} {
t1 del A5
t1 get a5
} {}
test ldapx-2.8 {ldapx::entry - getattr} {
lsort [t1 getattr]
} {a1 a2 a3 a4}
test ldapx-3.1 {ldapx::entry - backup toanother} {
::ldapx::entry create t2
::ldapx::entry create t3
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 backup t2
t3 diff t1 t2
t3 change
} {}
test ldapx-3.2 {ldapx::entry - diff toanother modrdn uid deleteoldrdn} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 set1 "uid" "test"
t1 backup t2
t1 dn "$rdn2,$sup1"
t1 set1 "uid" "test2"
t3 diff t1 t2
t3 change
} [list [list modrdn $rdn2 1]]
test ldapx-3.3 {ldapx::entry - diff toanother modrdn uid keepoldrdn} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 set1 "uid" "test"
t1 backup t2
t1 dn "$rdn2,$sup1"
t1 add1 "uid" "test2"
t3 diff t1 t2
t3 change
} [list [list modrdn $rdn2 0]]
test ldapx-3.4 {ldapx::entry - diff toanother modrdn superior} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 backup t2
t1 dn "$rdn1,$sup2"
t3 diff t1 t2
t3 change
} [list [list modrdn $rdn1 0 $sup2]]
test ldapx-3.5 {ldapx::entry - diff toanother add attr} {
t1 reset
t1 setall $entry
t1 backup t2
t1 set anotherAttribute {v1 v2}
t3 diff t1 t2
t3 change
} {{mod {{modadd anotherattribute {v1 v2}}}}}
test ldapx-3.6 {ldapx::entry - diff toanother repl attr} {
t1 reset
t1 setall $entry
t1 backup t2
t1 del1 a3 v32
t3 diff t1 t2
t3 change
} {{mod {{modrepl a3 {v31 v33}}}}}
test ldapx-3.7 {ldapx::entry - diff toanother add value} {
t1 reset
t1 setall $entry
t1 backup t2
t1 add1 a3 v34
t3 diff t1 t2
t3 change
} {{mod {{modrepl a3 {v31 v32 v33 v34}}}}}
test ldapx-3.8 {ldapx::entry - diff toanother del attr} {
t1 reset
t1 setall $entry
t1 backup t2
t1 del A3
t3 diff t1 t2
t3 change
} {{mod {{moddel a3}}}}
test ldapx-3.9 {ldapx::entry - diff toanother del entry 1} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 backup t2
t1 setall {}
t3 diff t1 t2
list [t3 dn] [lindex [t3 change] 0 0]
} [list "$rdn1,$sup1" del]
test ldapx-3.10 {ldapx::entry - diff toanother del entry 2} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t1 backup t2
t1 dn ""
t1 setall {}
t3 diff t1 t2
list [t3 dn] [lindex [t3 change] 0 0]
} [list "$rdn1,$sup1" del]
test ldapx-3.11 {ldapx::entry - diff toanother add entry} {
t1 reset
t1 setall {}
t1 backup t2
t1 setall $entry
t3 diff t1 t2
lsort [list [lindex [t3 change] 0 0] \
[lsort [lindex [t3 change] 0 1]]]
} [lsort [list add [lsort [string tolower $entry]]]]
test ldapx-3.12 {ldapx::entry - diff toanother add entry dn 1} {
t1 reset
t1 backup t2
t1 dn "$rdn1,$sup1"
t1 setall $entry
t3 diff t1 t2
list [t3 dn] [lindex [t3 change] 0 0]
} [list "$rdn1,$sup1" add]
test ldapx-3.13 {ldapx::entry - diff toanother add entry dn 2} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 backup t2
t1 setall $entry
t3 diff t1 t2
list [t3 dn] [lindex [t3 change] 0 0]
} [list "$rdn1,$sup1" add]
test ldapx-3.14 {ldapx::entry - diff tothesame} {
t1 reset
t1 setall $entry
t1 backup
t1 set1 A3 v34
t3 diff t1
t3 change
} {{mod {{modrepl a3 v34}}}}
test ldapx-3.15 {ldapx::entry - restore toanother} {
t1 reset
t1 setall {a v}
t1 backup
t1 restore t2
t2 getall
} {a v}
test ldapx-3.16 {ldapx::entry - restore tothesame} {
t1 reset
t1 setall {a v}
t1 backup
t1 setall $entry
t1 restore
t1 getall
} {a v}
test ldapx-3.17 {ldapx::entry - swap} {
t1 reset
t1 setall {a v}
t1 dn d1
t1 backup
t1 setall {b w}
t1 dn d2
t1 swap
set l1 [list [t1 dn] [t1 getall]]
t1 swap
set l2 [list [t1 dn] [t1 getall]]
list $l1 $l2
} {{d1 {a v}} {d2 {b w}}}
test ldapx-3.18 {ldapx::entry - apply modrdn rdn} {
t1 reset
t1 dn "$rdn1,$sup1"
t2 reset
t2 dn "$rdn1,$sup1"
t2 change [list [list modrdn $rdn2 0]]
t1 apply t2
t1 dn
} "$rdn2,$sup1"
test ldapx-3.19 {ldapx::entry - apply modrdn superior} {
t1 reset
t1 dn "$rdn1,$sup1"
t2 reset
t2 dn "$rdn1,$sup1"
t2 change [list [list modrdn $rdn1 0 $sup2]]
t1 apply t2
t1 dn
} "$rdn1,$sup2"
test ldapx-3.20 {ldapx::entry - apply modrdn rdn+superior} {
t1 reset
t1 dn "$rdn1,$sup1"
t2 reset
t2 dn "$rdn1,$sup1"
t2 change [list [list modrdn $rdn2 0 $sup2]]
t1 apply t2
t1 dn
} "$rdn2,$sup2"
test ldapx-3.21 {ldapx::entry - apply add} {
t1 reset
t2 reset
t2 dn "$rdn1,$sup1"
t2 change [list [list add $entry]]
t1 apply t2
lsort [t1 getall]
} [lsort $entry]
test ldapx-3.22 {ldapx::entry - apply del} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t2 reset
t2 dn "$rdn1,$sup1"
t2 change {{del}}
t1 apply t2
lsort [t1 getall]
} {}
test ldapx-3.23 {ldapx::entry - apply mod add} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t2 reset
t2 dn "$rdn1,$sup1"
t2 change {{mod {{modadd A4 {v41 v42}}}}}
t1 apply t2
t1 get a4
} {v41 v42}
test ldapx-3.24 {ldapx::entry - apply mod del} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t2 reset
t2 dn "$rdn1,$sup1"
t2 change {{mod {{moddel A3}}}}
t1 apply t2
t1 get a3
} {}
test ldapx-3.25 {ldapx::entry - apply mod repl} {
t1 reset
t1 dn "$rdn1,$sup1"
t1 setall $entry
t2 reset
t2 dn "$rdn1,$sup1"
t2 change {{mod {{modrepl A3 {v34 v35}}}}}
t1 apply t2
t1 get a3
} {v34 v35}
test ldapx-4.1 {ldapx::entry - deletion} {
t1 destroy
t2 destroy
t3 destroy
} {}
testsuiteCleanup
|