1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-07-01 02:53:53 +00:00

Implement feature request #77: Support IRCv3 capability negotiation during registration

This commit is contained in:
Stefano 2022-03-06 23:20:06 +01:00 committed by Alex Bee
parent b1565dba18
commit 54099b85a3
5 changed files with 268 additions and 14 deletions

View file

@ -456,3 +456,54 @@ func Test671(t *testing.T) {
s.st.EXPECT().GetNick("user2").Return(nil)
c.h_671(ParseLine(":irc.server.org 671 test user2 :some ignored text"))
}
func TestCap(t *testing.T) {
c, s := setUp(t)
defer s.tearDown()
c.Config().EnableCapabilityNegotiation = true
c.Config().Capabilites = []string{"cap1", "cap2", "cap3", "cap4"}
c.h_REGISTER(&Line{Cmd: REGISTER})
s.nc.Expect("CAP LS")
s.nc.Expect("NICK test")
s.nc.Expect("USER test 12 * :Testing IRC")
// Ensure that capabilities not supported by the server are not requested
s.nc.Send("CAP * LS :cap2 cap4")
s.nc.Expect("CAP REQ :cap2 cap4")
s.nc.Send("CAP * ACK :cap2 cap4")
s.nc.Expect("CAP END")
for _, cap := range []string{"cap2", "cap4"} {
if !c.SupportsCapability(cap) {
t.Fail()
}
if !c.HasCapability(cap) {
t.Fail()
}
}
for _, cap := range []string{"cap1", "cap3"} {
if c.HasCapability(cap) {
t.Fail()
}
}
// test disable capability after registration
s.c.Cap("REQ", "-cap4")
s.nc.Expect("CAP REQ :-cap4")
s.nc.Send("CAP * ACK :-cap4")
s.nc.Expect("CAP END")
if !c.HasCapability("cap2") {
t.Fail()
}
if c.HasCapability("cap4") {
t.Fail()
}
}