From cb53fd6a83c364695f41bacc97f46707d064356f Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sun, 6 Aug 2017 16:20:03 +0100 Subject: [PATCH] tests: send1: add tag tests to all functions --- tests/send1.c | 2080 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2080 insertions(+) diff --git a/tests/send1.c b/tests/send1.c index 9823bc90..e80aeccb 100644 --- a/tests/send1.c +++ b/tests/send1.c @@ -219,6 +219,30 @@ static void sendto_one1(void) standard_free(); } +static void sendto_one1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_one(local_chan_o, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_o, MSG); + + sendto_one(local_chan_ov, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one(local_chan_v, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, local_chan_v, MSG); + + sendto_one(local_chan_p, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, local_chan_p, MSG); + + standard_free(); +} + static void sendto_one_prefix1(void) { standard_init(); @@ -267,6 +291,84 @@ static void sendto_one_prefix1(void) standard_free(); } +static void sendto_one_prefix1__tags(void) +{ + standard_init(); + + strcpy(user->user->suser, "test"); + strcpy(remote->user->suser, "rtest"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_one_prefix(user, &me, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " TEST " TEST_NICK " :Hello World!" CRLF, user, MSG); + + sendto_one_prefix(user, user, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_NICK " TEST " TEST_NICK " :Hello World!" CRLF, user, MSG); + + sendto_one_prefix(user, remote, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK " TEST " TEST_NICK " :Hello World!" CRLF, user, MSG); + + sendto_one_prefix(user, server, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_SERVER_NAME " TEST " TEST_NICK " :Hello World!" CRLF, user, MSG); + + + sendto_one_prefix(local_chan_o, &me, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " TEST LChanOp :Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_prefix(local_chan_o, user, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :" TEST_NICK " TEST LChanOp :Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_prefix(local_chan_o, remote, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME ";account=rtest :" TEST_REMOTE_NICK " TEST LChanOp :Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_prefix(local_chan_o, server, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " TEST LChanOp :Hello World!" CRLF, local_chan_o, MSG); + + + sendto_one_prefix(local_chan_ov, &me, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " TEST LChanOpVoice :Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_prefix(local_chan_ov, user, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_NICK " TEST LChanOpVoice :Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_prefix(local_chan_ov, remote, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_REMOTE_NICK " TEST LChanOpVoice :Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_prefix(local_chan_ov, server, "TEST", ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " TEST LChanOpVoice :Hello World!" CRLF, local_chan_ov, MSG); + + + sendto_one_prefix(local_chan_v, &me, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " TEST LChanVoice :Hello World!" CRLF, local_chan_v, MSG); + + sendto_one_prefix(local_chan_v, user, "TEST", ":Hello %s!", "World"); + is_client_sendq("@account=test :" TEST_NICK " TEST LChanVoice :Hello World!" CRLF, local_chan_v, MSG); + + sendto_one_prefix(local_chan_v, remote, "TEST", ":Hello %s!", "World"); + is_client_sendq("@account=rtest :" TEST_REMOTE_NICK " TEST LChanVoice :Hello World!" CRLF, local_chan_v, MSG); + + sendto_one_prefix(local_chan_v, server, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_SERVER_NAME " TEST LChanVoice :Hello World!" CRLF, local_chan_v, MSG); + + + sendto_one_prefix(local_chan_p, &me, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " TEST LChanPeon :Hello World!" CRLF, local_chan_p, MSG); + + sendto_one_prefix(local_chan_p, user, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_NICK " TEST LChanPeon :Hello World!" CRLF, local_chan_p, MSG); + + sendto_one_prefix(local_chan_p, remote, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK " TEST LChanPeon :Hello World!" CRLF, local_chan_p, MSG); + + sendto_one_prefix(local_chan_p, server, "TEST", ":Hello %s!", "World"); + is_client_sendq(":" TEST_SERVER_NAME " TEST LChanPeon :Hello World!" CRLF, local_chan_p, MSG); + + standard_free(); +} + static void sendto_one_notice1(void) { standard_init(); @@ -293,6 +395,41 @@ static void sendto_one_notice1(void) standard_free(); } +static void sendto_one_notice1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_one_notice(local_chan_o, ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE LChanOp :Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_notice(local_chan_ov, ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE LChanOpVoice :Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_notice(local_chan_v, ":Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " NOTICE LChanVoice :Hello World!" CRLF, local_chan_v, MSG); + + // Unregistered + local_chan_o->name[0] = '\0'; + local_chan_ov->name[0] = '\0'; + local_chan_v->name[0] = '\0'; + + sendto_one_notice(local_chan_o, ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_notice(local_chan_ov, ":Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_notice(local_chan_v, ":Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :Hello World!" CRLF, local_chan_v, MSG); + + standard_free(); +} + static void sendto_one_numeric1(void) { standard_init(); @@ -325,6 +462,41 @@ static void sendto_one_numeric1(void) standard_free(); } +static void sendto_one_numeric1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_one_numeric(local_chan_o, 1, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " 001 LChanOp Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_numeric(local_chan_ov, 1, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " 001 LChanOpVoice Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_numeric(local_chan_v, 1, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " 001 LChanVoice Hello World!" CRLF, local_chan_v, MSG); + + // Unregistered + local_chan_o->name[0] = '\0'; + local_chan_ov->name[0] = '\0'; + local_chan_v->name[0] = '\0'; + + sendto_one_numeric(local_chan_o, 1, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " 001 * Hello World!" CRLF, local_chan_o, MSG); + + sendto_one_numeric(local_chan_ov, 1, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " 001 * Hello World!" CRLF, local_chan_ov, MSG); + + sendto_one_numeric(local_chan_v, 1, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " 001 * Hello World!" CRLF, local_chan_v, MSG); + + standard_free(); +} + static void sendto_server1(void) { standard_init(); @@ -411,6 +583,97 @@ static void sendto_server1(void) standard_free(); } +static void sendto_server1__tags(void) +{ + standard_init(); + + // TODO test capabilities + + strcpy(user->user->suser, "test"); + strcpy(remote->user->suser, "rtest"); + strcpy(remote2->user->suser, "r2test"); + strcpy(remote3->user->suser, "r3test"); + + // Local + sendto_server(NULL, channel, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(NULL, lchannel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(NULL, NULL, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(user, channel, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(user, lchannel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(user, NULL, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + // Remote + sendto_server(remote, channel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(remote, lchannel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(remote, NULL, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(remote2, channel, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(remote2, lchannel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(remote2, NULL, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq("Hello World!" CRLF, server3, MSG); + + sendto_server(remote3, channel, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(remote3, lchannel, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_server(remote3, NULL, 0, 0, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, server, MSG); + is_client_sendq("Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + standard_free(); +} + static void sendto_channel_flags__local__all_members(void) { standard_init(); @@ -950,6 +1213,77 @@ static void sendto_channel_opmod__local(void) is_client_sendq_empty(server2, "No users to receive message; " MSG); } +static void sendto_channel_opmod__local__tags(void) +{ + standard_init(); + + strcpy(local_chan_p->user->suser, "test"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + + // This function does not support TS5... + standard_ids(); + + // Without CAP_CHW | CAP_EOPMOD + standard_server_caps(0, CAP_CHW | CAP_EOPMOD); + + sendto_channel_opmod(local_chan_p, local_chan_p, channel, "TEST", "Hello World!"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Message source; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq_empty(server, "No users to receive message; " MSG); + is_client_sendq_empty(server2, "No users to receive message; " MSG); + + // With CAP_CHW, without CAP_EOPMOD + standard_server_caps(CAP_CHW, CAP_EOPMOD); + + sendto_channel_opmod(local_chan_p, local_chan_p, channel, "TEST", "Hello World!"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Message source; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE @" TEST_CHANNEL " : Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "No users to receive message; " MSG); + + // Moderated channel + channel->mode.mode |= MODE_MODERATED; + + local_chan_o->localClient->caps &= ~CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps &= ~CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_ov->localClient->caps &= ~CAP_SERVER_TIME; + + sendto_channel_opmod(local_chan_p, local_chan_p, channel, "TEST", "Hello World!"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq(":LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@account=test :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Message source; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_ME_ID "90004 TEST " TEST_CHANNEL " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "No users to receive message; " MSG); + + // With CAP_CHW | CAP_EOPMOD + channel->mode.mode &= ~MODE_MODERATED; + standard_server_caps(CAP_CHW | CAP_EOPMOD, 0); + + sendto_channel_opmod(local_chan_p, local_chan_p, channel, "TEST", "Hello World!"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq(":LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@account=test :LChanPeon" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Message source; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_ME_ID "90004 TEST =" TEST_CHANNEL " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "No users to receive message; " MSG); +} + static void sendto_channel_opmod__remote(void) { standard_init(); @@ -1005,6 +1339,71 @@ static void sendto_channel_opmod__remote(void) standard_free(); } +static void sendto_channel_opmod__remote__tags(void) +{ + standard_init(); + + strcpy(remote2_chan_d->user->suser, "test"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + + // This function does not support TS5... + standard_ids(); + + // Without CAP_CHW | CAP_EOPMOD + standard_server_caps(0, CAP_CHW | CAP_EOPMOD); + + sendto_channel_opmod(server2, remote2_chan_d, channel, "TEST", "Hello World!"); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq_empty(server, "Message source; " MSG); + is_client_sendq_empty(server2, "No users to receive message; " MSG); + + // With CAP_CHW, without CAP_EOPMOD + standard_server_caps(CAP_CHW, CAP_EOPMOD); + + sendto_channel_opmod(server2, remote2_chan_d, channel, "TEST", "Hello World!"); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_SERVER2_ID " NOTICE @" TEST_CHANNEL " : Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "Message source; " MSG); + + // Moderated channel + channel->mode.mode |= MODE_MODERATED; + + local_chan_o->localClient->caps &= ~CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps &= ~CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_ov->localClient->caps &= ~CAP_SERVER_TIME; + + sendto_channel_opmod(server2, remote2_chan_d, channel, "TEST", "Hello World!"); + is_client_sendq(":R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@account=test :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_SERVER2_ID "90205 TEST " TEST_CHANNEL " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "Message source; " MSG); + + // With CAP_CHW | CAP_EOPMOD + channel->mode.mode &= ~MODE_MODERATED; + standard_server_caps(CAP_CHW | CAP_EOPMOD, 0); + + sendto_channel_opmod(server2, remote2_chan_d, channel, "TEST", "Hello World!"); + is_client_sendq(":R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@account=test :R2ChanDeaf" TEST_ID_SUFFIX " TEST " TEST_CHANNEL " :Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_d, "Deaf; " MSG); + is_client_sendq(":" TEST_SERVER2_ID "90205 TEST =" TEST_CHANNEL " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, "Message source; " MSG); + + standard_free(); +} + static void sendto_channel_local1(void) { standard_init(); @@ -1089,6 +1488,118 @@ static void sendto_channel_local1(void) standard_free(); } +static void sendto_channel_local1__tags(void) +{ + standard_init(); + + strcpy(user->user->suser, "test"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_channel_local(user, ALL_MEMBERS, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local(user, CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +v; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local(user, CHFL_CHANOP, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local(user, CHFL_CHANOP | CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o/+v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o/+v; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o/+v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o/+v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local(user, ONLY_OPERS, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not an oper; " MSG); + is_client_sendq_empty(local_chan_o, "Not an oper; " MSG); + is_client_sendq_empty(local_chan_ov, "Not an oper; " MSG); + is_client_sendq_empty(local_chan_v, "Not an oper; " MSG); + is_client_sendq_empty(local_chan_p, "Not an oper; " MSG); + is_client_sendq_empty(local_chan_d, "Not an oper; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + struct Client *oper1 = make_local_person_nick("oper1"); + struct Client *oper2 = make_local_person_nick("oper2"); + + make_local_person_oper(oper1); + make_local_person_oper(oper2); + + oper2->umodes |= UMODE_ADMIN; + + add_user_to_channel(lchannel, oper1, CHFL_PEON); + add_user_to_channel(lchannel, oper2, CHFL_PEON); + + oper1->localClient->caps |= CAP_ACCOUNT_TAG; + oper2->localClient->caps |= CAP_SERVER_TIME; + + sendto_channel_local(user, ALL_MEMBERS, lchannel, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, user, "On channel; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, oper1, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, oper2, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_channel_local(user, ONLY_OPERS, lchannel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not an oper; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, oper1, "Is an oper; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, oper2, "Is an oper; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + oper1->localClient->caps &= ~CAP_ACCOUNT_TAG; + oper2->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_channel_local(user, ALL_MEMBERS, lchannel, "Hello %s!", "World"); + is_client_sendq("Hello World!" CRLF, user, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, oper1, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, oper2, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_channel_local(user, ONLY_OPERS, lchannel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not an oper; " MSG); + is_client_sendq("Hello World!" CRLF, oper1, "Is an oper; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, oper2, "Is an oper; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + standard_free(); +} + static void sendto_channel_local_with_capability1(void) { standard_init(); @@ -1219,6 +1730,142 @@ static void sendto_channel_local_with_capability1(void) standard_free(); } +static void sendto_channel_local_with_capability1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_INVITE_NOTIFY; + local_chan_v->localClient->caps |= CAP_INVITE_NOTIFY; + + strcpy(user->user->suser, "test"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_channel_local_with_capability(user, ALL_MEMBERS, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, ALL_MEMBERS, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, ALL_MEMBERS, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_VOICE, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +v; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_VOICE, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +v; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Not +v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_VOICE, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +v; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP | CHFL_VOICE, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o/+v; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP | CHFL_VOICE, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o/+v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o/+v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability(user, CHFL_CHANOP | CHFL_VOICE, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Has +o/+v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o/+v; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o/+v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o/+v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_channel_local_with_capability_butone1(void) { standard_init(); @@ -1319,6 +1966,113 @@ static void sendto_channel_local_with_capability_butone1(void) standard_free(); } +static void sendto_channel_local_with_capability_butone1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_INVITE_NOTIFY; + local_chan_v->localClient->caps |= CAP_INVITE_NOTIFY; + + strcpy(local_chan_o->user->suser, "test_o"); + strcpy(local_chan_p->user->suser, "test_p"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_channel_local_with_capability_butone(NULL, ALL_MEMBERS, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(NULL, ALL_MEMBERS, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(NULL, ALL_MEMBERS, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_o, ALL_MEMBERS, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_o, ALL_MEMBERS, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_o, ALL_MEMBERS, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_p, ALL_MEMBERS, CAP_INVITE_NOTIFY, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_p Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test_p Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_p, ALL_MEMBERS, 0, CAP_INVITE_NOTIFY, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_with_capability_butone(local_chan_p, ALL_MEMBERS, 0, 0, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_p Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test_p Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_channel_local_butone1(void) { standard_init(); @@ -1416,6 +2170,112 @@ static void sendto_channel_local_butone1(void) standard_free(); } +static void sendto_channel_local_butone1__tags(void) +{ + standard_init(); + + strcpy(local_chan_o->user->suser, "test_o"); + strcpy(local_chan_ov->user->suser, "test_ov"); + strcpy(local_chan_v->user->suser, "test_v"); + strcpy(local_chan_p->user->suser, "test_p"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_channel_local_butone(NULL, ALL_MEMBERS, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_o, ALL_MEMBERS, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_p, ALL_MEMBERS, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_p Hello World!" CRLF, local_chan_o, "On channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On channel; " MSG); + is_client_sendq("@account=test_p Hello World!" CRLF, local_chan_v, "On channel; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_ov, CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq_empty(local_chan_ov, "Is the one (neo); " MSG); + is_client_sendq("@account=test_ov Hello World!" CRLF, local_chan_v, "Has +v; " MSG); + is_client_sendq_empty(local_chan_p, "Not +v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_p, CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not +v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +v; " MSG); + is_client_sendq("@account=test_p Hello World!" CRLF, local_chan_v, "Has +v; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_o, CHFL_CHANOP, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Not +o; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_p, CHFL_CHANOP, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_p Hello World!" CRLF, local_chan_o, "Has +o; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o; " MSG); + is_client_sendq_empty(local_chan_v, "Not +o; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_v, CHFL_CHANOP | CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_v Hello World!" CRLF, local_chan_o, "Has +o/+v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_v, "Is the one (neo); " MSG); + is_client_sendq_empty(local_chan_p, "Not +o/+v; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o/+v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_channel_local_butone(local_chan_p, CHFL_CHANOP | CHFL_VOICE, channel, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_p Hello World!" CRLF, local_chan_o, "Has +o/+v; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Has +o/+v; " MSG); + is_client_sendq("@account=test_p Hello World!" CRLF, local_chan_v, "Has +o/+v; " MSG); + is_client_sendq_empty(local_chan_p, "Is the one (neo); " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Has +o/+v; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_common_channels_local1(void) { standard_init(); @@ -1521,6 +2381,153 @@ static void sendto_common_channels_local1(void) standard_free(); } +static void sendto_common_channels_local1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_INVITE_NOTIFY; + local_chan_v->localClient->caps |= CAP_INVITE_NOTIFY; + + strcpy(local_chan_o->user->suser, "test_o"); + strcpy(local_no_chan->user->suser, "test_n"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_common_channels_local(local_chan_o, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_o Hello World!" CRLF, local_chan_o, "Has cap; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_chan_o, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Has cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_chan_o, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_o Hello World!" CRLF, local_chan_o, "No cap checking; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On common channel; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "On common channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On common channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps |= CAP_SERVER_TIME; + + sendto_common_channels_local(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_no_chan, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_no_chan, "No cap checking; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps |= CAP_INVITE_NOTIFY; + local_no_chan->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_common_channels_local(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_n Hello World!" CRLF, local_no_chan, "Has cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Has cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test_n Hello World!" CRLF, local_no_chan, "No cap checking; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps &= ~CAP_SERVER_TIME; + + sendto_common_channels_local(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@account=test_n Hello World!" CRLF, local_no_chan, "Has cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Has cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq("@account=test_n Hello World!" CRLF, local_no_chan, "No cap checking; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_common_channels_local_butone1(void) { standard_init(); @@ -1626,6 +2633,153 @@ static void sendto_common_channels_local_butone1(void) standard_free(); } +static void sendto_common_channels_local_butone1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_INVITE_NOTIFY; + local_chan_v->localClient->caps |= CAP_INVITE_NOTIFY; + + strcpy(local_chan_o->user->suser, "test_o"); + strcpy(local_no_chan->user->suser, "test_n"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_common_channels_local_butone(local_chan_o, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_chan_o, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_v, "Has cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_chan_o, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Is the one (neo); " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "On common channel; " MSG); + is_client_sendq("@account=test_o Hello World!" CRLF, local_chan_v, "On common channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_p, "On common channel; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_d, "On common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Not on common channel; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps |= CAP_SERVER_TIME; + + sendto_common_channels_local_butone(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps |= CAP_INVITE_NOTIFY; + local_no_chan->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_common_channels_local_butone(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + local_no_chan->localClient->caps &= ~CAP_SERVER_TIME; + + sendto_common_channels_local_butone(local_no_chan, CAP_INVITE_NOTIFY, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_common_channels_local_butone(local_no_chan, 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_o, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_ov, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_p, "Not on common channel; " MSG); + is_client_sendq_empty(local_chan_d, "Not on common channel; " MSG); + is_client_sendq_empty(local_no_chan, "Is the one (neo); " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_match_butone__host(void) { standard_init(); @@ -1726,6 +2880,113 @@ static void sendto_match_butone__host(void) standard_free(); } +static void sendto_match_butone__host__tags(void) +{ + standard_init(); + + strcpy(user->user->suser, "test"); + strcpy(remote->user->suser, "rtest"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + // This function does not support TS5... + standard_ids(); + + // Local + sendto_match_butone(NULL, user, "*.test", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Host matches; " MSG); + is_client_sendq("@account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Host matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Host matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Host matches; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(NULL, user, "*.invalid", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, user, "*.test", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Host matches; " MSG); + is_client_sendq("@account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Host matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Host matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Host matches; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, user, "*.invalid", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + // Remote + sendto_match_butone(NULL, remote, "*.test", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Host matches; " MSG); + is_client_sendq("@account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Host matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Host matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Host matches; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(NULL, remote, "*.invalid", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, remote, "*.test", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Host matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Host matches; " MSG); + is_client_sendq("@account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Host matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Host matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Host matches; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, remote, "*.invalid", MATCH_HOST, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + standard_free(); +} + static void sendto_match_butone__server(void) { standard_init(); @@ -1826,6 +3087,113 @@ static void sendto_match_butone__server(void) standard_free(); } +static void sendto_match_butone__server__tags(void) +{ + standard_init(); + + strcpy(user->user->suser, "test"); + strcpy(remote->user->suser, "rtest"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + // This function does not support TS5... + standard_ids(); + + // Local + sendto_match_butone(NULL, user, "me.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Server matches; " MSG); + is_client_sendq("@account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Server matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Server matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Server matches; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(NULL, user, "example.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, user, "me.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Server matches; " MSG); + is_client_sendq("@account=test :" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Server matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Server matches; " MSG); + is_client_sendq(":" TEST_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Server matches; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, user, "example.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + // Remote + sendto_match_butone(NULL, remote, "me.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Server matches; " MSG); + is_client_sendq("@account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Server matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Server matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Server matches; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(NULL, remote, "example.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, remote, "me.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, user, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_o, "Server matches; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_ov, "Server matches; " MSG); + is_client_sendq("@account=rtest :" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_v, "Server matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_p, "Server matches; " MSG); + is_client_sendq(":" TEST_REMOTE_NICK TEST_ID_SUFFIX " TEST Hello World!" CRLF, local_chan_d, "Server matches; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + sendto_match_butone(server, remote, "example.*", MATCH_SERVER, "TEST Hello %s!", "World"); + is_client_sendq_empty(user, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_o, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_ov, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_v, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_p, "Host doesn't match; " MSG); + is_client_sendq_empty(local_chan_d, "Host doesn't match; " MSG); + is_client_sendq_empty(server, "Is the one (neo); " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server2, "Is a server; " MSG); + is_client_sendq(":" TEST_REMOTE_ID " TEST Hello World!" CRLF, server3, "Is a server; " MSG); + + standard_free(); +} + static void sendto_local_clients_with_capability1(void) { standard_init(); @@ -1846,6 +3214,37 @@ static void sendto_local_clients_with_capability1(void) standard_free(); } +static void sendto_local_clients_with_capability1__tags(void) +{ + standard_init(); + + local_chan_o->localClient->caps |= CAP_INVITE_NOTIFY; + local_chan_v->localClient->caps |= CAP_INVITE_NOTIFY; + + strcpy(user->user->suser, "test"); + strcpy(local_chan_o->user->suser, "test_o"); + strcpy(local_chan_ov->user->suser, "test_ov"); + strcpy(local_chan_v->user->suser, "test_v"); + strcpy(local_chan_p->user->suser, "test_p"); + strcpy(local_chan_d->user->suser, "test_d"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + sendto_local_clients_with_capability(CAP_INVITE_NOTIFY, "Hello %s!", "World"); + is_client_sendq_empty(user, "Doesn't have cap; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_o, "Has cap; " MSG); + is_client_sendq_empty(local_chan_ov, "Doesn't have cap; " MSG); + is_client_sendq("Hello World!" CRLF, local_chan_v, "Has cap; " MSG); + is_client_sendq_empty(local_chan_p, "Doesn't have cap; " MSG); + is_client_sendq_empty(local_chan_d, "Doesn't have cap; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_monitor1(void) { struct monitor *monptr; @@ -1871,6 +3270,52 @@ static void sendto_monitor1(void) standard_free(); } +static void sendto_monitor1__tags(void) +{ + struct monitor *monptr; + + standard_init(); + + strcpy(user->user->suser, "test"); + local_chan_o->localClient->caps |= CAP_ACCOUNT_TAG; + local_chan_o->localClient->caps |= CAP_SERVER_TIME; + local_chan_ov->localClient->caps |= CAP_SERVER_TIME; + local_chan_v->localClient->caps |= CAP_ACCOUNT_TAG; + + monptr = find_monitor(TEST_NICK, 1); + rb_dlinkAddAlloc(local_chan_o, &monptr->users); + rb_dlinkAddAlloc(monptr, &local_chan_o->localClient->monitor_list); + rb_dlinkAddAlloc(local_chan_v, &monptr->users); + rb_dlinkAddAlloc(monptr, &local_chan_v->localClient->monitor_list); + + sendto_monitor(user, monptr, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not monitoring; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test Hello World!" CRLF, local_chan_o, "Monitoring; " MSG); + is_client_sendq_empty(local_chan_ov, "Not monitoring; " MSG); + is_client_sendq("@account=test Hello World!" CRLF, local_chan_v, "Monitoring; " MSG); + is_client_sendq_empty(local_chan_p, "Not monitoring; " MSG); + is_client_sendq_empty(local_chan_d, "Not monitoring; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + rb_dlinkAddAlloc(local_chan_ov, &monptr->users); + rb_dlinkAddAlloc(monptr, &local_chan_ov->localClient->monitor_list); + clear_monitor(local_chan_o); + clear_monitor(local_chan_v); + + sendto_monitor(user, monptr, "Hello %s!", "World"); + is_client_sendq_empty(user, "Not monitoring; " MSG); + is_client_sendq_empty(local_chan_o, "Not monitoring; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " Hello World!" CRLF, local_chan_ov, "Monitoring; " MSG); + is_client_sendq_empty(local_chan_v, "Not monitoring; " MSG); + is_client_sendq_empty(local_chan_p, "Not monitoring; " MSG); + is_client_sendq_empty(local_chan_d, "Not monitoring; " MSG); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void sendto_anywhere1(void) { standard_init(); @@ -2288,6 +3733,152 @@ static void sendto_match_servs1(void) standard_free(); } +static void sendto_match_servs1__tags(void) +{ + standard_init(); + + strcpy(user->user->suser, "test"); + strcpy(remote->user->suser, "rtest"); + user->localClient->caps |= CAP_ACCOUNT_TAG; + user->localClient->caps |= CAP_SERVER_TIME; + + server->localClient->caps = CAP_ENCAP; + server2->localClient->caps = CAP_ENCAP; + server2->localClient->caps |= CAP_KNOCK; + server3->localClient->caps = CAP_BAN; + + // This function does not support TS5... + standard_ids(); + + // Match all + sendto_match_servs(&me, "*.test", 0, 0, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(user, "*.test", 0, 0, "Hello %s!", "World"); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(remote, "*.test", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_REMOTE_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_REMOTE_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(server, "*.test", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_SERVER_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_SERVER_ID " Hello World!" CRLF, server3, MSG); + + // Match all, CAP_ENCAP but not CAP_KNOCK + sendto_match_servs(&me, "*.test", CAP_ENCAP, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(user, "*.test", CAP_ENCAP, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(remote, "*.test", CAP_ENCAP, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(server, "*.test", CAP_ENCAP, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + // Match all, but not CAP_BAN + sendto_match_servs(&me, "*.test", 0, CAP_BAN, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(user, "*.test", 0, CAP_BAN, "Hello %s!", "World"); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(remote, "*.test", 0, CAP_BAN, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_REMOTE_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(server, "*.test", 0, CAP_BAN, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_SERVER_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + // Match all, CAP_BAN but not CAP_KNOCK + sendto_match_servs(&me, "*.test", CAP_BAN, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(user, "*.test", CAP_BAN, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(remote, "*.test", CAP_BAN, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq(":" TEST_REMOTE_ID " Hello World!" CRLF, server3, MSG); + + sendto_match_servs(server, "*.test", CAP_BAN, CAP_KNOCK, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq(":" TEST_SERVER_ID " Hello World!" CRLF, server3, MSG); + + // Match all, CAP_KNOCK + sendto_match_servs(&me, "*.test", CAP_KNOCK, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_ME_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(user, "*.test", CAP_KNOCK, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(remote, "*.test", CAP_KNOCK, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_REMOTE_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(server, "*.test", CAP_KNOCK, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq(":" TEST_SERVER_ID " Hello World!" CRLF, server2, MSG); + is_client_sendq_empty(server3, MSG); + + // Match none + sendto_match_servs(&me, "*.invalid", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(user, "*.invalid", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(remote, "*.invalid", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + sendto_match_servs(server, "*.invalid", 0, 0, "Hello %s!", "World"); + is_client_sendq_empty(server, MSG); + is_client_sendq_empty(server2, MSG); + is_client_sendq_empty(server3, MSG); + + standard_free(); +} + static void sendto_realops_snomask1(void) { struct Client *oper1 = make_local_person_nick("oper1"); @@ -2505,6 +4096,233 @@ static void sendto_realops_snomask1(void) standard_free(); } +static void sendto_realops_snomask1__tags(void) +{ + struct Client *oper1 = make_local_person_nick("oper1"); + struct Client *oper2 = make_local_person_nick("oper2"); + struct Client *oper3 = make_local_person_nick("oper3"); + struct Client *oper4 = make_local_person_nick("oper4"); + + standard_init(); + + strcpy(oper1->user->suser, "test1"); + strcpy(oper2->user->suser, "test2"); + strcpy(oper3->user->suser, "test3"); + strcpy(oper4->user->suser, "test4"); + + oper1->localClient->caps |= CAP_ACCOUNT_TAG; + oper1->localClient->caps |= CAP_SERVER_TIME; + oper2->localClient->caps |= CAP_SERVER_TIME; + oper3->localClient->caps |= CAP_ACCOUNT_TAG; + + make_local_person_oper(oper1); + make_local_person_oper(oper2); + make_local_person_oper(oper3); + make_local_person_oper(oper4); + + oper1->snomask = SNO_BOTS | SNO_SKILL; + oper2->snomask = SNO_GENERAL | SNO_REJ; + oper3->snomask = SNO_BOTS | SNO_SKILL; + oper4->snomask = SNO_GENERAL | SNO_REJ; + + oper3->localClient->privset = privilegeset_get("admin"); + oper4->localClient->privset = privilegeset_get("admin"); + + server->localClient->caps = CAP_ENCAP | CAP_TS6; + server2->localClient->caps = 0; + + ConfigFileEntry.global_snotices = 0; + remote_rehash_oper_p = NULL; + + sendto_realops_snomask(SNO_BOTS, L_ALL, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_OPER, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ALL, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_OPER, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq_empty(server, MSG); + + remote_rehash_oper_p = remote; + + sendto_realops_snomask(SNO_BOTS, L_ALL, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_OPER, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ALL, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_OPER, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE " TEST_REMOTE_NICK " :*** Notice -- Hello World!" CRLF, server, MSG); + + standard_ids(); + + sendto_realops_snomask(SNO_BOTS, L_ALL, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_BOTS, L_OPER, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ALL, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_OPER, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq(":" TEST_ME_ID " NOTICE " TEST_REMOTE_ID " :*** Notice -- Hello World!" CRLF, server, MSG); + + // This feature does not support TS5... + ConfigFileEntry.global_snotices = 1; + + sendto_realops_snomask(SNO_BOTS, L_NETWIDE | L_ALL, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE b :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_realops_snomask(SNO_BOTS, L_NETWIDE | L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE b :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_realops_snomask(SNO_BOTS, L_NETWIDE | L_OPER, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE b :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE | L_ALL, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE s :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE | L_ADMIN, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE s :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE | L_OPER, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq(":" TEST_ME_ID " ENCAP * SNOTE s :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + remove_local_person(oper1); + remove_local_person(oper2); + remove_local_person(oper3); + remove_local_person(oper4); + + standard_free(); +} + static void sendto_realops_snomask_from1(void) { struct Client *oper1 = make_local_person_nick("oper1"); @@ -2615,6 +4433,126 @@ static void sendto_realops_snomask_from1(void) remove_local_person(oper4); } +static void sendto_realops_snomask_from1__tags(void) +{ + struct Client *oper1 = make_local_person_nick("oper1"); + struct Client *oper2 = make_local_person_nick("oper2"); + struct Client *oper3 = make_local_person_nick("oper3"); + struct Client *oper4 = make_local_person_nick("oper4"); + + strcpy(oper1->user->suser, "test1"); + strcpy(oper2->user->suser, "test2"); + strcpy(oper3->user->suser, "test3"); + strcpy(oper4->user->suser, "test4"); + + oper1->localClient->caps |= CAP_ACCOUNT_TAG; + oper1->localClient->caps |= CAP_SERVER_TIME; + oper2->localClient->caps |= CAP_SERVER_TIME; + oper3->localClient->caps |= CAP_ACCOUNT_TAG; + + make_local_person_oper(oper1); + make_local_person_oper(oper2); + make_local_person_oper(oper3); + make_local_person_oper(oper4); + + oper1->snomask = SNO_BOTS | SNO_SKILL; + oper2->snomask = SNO_GENERAL | SNO_REJ; + oper3->snomask = SNO_BOTS | SNO_SKILL; + oper4->snomask = SNO_GENERAL | SNO_REJ; + + oper3->localClient->privset = privilegeset_get("admin"); + oper4->localClient->privset = privilegeset_get("admin"); + + sendto_realops_snomask_from(SNO_BOTS, L_ALL, &me, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_BOTS, L_ADMIN, &me, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_BOTS, L_OPER, &me, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_BOTS, L_ALL, server, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_BOTS, L_ADMIN, server, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper3, "Matches mask; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_BOTS, L_OPER, server, "Hello %s!", "World"); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper1, "Matches mask; " MSG); + is_client_sendq_empty(oper2, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper3, "Not an oper; " MSG); + is_client_sendq_empty(oper4, "Doesn't match mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_ALL, &me, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_ADMIN, &me, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_OPER, &me, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_ALL, server, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_ADMIN, server, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper2, "Not an admin; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq(":" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper4, "Matches mask; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_realops_snomask_from(SNO_GENERAL, L_OPER, server, "Hello %s!", "World"); + is_client_sendq_empty(oper1, "Doesn't match mask; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_SERVER_NAME " NOTICE * :*** Notice -- Hello World!" CRLF, oper2, "Matches mask; " MSG); + is_client_sendq_empty(oper3, "Doesn't match mask; " MSG); + is_client_sendq_empty(oper4, "Not an oper; " MSG); + is_client_sendq_empty(server, MSG); + + remove_local_person(oper1); + remove_local_person(oper2); + remove_local_person(oper3); + remove_local_person(oper4); +} + static void sendto_wallops_flags1(void) { struct Client *user1 = make_local_person_nick("user1"); @@ -2670,6 +4608,71 @@ static void sendto_wallops_flags1(void) remove_local_person(oper4); } +static void sendto_wallops_flags1__tags(void) +{ + struct Client *user1 = make_local_person_nick("user1"); + struct Client *user2 = make_local_person_nick("user2"); + struct Client *oper1 = make_local_person_nick("oper1"); + struct Client *oper2 = make_local_person_nick("oper2"); + struct Client *oper3 = make_local_person_nick("oper3"); + struct Client *oper4 = make_local_person_nick("oper4"); + + strcpy(oper1->user->suser, "test1"); + strcpy(oper2->user->suser, "test2"); + strcpy(oper3->user->suser, "test3"); + strcpy(oper4->user->suser, "test4"); + + oper1->localClient->caps |= CAP_ACCOUNT_TAG; + oper1->localClient->caps |= CAP_SERVER_TIME; + oper2->localClient->caps |= CAP_SERVER_TIME; + oper3->localClient->caps |= CAP_ACCOUNT_TAG; + + make_local_person_oper(oper1); + make_local_person_oper(oper2); + make_local_person_oper(oper3); + make_local_person_oper(oper4); + + user1->umodes |= UMODE_WALLOP; + oper1->umodes |= UMODE_WALLOP | UMODE_OPERWALL; + oper2->umodes |= UMODE_WALLOP | UMODE_OPERWALL | UMODE_ADMIN; + oper3->umodes |= UMODE_WALLOP; + oper4->umodes |= UMODE_OPERWALL; + + sendto_wallops_flags(UMODE_WALLOP, oper1, "Test to users"); + is_client_sendq(":oper1" TEST_ID_SUFFIX " WALLOPS :Test to users" CRLF, user1, "User is +w; " MSG); + is_client_sendq_empty(user2, "User is -w; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test1 :oper1" TEST_ID_SUFFIX " WALLOPS :Test to users" CRLF, oper1, "User is +w; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :oper1" TEST_ID_SUFFIX " WALLOPS :Test to users" CRLF, oper2, "User is +w; " MSG); + is_client_sendq("@account=test1 :oper1" TEST_ID_SUFFIX " WALLOPS :Test to users" CRLF, oper3, "User is +w; " MSG); + is_client_sendq_empty(oper4, "User is -w; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_wallops_flags(UMODE_OPERWALL, oper2, "Test to opers"); + is_client_sendq_empty(user1, "Not an oper; " MSG); + is_client_sendq_empty(user2, "Not an oper; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME ";account=test2 :oper2" TEST_ID_SUFFIX " WALLOPS :Test to opers" CRLF, oper1, "Oper is +z; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :oper2" TEST_ID_SUFFIX " WALLOPS :Test to opers" CRLF, oper2, "Oper is +z; " MSG); + is_client_sendq_empty(oper3, "Oper is -z; " MSG); + is_client_sendq(":oper2" TEST_ID_SUFFIX " WALLOPS :Test to opers" CRLF, oper4, "Oper is +z; " MSG); + is_client_sendq_empty(server, MSG); + + sendto_wallops_flags(UMODE_ADMIN, &me, "Test to admins"); + is_client_sendq_empty(user1, "Not an admin; " MSG); + is_client_sendq_empty(user2, "Not an admin; " MSG); + is_client_sendq_empty(oper1, "Not an admin; " MSG); + is_client_sendq("@time=" ADVENTURE_TIME " :" TEST_ME_NAME " WALLOPS :Test to admins" CRLF, oper2, MSG); + is_client_sendq_empty(oper3, "Not an admin; " MSG); + is_client_sendq_empty(oper4, "Not an admin; " MSG); + is_client_sendq_empty(server, MSG); + + remove_local_person(user1); + remove_local_person(user2); + remove_local_person(oper1); + remove_local_person(oper2); + remove_local_person(oper3); + remove_local_person(oper4); +} + static void kill_client1(void) { standard_init(); @@ -2687,6 +4690,25 @@ static void kill_client1(void) standard_free(); } +static void kill_client1__tags(void) +{ + standard_init(); + + strcpy(remote->user->suser, "test"); + + kill_client(server, remote, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_NAME " KILL " TEST_REMOTE_NICK " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_ids(); + + kill_client(server, remote, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server, MSG); + is_client_sendq_empty(server2, MSG); + + standard_free(); +} + static void kill_client_serv_butone1(void) { standard_init(); @@ -2719,6 +4741,41 @@ static void kill_client_serv_butone1(void) standard_free(); } +static void kill_client_serv_butone1__tags(void) +{ + standard_init(); + + strcpy(remote2->user->suser, "test"); + strcpy(remote2->user->suser, "test2"); + + // This function does not support TS5... + standard_ids(); + + // If the server being sent to (or the kill target) is TS6, + // then "but one" is ignored and the kill is sent anyway + kill_client_serv_butone(remote, remote, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server3, MSG); + + kill_client_serv_butone(remote, remote2, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server3, MSG); + + kill_client_serv_butone(remote2, remote, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE_ID " :Hello World!" CRLF, server3, MSG); + + kill_client_serv_butone(remote2, remote2, "Hello %s!", "World"); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server2, MSG); + is_client_sendq(":" TEST_ME_ID " KILL " TEST_REMOTE2_ID " :Hello World!" CRLF, server3, MSG); + + standard_free(); +} + int main(int argc, char *argv[]) { plan_lazy(); @@ -2740,10 +4797,15 @@ int main(int argc, char *argv[]) ok(CAP_INVITE_NOTIFY != 0, "CAP_INVITE_NOTIFY missing; " MSG); sendto_one1(); + sendto_one1__tags(); sendto_one_prefix1(); + sendto_one_prefix1__tags(); sendto_one_notice1(); + sendto_one_notice1__tags(); sendto_one_numeric1(); + sendto_one_numeric1__tags(); sendto_server1(); + sendto_server1__tags(); sendto_channel_flags__local__all_members(); sendto_channel_flags__remote__all_members(); @@ -2757,30 +4819,48 @@ int main(int argc, char *argv[]) sendto_channel_flags__remote__chanop_voice(); sendto_channel_opmod__local(); + sendto_channel_opmod__local__tags(); sendto_channel_opmod__remote(); + sendto_channel_opmod__remote__tags(); sendto_channel_local1(); + sendto_channel_local1__tags(); sendto_channel_local_with_capability1(); + sendto_channel_local_with_capability1__tags(); sendto_channel_local_with_capability_butone1(); + sendto_channel_local_with_capability_butone1__tags(); sendto_channel_local_butone1(); + sendto_channel_local_butone1__tags(); sendto_common_channels_local1(); + sendto_common_channels_local1__tags(); sendto_common_channels_local_butone1(); + sendto_common_channels_local_butone1__tags(); sendto_match_butone__host(); + sendto_match_butone__host__tags(); sendto_match_butone__server(); + sendto_match_butone__server__tags(); sendto_match_servs1(); + sendto_match_servs1__tags(); sendto_local_clients_with_capability1(); + sendto_local_clients_with_capability1__tags(); sendto_monitor1(); + sendto_monitor1__tags(); sendto_anywhere1(); sendto_anywhere1__tags(); sendto_anywhere_echo1(); sendto_anywhere_echo1__tags(); sendto_realops_snomask1(); + sendto_realops_snomask1__tags(); sendto_realops_snomask_from1(); + sendto_realops_snomask_from1__tags(); sendto_wallops_flags1(); + sendto_wallops_flags1__tags(); kill_client1(); + kill_client1__tags(); kill_client_serv_butone1(); + kill_client_serv_butone1__tags(); client_util_free(); ircd_util_free();