commit e910604: [TEST] Force Actions Settings

korgoth1 vladislav.stakhov at gmail.com
Tue Mar 17 17:14:13 UTC 2020


Author: korgoth1
Date: 2020-03-17 20:04:47 +0300
URL: https://github.com/rspamd/rspamd/commit/e910604df1660331394786f24edbb30c82e776bb (refs/pull/3302/head)

[TEST] Force Actions Settings

---
 test/functional/cases/360_force_actions.robot | 54 +++++++++++++++++
 test/functional/configs/force_actions.conf    | 86 +++++++++++++++++++++++++++
 test/functional/configs/plugins.conf          |  1 +
 3 files changed, 141 insertions(+)

diff --git a/test/functional/cases/360_force_actions.robot b/test/functional/cases/360_force_actions.robot
new file mode 100644
index 000000000..8ef19584d
--- /dev/null
+++ b/test/functional/cases/360_force_actions.robot
@@ -0,0 +1,54 @@
+*** Settings ***
+Suite Setup     Force Actions Setup
+Suite Teardown  Force Actions Teardown
+Library         ${TESTDIR}/lib/rspamd.py
+Resource        ${TESTDIR}/lib/rspamd.robot
+Variables       ${TESTDIR}/lib/vars.py
+
+*** Variables ***
+${CONFIG}       ${TESTDIR}/configs/plugins.conf
+${URL_TLD}      ${TESTDIR}/../lua/unit/test_tld.dat
+${MESSAGE} 		${TESTDIR}/messages/url7.eml
+${RSPAMD_SCOPE}  Suite
+
+*** Test Cases ***
+FORCE ACTIONS from reject to add header
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_reject
+  Check Rspamc  ${result}  Action: add header
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_REJECT_TO_ADD_HEADER
+
+FORCE ACTIONS from reject to no action
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_reject_no_action
+  Check Rspamc  ${result}  Action: no action
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_REJECT_TO_NO_ACTION
+
+FORCE ACTIONS from no action to reject
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_no_action
+  Check Rspamc  ${result}  Action: reject
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_NO_ACTION_TO_REJECT
+
+FORCE ACTIONS from no action to add header
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_no_action_to_add_header
+  Check Rspamc  ${result}  Action: add header
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_NO_ACTION_TO_ADD_HEADER
+
+FORCE ACTIONS from add header to no action
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_add_header
+  Check Rspamc  ${result}  Action: no action
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_ADD_HEADER_TO_NO_ACTION
+
+FORCE ACTIONS from add header to reject
+  ${result} =  Scan Message With Rspamc  ${MESSAGE}  --header  Settings-Id=id_add_header_to_reject
+  Check Rspamc  ${result}  Action: reject
+  Should Contain  ${result.stdout}  FORCE_ACTION_FORCE_ADD_HEADER_TO_REJECT
+
+
+*** Keywords ***
+Force Actions Setup
+  ${PLUGIN_CONFIG} =  Get File  ${TESTDIR}/configs/force_actions.conf
+  Set Suite Variable  ${PLUGIN_CONFIG}
+  Generic Setup  PLUGIN_CONFIG
+
+Force Actions Teardown
+  Normal Teardown
+  Terminate All Processes    kill=True
\ No newline at end of file
diff --git a/test/functional/configs/force_actions.conf b/test/functional/configs/force_actions.conf
new file mode 100644
index 000000000..61732c4ac
--- /dev/null
+++ b/test/functional/configs/force_actions.conf
@@ -0,0 +1,86 @@
+force_actions {
+	rules {
+    	FORCE_REJECT_TO_ADD_HEADER {
+        	action = "add header";
+        	expression = "UBER_REJECT";
+        	require_action = ["reject"];
+    	}
+    	FORCE_REJECT_TO_NO_ACTION {
+        	action = "no action";
+        	expression = "UBER_REJECT2";
+        	require_action = ["reject"];
+		}
+		FORCE_NO_ACTION_TO_REJECT {
+        	action = "reject";
+        	expression = "UBER_HAM";
+        	require_action = ["no action"];
+		}
+		FORCE_NO_ACTION_TO_ADD_HEADER {
+        	action = "add header";
+        	expression = "UBER_HAM2";
+        	require_action = ["no action"];
+		}
+    	FORCE_ADD_HEADER_TO_NO_ACTION {
+        	action = "no action";
+        	expression = "UBER_ADD_HEADER";
+        	require_action = ["add header"];
+		}
+		FORCE_ADD_HEADER_TO_REJECT {
+        	action = "reject";
+        	expression = "UBER_ADD_HEADER2";
+        	require_action = ["add header"];
+		}
+	}
+}
+
+
+settings {
+  	id_reject {
+    id = "id_reject";
+    apply {
+    	symbols {
+    		UBER_REJECT = 100500.0;
+    		}
+    	}
+	}
+	id_reject_no_action {
+    id = "id_reject_no_action";
+    apply {
+    	symbols {
+    		UBER_REJECT2 = 100500.0;
+    		}
+    	}
+	}
+	id_no_action {
+    id = "id_no_action";
+    apply {
+    	symbols {
+    		UBER_HAM = 1.0;
+    		}
+    	}
+	}
+	id_no_action_to_add_header {
+    id = "id_no_action_to_add_header";
+    apply {
+    	symbols {
+    		UBER_HAM2 = 1.0;
+    		}
+    	}
+	}
+	id_add_header {
+    id = "id_add_header";
+    apply {
+    	symbols {
+    		UBER_ADD_HEADER = 50500.0;
+    		}
+    	}
+	}
+	id_add_header_to_reject {
+    id = "id_add_header_to_reject";
+    apply {
+    	symbols {
+    		UBER_ADD_HEADER2 = 50500.0;
+    		}
+    	}
+	}
+}
\ No newline at end of file
diff --git a/test/functional/configs/plugins.conf b/test/functional/configs/plugins.conf
index e74ddd73d..b1885eeb6 100644
--- a/test/functional/configs/plugins.conf
+++ b/test/functional/configs/plugins.conf
@@ -724,6 +724,7 @@ metric = {
   name = "default",
   actions = {
     reject = 100500,
+    add_header = 50500,
   }
   unknown_weight = 1
 }


More information about the Commits mailing list