# servers.)
:cl1 mode %channel% +D-D
:cl1 mode %channel%
-:cl1 expect %srv1-name% 324 %cl1-nick% %channel% \\+.*d
+:cl1 expect %srv1-name% 324 %channel% \\+.*d
# Make sure that client 1 does see the -d when client 2 quits
:cl2 wait cl1
-:cl2 part %channel% leaving
:cl1 expect %hidden-srv% mode %channel% -d
+:cl2 part %channel%
:cl1 quit done
# Check that we get local privileges properly.
:cl1 wait cl2,cl3
:cl1 raw :privs %cl1-nick%
-:cl1 expect %srv1-name% 270 %cl1-nick% %cl1-nick% :CHAN_LIMIT
+:cl1 expect %srv1-name% 270 %cl1-nick% :CHAN_LIMIT
:cl1 raw :privs %cl2-nick%
-:cl1 expect %srv1-name% 270 %cl1-nick% %cl2-nick% :CHAN_LIMIT
+:cl1 expect %srv1-name% 270 %cl2-nick% :CHAN_LIMIT
# Bug 1674539 is that remote /privs do not get any response.
# Testing shows that the problem only shows up with a hub between.
:cl1 raw :privs %cl3-nick%
-:cl1 expect %srv2-name% 270 %cl1-nick% %cl3-nick% :CHAN_LIMIT
+:cl1 expect %srv2-name% 270 %cl3-nick% :CHAN_LIMIT
# Synchronize everything
sync cl1,cl2,cl3
--- /dev/null
+define srv1 localhost:7601
+define srv1-name irc.example.net
+define hidden-srv *.undernet.org
+define channel #random-channel
+define cl1-nick Ch4n0pm4n
+
+# Connect a client and join it to the test channel.
+connect cl1 %cl1-nick% op3rm4n %srv1% :Some Chanop
+:cl1 join %channel%
+
+# Issue a variety of bans, all of which should be accepted.
+:cl1 mode %channel% +b *!*@1.0.0.0/16
+:cl1 mode %channel% +b *!*@1.0.0.*
+:cl1 mode %channel% +b *!*@*.example.com
+:cl1 mode %channel% +b *!foo@*.example.org
+:cl1 mode %channel% +b *!*@*.bar.example.*
+
+# Check the modes on the channel.
+:cl1 mode %channel% +b
+# These regexps make my eyes bleed almost enough to add a load of code to test-driver.pl.
+# There's another test-driver problem here, too: one "expect" works fine, but a second
+# one never sees the second numeric response from the server.
+:cl1 expect %srv1-name% 367 %channel% \\*!\\*@\\*\\.bar\\.example\\.* %cl1-nick% \\d+
+
+# Check that a more-encompassing ban removes the old bans.
+:cl1 mode %channel% +b *!*@1.0.*
+:cl1 expect %cl1-nick% mode %channel% -bb\\+b \\*!\\*@1\\.0\\.0\\.\\* \\*!\\*@1\\.0\\.0\\.0/16 \\*!\\*@1\\.0\\.\\*
+
+# Check that a narrower ban cannot be added.
+# Somewhat sadly, the first command gets no response at all.
+:cl1 mode %channel% +b *!*@1.0.0.1
+:cl1 mode %channel% +b
+:cl1 expect %srv1-name% 367 %channel% \\*!\\*@1\\.0\\.\\* %cl1-nick% \\d+
+
+# Can we remove a broader ban and add a narrow ban at the same time?
+# This was the core of the bug report (SF#1840011).
+:cl1 mode %channel% -b+b *!*@1.0.* *!*@1.0.0.1
+:cl1 expect %cl1-nick% mode %channel% -b\\+b \\*!\\*@1\\.0\\.\\* \\*!\\*@1\\.0\\.0\\.1
+:cl1 quit done
my $expect = $client->{expect}->[0];
my $mismatch;
$args = $args->[2]; # ->[1] is the entire string, ->[2] is split
- for (my $x=2; ($x<=$#$expect) and ($x<=$#$args) and not $mismatch; $x++) {
- if ($args->[$x] !~ /$expect->[$x]/i) {
+ for (my $x=0; ($x+2<=$#$expect) and ($x<=$#$args) and not $mismatch; $x++) {
+ my $expectation = $expect->[$x+2];
+ if ($args->[$x] !~ /$expectation/i) {
$mismatch = 1;
- print "Mismatch in arg $x: $args->[$x] !~ $expect->[$x]\n";
+ print "Mismatch in arg $x: $args->[$x] !~ $expectation\n";
}
- # $mismatch = 1 unless $args->[$x] =~ /$expect->[$x]/i;
}
unexpect($kernel, $session, $client) unless $mismatch;
}
my $expected = $client->{expect}->[0];
# check sender
- if ($expected->[0] =~ /\*(.+)/) {
- # we expect *sessionname, so look up session's current nick
- my $exp = $1;
- $sender =~ /^(.+)!/;
- return 0 if lc($heap->{clients}->{$exp}->{nick}) ne lc($1);
- } elsif ($expected->[0] =~ /^:?(.+!.+)/) {
- # expect :nick!user@host, so compare whole thing
- return 0 if lc($1) ne lc($sender);
- } else {
- # we only expect :nick, so compare that part
- $sender =~ /^:?(.+)!/;
- return 0 if lc($expected->[0]) ne lc($1);
- }
+ return 0 unless $sender =~ /^:?\Q$expected->[0]\E/i;
# compare text
- return 0 if lc($text) !~ /$expected->[2]/i;
+ return 0 unless $text =~ /$expected->[2]/i;
# drop expectation of event
unexpect($kernel, $session, $client);