Skip to content

Commit

Permalink
Fix all results. Updated IPs to match test domain
Browse files Browse the repository at this point in the history
  • Loading branch information
José Borges Ferreira committed Jul 14, 2020
1 parent 6419984 commit 543dad7
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 74 deletions.
16 changes: 2 additions & 14 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
#!/bin/bash

./smf-spf -h
RET=0
for testfile in tests/* ; do
echo "#########################################"
echo "Running $testfile ..."
miltertest -s $testfile
status=$?
echo -n "returned "
if [ $status -eq 0 ] ; then
echo -e "\e[32msuccessful\e[39m"
else
echo -e "\e[31mfailed\e[39m"
RET=1
FAILED+="\n\t$testfile"
fi
echo "#########################################"
miltertest -s $testfile
done

[[ -z "$FAILED" ]] || echo -e "#########################################\nFailed tests $FAILED"
exit $RET
1 change: 0 additions & 1 deletion smf-spf-tests-fixedip-fail.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
WhitelistIP 192.168.0.0/16
relaxedlocalpart on
TTL 1h
tagsubject off
RejectReason "Rejeitado"
User nobody
Expand Down
7 changes: 3 additions & 4 deletions smf-spf-tests-fixedip.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
LogTo /dev/stdout
WhitelistIP 192.168.0.0/16
RefuseFail off # (on|off)

TTL 1D
relaxedlocalpart on
tagsubject off
FixedClientIP 54.154.126.152
FixedClientIP 54.154.126.152
RefuseFail on
User nobody
Socket inet:2424@127.0.0.1
Syslog none
LogTo /dev/stdout
Syslog mail # (daemon|mail|local0...local7)
Daemonize off # (on|off)
AuthservID mail.example.com
2 changes: 1 addition & 1 deletion smf-spf-tests-q.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Quarantine on # (on|off)
QuarantineBox postmaster
TTL 60m
User nobody
Socket unix:/tmp/milter.sock
Socket unix:./milter.sock
Syslog mail # (daemon|mail|local0...local7)
Daemonize off # (on|off)
1 change: 1 addition & 0 deletions smf-spf-tests-refuse.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
LogTo /dev/stdout
WhitelistIP 127.0.0.0/8
RefuseFail on # (on|off)
RefuseSPFnone on # (on|off)
Expand Down
3 changes: 2 additions & 1 deletion smf-spf-tests.conf
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ QuarantineBox postmaster
#
# Default: 1h
#
TTL 1
TTL 1D
TTL 1h

# Run as a selected user (smf-spf must be started by root)
#
Expand Down
2 changes: 1 addition & 1 deletion tests/01-loadconfig-q.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests-q.conf")
-- try to connect to it
conn = mt.connect("unix:/tmp/milter.sock", 4, 0.25)
conn = mt.connect("unix:./milter.sock", 40, 0.25)
if conn == nil then
error("mt.connect() failed")
end
Expand Down
2 changes: 1 addition & 1 deletion tests/02-host-whitelisted.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

-- send connection information

mt.macro(conn, SMFIC_CONNECT, "j", "")
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "server.example.org", "2001:0101:DEAD:BEEF::1") ~= nil then
error("mt.conninfo() failed")
end
Expand Down
2 changes: 1 addition & 1 deletion tests/04-fixed-client-fail.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Copyright (c) 2009-2013, The Trusted Domain Project. All rights reserved.
mt.echo("SPF Fixed-client fail. Using ./smf-spf-tests-fixedip-fail.conf")
mt.echo("SPF pass test")

-- try to start the filter
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests-fixedip-fail.conf")
Expand Down
8 changes: 4 additions & 4 deletions tests/04-fixed-client-pass.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Copyright (c) 2009-2013, The Trusted Domain Project. All rights reserved.
mt.echo("SPF Fixed-client pass. Using ./smf-spf-tests-fixedip.conf")
mt.echo("SPF pass test")

-- try to start the filter
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests-fixedip.conf")
Expand All @@ -13,7 +13,7 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "10.10.10.10") ~= nil then
if mt.conninfo(conn, "localhost", "192.0.0.194") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -68,8 +68,8 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=fail", 1) then
error("incorrect Authentication-Results field : " .. ar)
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
Expand Down
2 changes: 1 addition & 1 deletion tests/04-fulltest-fail-tag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mt.echo("SPF fail test")
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests-q.conf")

-- try to connect to it
conn = mt.connect("unix:/tmp/milter.sock", 40, 0.25)
conn = mt.connect("unix:./milter.sock", 40, 0.25)
if conn == nil then
error("mt.connect() failed")
end
Expand Down
4 changes: 2 additions & 2 deletions tests/04-fulltest-neutral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=none", 1) then
if string.find(ar, "spf=neutral", 1, true) == nil then
mt.echo ("Got header Authentication-Results: " .. ar)
error("incorrect Authentication-Results field")
else
mt.echo("SPF neutral")
mt.echo("SPF neutral ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
Expand Down
13 changes: 6 additions & 7 deletions tests/04-fulltest-pass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "54.154.126.152") ~= nil then
if mt.conninfo(conn, "localhost", "54.194.147.141") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -77,12 +77,11 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=pass", 1) then
mt.echo("SPF pass ")
else
mt.echo(" Got AR: "..ar);
error("incorrect Authentication-Results field")
end
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
error("missing Authentication-Results field")
Expand Down
11 changes: 5 additions & 6 deletions tests/04-fulltest-refusefail.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Copyright (c) 2009-2013, The Trusted Domain Project. All rights reserved.
mt.echo("SPF refusefail test. Using ./smf-spf-tests-refuse.conf")
mt.echo("SPF pass test")

-- try to start the filter
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests-refuse.conf")
Expand All @@ -13,7 +13,7 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "10.10.10.10") ~= nil then
if mt.conninfo(conn, "localhost", "195.22.26.194") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand All @@ -27,11 +27,10 @@ if mt.mailfrom(conn, "<user@underspell.com>") ~= nil then
error("mt.mailfrom() failed")
end

if mt.getreply(conn) == SMFIR_REPLYCODE then
mt.echo ("received SMFIR_REPLYCODE ")
else
error("mt.mailfrom() unexpected reply")
if mt.getreply(conn) ~= SMFIR_REPLYCODE then
error("mt.mailfrom() unexpected reply")
end

print ("received SMFIR_REPLYCODE ")

mt.disconnect(conn)
12 changes: 6 additions & 6 deletions tests/04-fulltest-soft.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=softfail", 1) then
mt.echo("SPF softfail")
else
mt.echo(" Got AR: "..ar);
error("incorrect Authentication-Results field")
end
if string.find(ar, "spf=softfail", 1, true) == nil then
mt.echo ("Got header Authentication-Results: " .. ar)
error("incorrect Authentication-Results field")
else
mt.echo("SPF softfail ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
error("missing Authentication-Results field")
Expand Down
11 changes: 5 additions & 6 deletions tests/04-helo-pass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "hostname.underspell.com","10.11.12.13") ~= nil then
if mt.conninfo(conn, "helo.underspell.com","10.11.12.13") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -67,14 +67,13 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
mt.echo("Got AR "..ar)
if string.find(ar, "spf=pass", 1) then
mt.echo("SPF pass ")
else
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
error("missing Authentication-Results field")
end

mt.disconnect(conn)
37 changes: 19 additions & 18 deletions tests/05-cache-test.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Copyright (c) 2009-2013, The Trusted Domain Project. All rights reserved.
mt.echo("Milter cache test. Using ./smf-spf-tests.conf")
mt.echo("Milter cache test")

-- try to start the filter
mt.startfilter("./smf-spf", "-f", "-c","./smf-spf-tests.conf")
Expand All @@ -13,7 +13,8 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "54.154.126.152") ~= nil then
mt.echo("Connect from 54.194.157.134")
if mt.conninfo(conn, "localhost", "54.194.157.134") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand All @@ -23,7 +24,7 @@ end
-- send envelope macros and sender data
-- mt.helo() is called implicitly
mt.macro(conn, SMFIC_MAIL, "i", "t-verify-malformed")
if mt.mailfrom(conn, "<user@nospf.underspell.com>") ~= nil then
if mt.mailfrom(conn, "<user@underspell.com>") ~= nil then
error("mt.mailfrom() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -60,11 +61,10 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=none", 1) then
mt.echo("SPF none")
else
mt.echo(" Got AR: "..ar);
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
else
error("missing Authentication-Results field")
Expand All @@ -80,7 +80,8 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "54.154.126.152") ~= nil then
mt.echo("Connect from 54.194.147.141")
if mt.conninfo(conn, "localhost", "54.194.147.141") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -127,16 +128,16 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=pass", 1) then
mt.echo("SPF pass ")
else
mt.echo(" Got AR: "..ar);
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
error("missing Authentication-Results field")
end

mt.disconnect(conn)
-- try to connect to it
conn = mt.connect("inet:2424@127.0.0.1", 40, 0.25)
Expand All @@ -147,7 +148,8 @@ end
-- send connection information
-- mt.negotiate() is called implicitly
mt.macro(conn, SMFIC_CONNECT, "j", "mta.name.local")
if mt.conninfo(conn, "localhost", "54.154.126.152") ~= nil then
mt.echo("Connect from 54.194.147.141")
if mt.conninfo(conn, "localhost", "54.194.147.141") ~= nil then
error("mt.conninfo() failed")
end
if mt.getreply(conn) ~= SMFIR_CONTINUE then
Expand Down Expand Up @@ -194,15 +196,14 @@ end
if mt.eom_check(conn, MT_HDRINSERT, "Authentication-Results") or
mt.eom_check(conn, MT_HDRADD, "Authentication-Results") then
ar = mt.getheader(conn, "Authentication-Results", 0)
if string.find(ar, "spf=pass", 1) then
mt.echo("SPF pass ")
else
mt.echo(" Got AR: "..ar);
if string.find(ar, "spf=pass", 1, true) == nil then
error("incorrect Authentication-Results field")
else
mt.echo("SPF pass ")
end
else
mt.echo ("Got header Authentication-Results: " .. ar)
error("missing Authentication-Results field")
end

mt.disconnect(conn)
mt.disconnect(conn)

0 comments on commit 543dad7

Please sign in to comment.