From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 30 Sep 2021 06:11:50 -0700 Subject: [PATCH 16/28] SQUASH-ME: Add ERC scenarios for session-aware msg handlers --- .../base/mask-target-routing/foonet.lispdata | 45 +++++++++++++++++++ test/lisp/erc/erc-scenarios.el | 36 +++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/lisp/erc/erc-scenarios-resources/base/mask-target-routing/foonet.lispdata diff --git a/test/lisp/erc/erc-scenarios-resources/base/mask-target-routing/foonet.lispdata b/test/lisp/erc/erc-scenarios-resources/base/mask-target-routing/foonet.lispdata new file mode 100644 index 0000000000..796d5566b6 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-resources/base/mask-target-routing/foonet.lispdata @@ -0,0 +1,45 @@ +;; -*- mode: lisp-data; -*- +((pass 1 "PASS :changeme")) +((nick 1 "NICK tester")) +((user 1 "USER user 0 * :tester") + (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") + (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.foonet.org 003 tester :This server was created Mon, 31 May 2021 09:56:24 UTC") + (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)") + (0 ":irc.foonet.org 252 tester 0 :IRC Operators online") + (0 ":irc.foonet.org 254 tester 2 :channels formed") + (0 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers") + (0 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4") + (0 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4") + (0 ":irc.foonet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i") + ;; No mode answer + (0 ":irc.znc.in 306 tester :You have been marked as being away") + (0 ":tester!~u@gq7yjr7gsu7nn.irc JOIN #foo") + (0 ":irc.foonet.org 353 tester = #foo :alice @bob rando tester") + (0 ":irc.foonet.org 366 tester #foo :End of /NAMES list.") + (0 ":***!znc@znc.in PRIVMSG #foo :Buffer Playback...") + (0 ":alice!~u@gq7yjr7gsu7nn.irc PRIVMSG #foo :[10:00:02] bob: All that he is hath reference to your highness.") + (0 ":bob!~u@gq7yjr7gsu7nn.irc PRIVMSG #foo :[10:00:06] alice: Excellent workman! Thou canst not paint a man so bad as is thyself.") + (0 ":***!znc@znc.in PRIVMSG #foo :Playback Complete.") + (0 ":irc.foonet.org NOTICE tester :[09:56:57] This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.") + (0 ":irc.foonet.org 305 tester :You are no longer marked as being away")) + +((mode 5 "MODE #foo") + (0 ":irc.foonet.org 324 tester #foo +nt") + (0 ":irc.foonet.org 329 tester #foo 1622454985") + ;; Invalid msg + (0.1 ":rando!~u@em2i467d4ejul.irc PRIVMSG :") + (0.1 ":alice!~u@gq7yjr7gsu7nn.irc PRIVMSG #foo :bob: Farewell, pretty lady: you must hold the credit of your father.") + (0.1 ":bob!~u@gq7yjr7gsu7nn.irc NOTICE $* :[Global notice] going down soon.") + (0.1 ":alice!~u@rz2v467q4rwhy.irc PRIVMSG #foo :bob: Well, this is the forest of Arden.") + (0.1 ":bob!~u@gq7yjr7gsu7nn.irc NOTICE $$* :[Global notice] this is a warning.") + (0.1 ":alice!~u@rz2v467q4rwhy.irc PRIVMSG #foo :bob: Be married under a bush, like a beggar ? Get you to church, and have a good priest that can tell you what marriage is: this fellow will but join you together as they join wainscot; then one of you will prove a shrunk panel, and like green timber, warp, warp.") + (0.1 ":bob!~u@gq7yjr7gsu7nn.irc PRIVMSG $* :[Global msg] second warning.") + (0.1 ":alice!~u@rz2v467q4rwhy.irc PRIVMSG #foo :bob: And will you, being a man of your breeding.") + (0.1 ":bob!~u@gq7yjr7gsu7nn.irc NOTICE #* :[Global notice] final warning.")) diff --git a/test/lisp/erc/erc-scenarios.el b/test/lisp/erc/erc-scenarios.el index f7931b35b9..0e2928b9a1 100644 --- a/test/lisp/erc/erc-scenarios.el +++ b/test/lisp/erc/erc-scenarios.el @@ -1676,4 +1676,40 @@ erc-scenarios-networks-announced-missing (should-not erc-network) (should (string= erc-server-announced-name "irc.foonet.org")))))) +;; Targets that are host/server masks like $*, $$*, and #* are routed +;; to the server buffer: https://github.com/ircdocs/wooooms/issues/5 + +(ert-deftest erc-scenarios-base-mask-target-routing () + (erc-scenarios-common-with-cleanup + ((erc-scenarios-common-dialog "base/mask-target-routing") + (erc-d-linger-secs 0.5) + (dumb-server (erc-d-run "localhost" t 'foonet)) + (port (process-contact dumb-server :service)) + (dumb-server-buffer (get-buffer "*erc-d-server*")) + (expect (erc-d-t-make-expecter))) + + (ert-info ("Connect to foonet") + (with-current-buffer (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "changeme" + :full-name "tester") + (should (string= (buffer-name) (format "127.0.0.1:%d" port))))) + + (erc-d-t-wait-for 1 "server buffer ready" (get-buffer "foonet")) + + (ert-info ("Channel buffer #foo playback received") + (erc-d-t-wait-for 3 "#foo exists" (get-buffer "#foo")) + (with-current-buffer "#foo" + (funcall expect 10 "Excellent workman"))) + + (ert-info ("Global notices routed to server buffer") + (with-current-buffer "foonet" + (funcall expect 10 "going down soon") + (funcall expect 10 "this is a warning") + (funcall expect 10 "second warning") + (funcall expect 10 "final warning"))) + + (should-not (get-buffer "$*")))) + ;;; erc-scenarios.el ends here -- 2.31.1