aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/tests.bats
blob: 387c7c2603c9b0e39e57ba7714259a2ef48a8fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
load test_helper

RSPAMC="$BATS_TEST_DIRNAME/../../src/client/rspamc"

@test "Test rspamd using gtube" {
	export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/trivial.conf"
	run_rspamd
	run ${RSPAMC} -h localhost:56789 \
		"$BATS_TEST_DIRNAME/messages/gtube.eml"
	[ "$status" -eq 0 ]
	
	echo $output | grep 'Action: reject'
}

@test "Test rspamd encrypted using gtube" {
	export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/trivial.conf"
	run_rspamd
	run ${RSPAMC} -h localhost:56789 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		"$BATS_TEST_DIRNAME/messages/gtube.eml"
	[ "$status" -eq 0 ]
	
	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" {
	skip
	export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/trivial.conf"
	run_rspamd
	run perl $BATS_TEST_DIRNAME/cases/http_streamline.pl "$BATS_TEST_DIRNAME/messages/gtube.eml"
	[ "$status" -eq 0 ]
	
	echo $output | grep 'Action: reject'
}

@test "Test rspamd learn" {
	clear_stats
	export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/stats.conf"
	run_rspamd
	run ${RSPAMC} -h localhost:56790 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		learn_spam \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | egrep 'success.*true'
	
	run ${RSPAMC} -h localhost:56789 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		symbols \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | grep 'BAYES_SPAM'
	clear_stats
}

@test "Test rspamd re-learn" {
	clear_stats
	export RSPAMD_CONFIG="$BATS_TEST_DIRNAME/configs/stats.conf"
	run_rspamd
	run ${RSPAMC} -h localhost:56790 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		learn_spam \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | egrep 'success.*true'
	
	run ${RSPAMC} -h localhost:56790 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		learn_ham \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | egrep 'success.*true'
	
	run ${RSPAMC} -h localhost:56789 \
		--key y3ms1knmetxf8gdeixkf74b6tbpxqugmxzqksnjodiqei7tksyty \
		symbols \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | grep 'BAYES_HAM'
	clear_stats
}

@test "Test rspamd dependencies" {
	clear_stats
	sed -e 's|@@LUA_SCRIPT@@|${CURDIR}/functional/cases/deps.lua|' < \
		"$BATS_TEST_DIRNAME/configs/lua_test.conf" > \
		"$BATS_TMPDIR/rspamd.conf"
	export RSPAMD_CONFIG="$BATS_TMPDIR/rspamd.conf"
	run_rspamd
	run ${RSPAMC} -h localhost:56789 \
		symbols \
		"$BATS_TEST_DIRNAME/messages/spam_message.eml"
	[ "$status" -eq 0 ]
	
	echo $output | grep 'DEP10'
	clear_stats
}