diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-02 19:02:39 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-02 19:02:39 +0100 |
commit | 67bb533e8927bcc1e7de6f4b3b26e1a027a7e8f8 (patch) | |
tree | 3ed6413d503051ffddbbed672551b80bc6845870 /test/functional | |
parent | 22a433506e0d3fb9321df8d3b655217b15a61017 (diff) | |
download | rspamd-67bb533e8927bcc1e7de6f4b3b26e1a027a7e8f8.tar.gz rspamd-67bb533e8927bcc1e7de6f4b3b26e1a027a7e8f8.zip |
Add functional test for spamc protocol.
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/cases/spamc.pl | 40 | ||||
-rw-r--r-- | test/functional/tests.bats | 9 |
2 files changed, 49 insertions, 0 deletions
diff --git a/test/functional/cases/spamc.pl b/test/functional/cases/spamc.pl new file mode 100644 index 000000000..abeefb8b4 --- /dev/null +++ b/test/functional/cases/spamc.pl @@ -0,0 +1,40 @@ +#!/usr/bin/env perl + +use warnings; +use strict; + +use Socket; + +my $host = "127.0.0.1"; +my $port = 56789; +my $input = shift; + +open(INPUT, "< $input") or die "Can't open input file $input\n"; + +socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]) + or die "Can't create a socket $!\n"; +connect(SOCKET, pack_sockaddr_in($port, inet_aton($host))) + or die "Can't connect to port $port! \n"; + +print SOCKET "SYMBOLS SPAMC/1.0\r\n"; + +my $msg; +while (my $line = <INPUT>) { + $msg .= $line; +} + +my $dlen = length($msg); +print SOCKET "Content-length: $dlen\r\n\r\n$msg"; + +SOCKET->autoflush(1); + +shutdown(SOCKET, 1); + +close(INPUT); + +while (my $line = <SOCKET>) { + print $line; +} + +close(SOCKET); + diff --git a/test/functional/tests.bats b/test/functional/tests.bats index 73811f2d5..b9d71a2a5 100644 --- a/test/functional/tests.bats +++ b/test/functional/tests.bats @@ -12,6 +12,15 @@ RSPAMC="$BATS_TEST_DIRNAME/../../src/client/rspamc" echo $output | grep 'Action: reject' } +@test "Test rspamd spamc gtube" { + export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/trivial.conf" + run_rspamd + run perl $BATS_TEST_DIRNAME/cases/spamc.pl "$BATS_TEST_DIRNAME/messages/gtube.eml" + [ "$status" -eq 0 ] + + echo $output | grep 'GTUBE' +} + @test "Test rspamd streamlined gtube" { export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/trivial.conf" run_rspamd |