1#!/bin/bash
2# \
3exec tclsh "$0" "$@"
4
5source tests/commands/common.tcl
6
7proc simple {} {
8 global server client serverout clientout port
9
10 # add ban
11 clear
12 server "addban 127.0.0.1"
13 expect $serverout "Ban on 127.0.0.1 added."
14
15 # try to reconnect
16 client "disconnect"
17 client "reconnect"
18 wait 2
19 for {set i 0} {$i < 12} {incr i} { gets $clientout }
20 expect $clientout {} 0
21 expect $clientout {You are banned! (reason: none given)} 0
22 expect $clientout {If you feel there has been an error, contact the server host. (No e-mail given)} 0
23 expect $serverout {Player disconnected. (SPECTATOR, 0 FRAGS, 0 DEATHS)}
24 expect $serverout {127.0.0.1:10501 is trying to connect...}
25 expect $serverout {127.0.0.1:10501 is banned and unable to join! (reason: none given)}
26
27 # remove ban
28 clear
29 server "delban 127.0.0.1"
30 expect $serverout "1 Bans removed."
31
32 # reconnect should have worked now
33 clear
34 client "disconnect"
35 client "reconnect"
36 wait 2
37 expect $serverout {127.0.0.1:10501 is trying to connect...}
38 expect $serverout {Player has connected.}
39}
40
41proc wildcard {} {
42 global server client serverout clientout port
43
44 # add ban
45 clear
46 server "addban 127.0.0.*"
47 expect $serverout "Ban on 127.0.0.* added."
48
49 # try to reconnect
50 client "disconnect"
51 client "reconnect"
52 wait 2
53 for {set i 0} {$i < 12} {incr i} { gets $clientout }
54 expect $clientout {} 0
55 expect $clientout {You are banned! (reason: none given)} 0
56 expect $clientout {If you feel there has been an error, contact the server host. (No e-mail given)} 0
57 expect $serverout {Player disconnected. (SPECTATOR, 0 FRAGS, 0 DEATHS)}
58 expect $serverout {127.0.0.1:10501 is trying to connect...}
59 expect $serverout {127.0.0.1:10501 is banned and unable to join! (reason: none given)}
60
61 # remove ban
62 clear
63 server "delban 127.0.0.*"
64 expect $serverout "1 Bans removed."
65
66 # reconnect should have worked now
67 clear
68 client "disconnect"
69 client "reconnect"
70 wait 2
71 expect $serverout {127.0.0.1:10501 is trying to connect...}
72 expect $serverout {Player has connected.}
73}
74
75proc notme {} {
76 global server client serverout clientout port
77
78 # add ban
79 clear
80 server "addban 128.0.0.*"
81 expect $serverout "Ban on 128.0.0.* added."
82
83 # reconnect should have worked now
84 clear
85 client "disconnect"
86 client "reconnect"
87 wait 2
88 expect $serverout {Player disconnected. (SPECTATOR, 0 FRAGS, 0 DEATHS)}
89 expect $serverout {127.0.0.1:10501 is trying to connect...}
90 expect $serverout {Player has connected.}
91}
92
93proc main {} {
94 simple
95 wildcard
96 notme
97}
98
99start
100
101set error [catch { main }]
102
103if { $error } {
104 puts "FAIL Test crashed!"
105}
106
107end
108