From 559df11d4146fc009ab5f67f8a57f436f5aac1be Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 25 Dec 2019 20:38:19 +0000 Subject: [PATCH] testing :D --- scripts/dev_ipad_run.sh | 16 +++++++++ scripts/test.sh | 4 +++ spec/ngircd.conf | 42 ++++++++++++++++++++++ spec/ngircd_harness_spec.moon | 68 +++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100755 scripts/dev_ipad_run.sh create mode 100755 scripts/test.sh create mode 100644 spec/ngircd.conf create mode 100644 spec/ngircd_harness_spec.moon diff --git a/scripts/dev_ipad_run.sh b/scripts/dev_ipad_run.sh new file mode 100755 index 0000000..975e3fa --- /dev/null +++ b/scripts/dev_ipad_run.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +moonc-5.3 `find -type f | grep 'moon$'` +ngircd -f ./spec/ngircd.conf + +function trap_ctrlc () { + killall ngircd + exit 0 +} + +trap "trap_ctrlc" 2 + +cd src +export KETRACEL_DEBUG=yes +export KETRACEL_SPASS=hunter2 +lua5.3 -l set_paths ketracel.lua diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..99ff4e5 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +moonc `find -type f | grep -v spec | grep 'moon$'` +busted --defer-print diff --git a/spec/ngircd.conf b/spec/ngircd.conf new file mode 100644 index 0000000..3f4c0e8 --- /dev/null +++ b/spec/ngircd.conf @@ -0,0 +1,42 @@ +[Global] +Name = test.localhost +Info = oh god +Listen = 0.0.0.0 +MotdPhrase = testing +Network = ShadowNET +Ports = 6667 +ServerGID = 65534 +ServerUID = 65534 + +[Limits] +MaxJoins = 50 +MaxNickLength = 31 +MaxListSize = 100 +PingTimeout = 120 +PongTimeout = 20 + +[Options] +AllowedChannelTypes = #&+ +AllowRemoteOper = yes +CloakUserToNick = yes +DNS = no +Ident = no +MorePrivacy = no +NoticeBeforeRegistration = yes +OperCanUseMode = yes +OperChanPAutoOp = yes +PAM = no +PAMIsOptional = yes +RequireAuthPing = yes + +[Channel] +Name = #lobby +Topic = Welcome to the new ShadowNET! +Modes = tn + +[Server] +Name = ketracel.akua +Passive = yes +MyPassword = hunter2 +PeerPassword = hunter2 +ServiceMask = Ketracel,*Serv diff --git a/spec/ngircd_harness_spec.moon b/spec/ngircd_harness_spec.moon new file mode 100644 index 0000000..f55b19a --- /dev/null +++ b/spec/ngircd_harness_spec.moon @@ -0,0 +1,68 @@ +irce = require "irce" +socket = require "socket" + +describe "ngircd protocol support", -> + local file + local last_msg + client = socket.tcp! + client\settimeout 1 + irc = irce.new! + irc\set_send_func (message) => + last_msg = message + print "[server] > " .. message + client\send message + irc\load_module require "irce.modules.ngircd" + + setup -> + print "got here" + file = io.popen "ngircd -n -f ./spec/ngircd.conf", "r" + + teardown -> + with io.popen "killall ngircd", "r" + \close! + with file + print \read "*all" + \close! + + it "actually is running ngircd", -> + with io.popen "pstree" + data = \read "*all" + assert.truthy string.find data, "ngircd" + + it "registers", -> + bursted = false + irc\set_callback "376", => + bursted = true + + client\connect "127.0.0.1", 6667 + irc\REGISTER "hunter2", "kc-test", "0.0.1", "ketracel.akua", "test", "31" + + while not bursted + msg = client\receive! + print "[server] " .. msg + irc\process msg + + irc\clear_callback "376" + + it "can do a normal client connection", -> + irc_client = socket.tcp! + ircce = irce.new! + ircce\set_send_func (message) => + print "[client] > " .. message + irc_client\send message + running = true + ircce\set_callback "005", => + running = false + + ircce\load_module require "irce.modules.base" + irc_client\connect "127.0.0.1", 6667 + ircce\NICK "test" + ircce\USER "test", "hunter2" + + while running + msg = irc_client\receive! + print "[client] < " .. msg + ircce\process msg + + ircce\QUIT "bye" + irc_client\close!