person-cov.exp 13.6 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
# Test suite for lyskomd.
2
# Copyright (C) 1999, 2002  Lysator Academic Computer Association.
Per Cederqvist's avatar
Per Cederqvist committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# This file is part of the LysKOM server.
# 
# LysKOM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by 
# the Free Software Foundation; either version 1, or (at your option) 
# any later version.
# 
# LysKOM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License
# along with LysKOM; see the file COPYING.  If not, write to
# Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
# or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
# MA 02139, USA.
#
# Please mail bug reports to bug-lyskom@lysator.liu.se. 


David Byers's avatar
David Byers committed
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
# Supplemental test cases for person.c

# X Attempt to mark a text in a secret conference
# X Attempt to mark a text in an rd_prot conference
# X Attempt to mark a text when it has reached the mark limit
# X Attempt to unmark a text that has zero marks

# X Attempt to set the user area to a text that has reached mark limit
# X Set a user area when there already is a user area
# X Set a user area when the current user area has zero marks
# X Set a user area when the current user area is deleted
# X Attempt to set-user-area for a secret person
# X Attempt to ser-user-area for a person we don't have rights to

# X Delete a person that has marked texts
# X Delete a person that has a marked text that has zero marks
# X Delete a person whose user area is deleted

# X Try to log in with incorrect password

# X Try to create a person before login with param.create_person_before_login set
# X Try to create a person without the privs to do so
# X Try to create a person with zero-length name
# X Try to create a person with a non-printable character in the name
# X Try to create a person with the name of a person already there
# X Try to create a person with a password containing a NUL
# X Create a person with an invalid aux-item-list
# X Create persons so we hit the max number of confs

# X get-pers-stat for person with secret letterbox
# X get-pers-stat-old for person with secret letterbox

# X get-created-texts for a person with secret letterbox

# X Request 256 texts from map-created-texts

# X Call map-created-texts for a secret person

# X Attempt to change someone else's password
# X Attempt to change password to one containing a NUL

# X Attempt to query-read-texts for a secret person
# X Attempt to query-read-texts for a secret conference
# X Attempt to query-read-texts for an open conf we are not member of
# X Attempt to query-read-texts for someone else's secret membership
# X Attempt to query-read-texts for a person with unread_is_secret set

# X Call set-pers-flags for self
# X Call set-pers-flags for supervised person
# X Call set-pers-flags as administrator
# X Call set-pers-flags for a secret person we may not know about
# X Call set-pers-flags for person 0
# X Call set-pers-flags for someone else


# Hard to do
#   All the restart_kom calls...
#   Fail to create the password string in legal_passwd
#   Call to do_mark_text with pers_p equal NULL
#   Call to do_mark_text with text_s equal to NULL
#   Call to do_unmark_text with pers_p equal NULL
#   Call to do_set_user_area with pers_p equal NULL
#   In do_delete_person fail to remove the person as a member in a conf
#   -- Happens if the member/membership correspondence is FUBAR
#   Fail to create the password string in chk_passwd
#   Failure in cached_create_person (bloddy thing can't fail!)
#   Failure in cached_get_person_stat
#   Failure in do_set_passwd
#   Failure in access_perm

read_versions
96
source "$srcdir/config/prot-a.exp"
David Byers's avatar
David Byers committed
97
98

lyskomd_start "" "" "\
99
Aux-item definition file: $srcdir/lyskomd.0/aux-items.conf
100
Max conferences: 17
David Byers's avatar
David Byers committed
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
Max texts: 2000
Max marks per text: 1
Max conference name length: 60
Anyone can create new persons: false
Allow creation of persons before login: false
"

client_start 0
talk_to client 0
kom_connect "DejaGnu Test Suite"
kom_accept_async "0 { }"

kom_login 5 "gazonk" 0
kom_enable 255
kom_create_person "P6" "PW6" "00000000" "0 { }"
kom_create_person "P7" "PW7" "00000000" "0 { }"
kom_create_person "P8" "PW8" "00000000" "0 { }"
kom_create_person "P9" "PW9" "00000000" "0 { }"

kom_set_conf_type 7 "10110000"
kom_set_priv_bits 6 "0001110000000000"


kom_login 6 "PW6" 0
kom_create_conference "C10" "00000000" "0 { }"
kom_create_conference "C11" "00000000" "0 { }"
kom_create_conference "C12" "00000000" "0 { }"
kom_create_conference "C13" "10000000" "0 { }"
kom_create_conference "C14" "10100000" "0 { }"

kom_add_member 11 6 100 9999 00100000
kom_add_member 14 6 100 9999 00100000
kom_add_member 14 7 100 9999 00000000
134
lyskomd_expect "Person 7 added to conference 14 by 6."
David Byers's avatar
David Byers committed
135
kom_add_member 10 7 100 9999 00000000
136
lyskomd_expect "Person 7 added to conference 10 by 6."
David Byers's avatar
David Byers committed
137
kom_add_member 10 9 100 9999 00000000
138
lyskomd_expect "Person 9 added to conference 10 by 6."
David Byers's avatar
David Byers committed
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


# Tests for text marking

kom_login 6 "PW6" 0

send "1000 86 [holl "T1"] 1 { 0 14 } 0 { }\n"
simple_expect "=1000 1"
send "1001 86 [holl "T2"] 1 { 0 13 } 0 { }\n"
simple_expect "=1001 2"
send "1002 86 [holl "T3"] 1 { 0 10 } 0 { }\n"
simple_expect "=1002 3"


# Attempt to mark a text in a secret conference we don't know about

kom_login 8 "PW8" 0

send "1003 72 1 0\n"
simple_expect "%1003 14 1"

# Attempt to mark a text in an rd_prot conference we're not members of

send "1004 72 2 0\n"
simple_expect "%1004 14 2"

# Attempt to mark beyond mark-limit

send "1005 72 3 0\n"
simple_expect "=1005"

kom_login 9 "PW9" 0
send "1006 72 3 0\n"
simple_expect "%1006 36 3"

# Attempt to unmark a text that has zero mark count but is marked

kom_login 8 "PW8" 0

178
if {$debug_calls} {
David Byers's avatar
David Byers committed
179
180
send "1007 1001 3 0\n"
simple_expect "=1007"
181
182
183
} else {
unsupported "Use configure --with-debug-calls to enable"
}
David Byers's avatar
David Byers committed
184
185

send "1008 73 3\n"
186
187
188
if {$debug_calls} {
    lyskomd_expect "WNG: do_unmark_text\\(\\): Text 3 has no_of_marks==0,  but person 8 had marked the text\\."
}
David Byers's avatar
David Byers committed
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
simple_expect "=1008"



# Tests for set-user-area

# Attempt to set the user area to a text that has reached mark limit
# Set a user area when there already is a user area
# Set a user area when the current user area has zero marks
# Set a user area when the current user area is deleted
# Attempt to set-user-area for a secret person
# Attempt to ser-user-area for a person we don't have rights to

kom_login 6 "PW6" 0

send "2000 86 [holl "T4"] 1 { 0 10 } 0 { }\n"
simple_expect "=2000 4"

send "2001 86 [holl "T5"] 1 { 0 10 } 0 { }\n"
simple_expect "=2001 5"

send "2002 86 [holl "T6"] 1 { 0 10 } 0 { }\n"
simple_expect "=2002 6"


# Attempt to set a user area that has reached mark-limit

kom_login 8 "PW8" 0

send "2003 72 4 1\n"
simple_expect "=2003"

send "2004 57 8 4\n"
222
lyskomd_expect "LIMIT: set_user_area\\(8, 4\\): New user_area's mark count \\(1\\) > 1."
David Byers's avatar
David Byers committed
223
224
225
226
227
228
229
230
231
232
233
234
235
236
simple_expect "%2004 36 4"


# Set a user area when there already is a user area

send "2005 57 8 5\n"
simple_expect "=2005"

send "2006 57 8 6\n"
simple_expect "=2006"


# Set a user area when the current one has zero marks

237
if {$debug_calls} {
David Byers's avatar
David Byers committed
238
239
send "2007 1001 6 0\n"
simple_expect "=2007"
240
241
242
} else {
unsupported "Use configure --with-debug-calls to enable"
}
David Byers's avatar
David Byers committed
243
244

send "2008 57 8 5\n"
245
246
247
if {$debug_calls} {
    lyskomd_expect "ERROR: set_user_area\\(8, 5\\): Old user_area 6 unmarked."
}
David Byers's avatar
David Byers committed
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
simple_expect "=2008"


# Set a user area when the current one has been deleted

kom_login 6 "PW6" 0
send "2009 29 5\n"
simple_expect "=2009"
kom_login 8 "PW8" 0

send "2010 57 8 6\n"
simple_expect "=2010"


# Attempt to set the user area for a secret person

send "2011 57 7 6\n"
simple_expect "%2011 10 7"


# Attempt to set the user area for another person we don't have rights to

send "2012 57 9 6\n"
simple_expect "%2012 12 9"



# Tests for deleting a person

kom_login 6 "PW6" 0
kom_create_person "P15" "PW15" "00000000" "0 { }"

kom_login 15 "PW15" 0
send "3000 86 [holl "T7"] 1 { 0 10 } 0 { }\n"
simple_expect "=3000 7"
send "3001 86 [holl "T8"] 1 { 0 10 } 0 { }\n"
simple_expect "=3001 8"
send "3002 86 [holl "T9"] 1 { 0 10 } 0 { }\n"
simple_expect "=3002 9"

send "3003 72 7 1\n"
simple_expect "=3003"
send "3004 72 8 1\n"
simple_expect "=3004"

293
if {$debug_calls} {
David Byers's avatar
David Byers committed
294
295
send "3006 1001 8 0\n"
simple_expect "=3006"
296
297
298
} else {
unsupported "Use configure --with-debug-calls to enable"
}
David Byers's avatar
David Byers committed
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314

send "3007 57 15 9\n"
simple_expect "=3007"

send "3008 29 9\n"
simple_expect "=3008"

# The setup at this point is
# Person 15 has user area 9, which is deleted
# Person 15 has marked text 8 and 9
# Text 9 has had its mark count set to zero

# Delete a user who has marked texts, whose user area is 
# deleted and who has a text marked that has zero marks

send "3009 11 15\n"
315
316
317
if {$debug_calls} {
    lyskomd_expect "WNG: do_unmark_text\\(\\): Text 8 has no_of_marks==0,  but person 15 had marked the text\\."
}
David Byers's avatar
David Byers committed
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
simple_expect "=3009"


# Login stuff. Try to log in with the bad password

send "4000 62 6 [holl "BADPWD"] 0\n"
simple_expect "%4000 4 6"


# Create person stuff

# Try to create a person without logging in when that's not allowed

kom_logout
send "5000 89 [holl "PXX"] [holl "PXX"] 00000000 0 { }\n"
simple_expect "%5000 6 0"

# Try to create a person without the privs to do so

kom_login 8 "PW8" 0
send "5001 89 [holl "PXX"] [holl "PXX"] 00000000 0 { }\n"
simple_expect "%5001 12 0"

# Try to create a person with an empty name

kom_login 6 "PW6" 0
send "5002 89 [holl ""] [holl "PXX"] 00000000 0 { }\n"
simple_expect "%5002 18 0"

# Try to create a person with a non-printable character in the name

send "5003 89 [holl "X\001Y"] [holl "PXX"] 00000000 0 { }\n"
simple_expect "%5003 18 0"

# Try to create a person with a duplicate name

send "5004 89 [holl "P6"] [holl "PWX"] 00000000 0 { }\n"
simple_expect "%5004 21 0"

# Try to create a person with a password with a NUL
# Stupid TCL sort of FORGETS about the string after the NUL
# 
# send "5005 89 [holl "PXX"] [holl "P\000X"] 00000000 0 { }\n"
# simple_expect "%5005 18 0"

# Attempt to create a person with an invalid aux-item list

kom_login 6 "PW6" 0
send "5006 89 [holl "PXX"] [holl "PYY"] 00000000 1 { 0 00000000 0 [holl "A"] }\n"
simple_expect "%5006 48 0"

# Create persons til we hit the max number of confs

kom_login 6 "PW6" 0
send "5006 89 [holl "P16"] [holl "PW16"] 00000000 0 { }\n"
simple_expect "=5006 17"

send "5007 89 [holl "P17"] [holl "PW17"] 00000000 0 { }\n"
376
lyskomd_expect "ERROR: Couldn't create person. Too many conferences."
David Byers's avatar
David Byers committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
simple_expect "%5007 19 18"


# Tests for get-pers-stat

send "6000 49 7\n"
simple_expect "%6000 10 7"

send "6001 6 7 1\n"
simple_expect "%6001 10 7"


# Tests for get-created-texts

send "7000 47 7 0 9999\n"
simple_expect "%7000 10 7"


# Test for map-created-texts

# Try to get too many entries

send "7001 104 6 1 256\n"
simple_expect "%7001 46 255"

# Try to get created texts for a secret person

send "7002 104 7 1 10\n"
simple_expect "%7002 10 7"

# Attempt to change someone else's password

kom_login 8 "PW8" 0
send "8000 8 9 [holl "PW9"] [holl "9PW"]\n"
simple_expect "%8000 12 9"

# Attempt to change password to one with a NUL
# Stupid TCL truncates the password at the NUL
#
# send "8001 8 [holl "PW8"] [holl "A\000B"]\n"
# simple_expect "%8001 4 8" 


# Tests for query-read-texts

kom_login 8 "PW8" 0

# Attempt to query-read-texts for a secret person

send "9000 98 7 10\n"
simple_expect "%9000 10 7"

# Attempt to query-read-texts for a secret conference on an open person

send "9001 98 6 14\n"
simple_expect "%9001 9 14"

# Attempt to query-read-texts for a conference we're not a member of

send "9002 98 8 10\n"
simple_expect "%9002 13 10"

# Attempt to query-read-texts for someone else's secret membership

send "9003 98 6 11\n"
simple_expect "%9003 13 11"

# Attempt to query-read-texts for a person with unread_is_secret set

kom_login 5 "gazonk" 0
kom_enable 255

kom_add_member 10 9 100 9999 00000000
send "9004 106 9 10000000\n"
simple_expect "=9004"
send "9005 86 [holl "T10"] 1 { 0 10 } 0 { }\n"
simple_expect "=9005 10"
kom_login 9 "PW9" 0
send "9006 27 10 2 { 1 2 }\n"
simple_expect "=9006"

kom_login 6 "PW6" 0
send "9007 98 9 10\n"
simple_expect "=9007 1 $any_time 10 100 0 0 \\* 6 $any_time 00000000"


# Tests on set-pers-flags

kom_login 9 "PW9" 0

send "10000 49 9\n"
468
extracting_expect "=10000 $hollerith \[01\]+ 10000000 $any_time 0 $any_num ($any*)" pers 1
David Byers's avatar
David Byers committed
469
470
471
472
473
474
475

# Call on self

send "10001 106 9 10011001\n"
simple_expect "=10001"

send "10001 49 9\n"
476
simple_expect "=10001 $hollerith \[01\]+ 10011001 $any_time 0 $any_num $pers"
David Byers's avatar
David Byers committed
477
478
479
480
481
482
483
484
485
486

# Call on supervised person

kom_login 5 "gazonk" 0
kom_enable 0

send "10002 106 9 01100110\n"
simple_expect "=10002"

send "10002 49 9\n"
487
simple_expect "=10002 $hollerith \[01\]+ 01100110 $any_time 0 $any_num $pers"
David Byers's avatar
David Byers committed
488
489
490
491
492
493
494
495
496
497
498


# Call as administrator

kom_login 5 "gazonk" 0
kom_enable 255

send "10003 106 9 11000011\n"
simple_expect "=10003"

send "10003 49 9\n"
499
simple_expect "=10003 $hollerith \[01\]+ 11000011 $any_time 0 $any_num $pers"
David Byers's avatar
David Byers committed
500
501
502
503
504
505
506
507
508
509
510


# Call on secret person we don't know about

kom_login 8 "PW8" 0
send "10004 106 7 01010101\n"
simple_expect "%10004 10 7"

kom_login 5 "gazonk" 0
kom_enable 0
send "10005 49 7\n"
511
simple_expect "=10005 $hollerith \[01\]+ 00000000 $any*"
David Byers's avatar
David Byers committed
512
513
514
515
516
517
518
519
520
521
522
523
524

# Call on person 0

send "10006 106 0 01110111\n"
simple_expect "%10006 8 0"

# Call on non-supervised person

kom_login 8 "PW8" 0
send "10007 106 9 10101010\n"
simple_expect "%10007 12 9"

send "10008 49 9\n"
525
simple_expect "=10008 $hollerith \[01\]+ 11000011 $any_time 0 $any_num $pers"
David Byers's avatar
David Byers committed
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540



# ============================================================
# Shut it down

talk_to client 0
kom_login 5 "gazonk" 0
kom_enable 255

send "99999 44 0\n"
simple_expect "=99999"

client_death 0
lyskomd_death