summaryrefslogtreecommitdiffstats
path: root/test/functional/lua/miltertest
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2018-01-30 17:06:35 +0200
committerAndrew Lewis <nerf@judo.za.org>2018-01-30 17:06:35 +0200
commit77e0862c9eb71bf1aa22892235d3aaad4431d236 (patch)
tree68ea9819396c19b394dfc71755a124df2b8cbdd3 /test/functional/lua/miltertest
parentb8137c5f9c9716e781d7cbae76911774603bdc09 (diff)
downloadrspamd-77e0862c9eb71bf1aa22892235d3aaad4431d236.tar.gz
rspamd-77e0862c9eb71bf1aa22892235d3aaad4431d236.zip
[Test] Beginning of tests for milter
Diffstat (limited to 'test/functional/lua/miltertest')
-rw-r--r--test/functional/lua/miltertest/mt1.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/functional/lua/miltertest/mt1.lua b/test/functional/lua/miltertest/mt1.lua
new file mode 100644
index 000000000..a6f6722de
--- /dev/null
+++ b/test/functional/lua/miltertest/mt1.lua
@@ -0,0 +1,59 @@
+-- Test one simple interaction
+
+conn = mt.connect("inet:" .. port .. "@" .. host)
+if conn == nil then
+ error "mt.connect() failed"
+end
+if mt.conninfo(conn, "localhost", "127.0.0.1") then
+ error "mt.conninfo() failed"
+end
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.conninfo() unexpected reply"
+end
+
+if mt.helo(conn, "it.is.i") then
+ error "mt.helo() failed"
+end
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.helo() unexpected reply"
+end
+mt.macro(conn, SMFIC_MAIL, "i", "test-id")
+if mt.mailfrom(conn, "sender@example.com") then
+ error "mt.mailfrom() failed"
+end
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.mailfrom() unexpected reply"
+end
+mt.rcptto(conn, "rcpt@example.com")
+
+if mt.header(conn, "From", "honest@sender") then
+ error "mt.header(From) failed"
+end
+
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.header(From) unexpected reply"
+end
+
+if mt.eoh(conn) then
+ error "mt.eoh() failed"
+end
+
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.eoh() unexpected reply"
+end
+
+if mt.bodystring(conn, "This is a simple test!\r\n") then
+ error "mt.bodystring() failed"
+end
+if mt.getreply(conn) ~= SMFIR_CONTINUE then
+ error "mt.bodystring() unexpected reply"
+end
+
+if mt.eom(conn) then
+ error "mt.eom() failed"
+end
+if mt.getreply(conn) ~= SMFIR_ACCEPT then
+ error "mt.eom() unexpected reply"
+end
+
+mt.disconnect(conn)