Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

lib.robot 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. *** Settings ***
  2. Library OperatingSystem
  3. Library ${RSPAMD_TESTDIR}/lib/rspamd.py
  4. Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot
  5. Variables ${RSPAMD_TESTDIR}/lib/vars.py
  6. *** Variables ***
  7. ${CONFIG} ${RSPAMD_TESTDIR}/configs/fuzzy.conf
  8. ${FLAG1_SYMBOL} R_TEST_FUZZY_DENIED
  9. ${FLAG2_SYMBOL} R_TEST_FUZZY_WHITE
  10. ${REDIS_SCOPE} Suite
  11. ${RSPAMD_FLAG1_NUMBER} 50
  12. ${RSPAMD_FLAG2_NUMBER} 51
  13. ${RSPAMD_FUZZY_BACKEND} redis
  14. ${RSPAMD_FUZZY_ENCRYPTED_ONLY} false
  15. ${RSPAMD_FUZZY_ENCRYPTION_KEY} null
  16. ${RSPAMD_FUZZY_INCLUDE} ${RSPAMD_TESTDIR}/configs/empty.conf
  17. ${RSPAMD_FUZZY_KEY} null
  18. ${RSPAMD_FUZZY_SHINGLES_KEY} null
  19. ${RSPAMD_SCOPE} Suite
  20. ${SETTINGS_FUZZY_CHECK} ${EMPTY}
  21. ${SETTINGS_FUZZY_WORKER} ${EMPTY}
  22. @{MESSAGES_SKIP} ${RSPAMD_TESTDIR}/messages/priority.eml
  23. @{MESSAGES} ${RSPAMD_TESTDIR}/messages/spam_message.eml ${RSPAMD_TESTDIR}/messages/zip.eml
  24. @{RANDOM_MESSAGES} ${RSPAMD_TESTDIR}/messages/bad_message.eml ${RSPAMD_TESTDIR}/messages/zip-doublebad.eml
  25. *** Keywords ***
  26. Fuzzy Skip Add Test Base
  27. [Arguments] ${message}
  28. Set Suite Variable ${RSPAMD_FUZZY_ADD_${message}} 0
  29. ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10 -f
  30. ... ${RSPAMD_FLAG1_NUMBER} fuzzy_add ${message}
  31. Check Rspamc ${result}
  32. Sync Fuzzy Storage
  33. Scan File ${message}
  34. Expect Symbol R_TEST_FUZZY_DENIED
  35. Create File ${RSPAMD_TMPDIR}/skip_hash.map.tmp 2d875d4737c59c4822fd01dadeba52a329de3933f766c6f167904c6a426bbfa7ea63a66bf807b25c5ee853baee58bfb18d3b423fcd13cfa7c3d77a840039a1ea
  36. Move File ${RSPAMD_TMPDIR}/skip_hash.map.tmp ${RSPAMD_TMPDIR}/skip_hash.map
  37. Sleep 1s Wait for reload
  38. Scan File ${message}
  39. Do Not Expect Symbol R_TEST_FUZZY_DENIED
  40. Fuzzy Add Test
  41. [Arguments] ${message}
  42. Set Suite Variable ${RSPAMD_FUZZY_ADD_${message}} 0
  43. ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10 -f
  44. ... ${RSPAMD_FLAG1_NUMBER} fuzzy_add ${message}
  45. Check Rspamc ${result}
  46. Sync Fuzzy Storage
  47. Scan File ${message}
  48. Expect Symbol ${FLAG1_SYMBOL}
  49. Set Suite Variable ${RSPAMD_FUZZY_ADD_${message}} 1
  50. Fuzzy Delete Test
  51. [Arguments] ${message}
  52. IF ${RSPAMD_FUZZY_ADD_${message}} == 0
  53. Fail "Fuzzy Add was not run"
  54. END
  55. ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -f ${RSPAMD_FLAG1_NUMBER} fuzzy_del
  56. ... ${message}
  57. Check Rspamc ${result}
  58. Sync Fuzzy Storage
  59. Scan File ${message}
  60. Do Not Expect Symbol ${FLAG1_SYMBOL}
  61. Fuzzy Fuzzy Test
  62. [Arguments] ${message}
  63. IF ${RSPAMD_FUZZY_ADD_${message}} != 1
  64. Fail "Fuzzy Add was not run"
  65. END
  66. @{path_info} = Path Splitter ${message}
  67. @{fuzzy_files} = List Files In Directory ${pathinfo}[0] pattern=${pathinfo}[1].fuzzy* absolute=1
  68. FOR ${i} IN @{fuzzy_files}
  69. Scan File ${i}
  70. Expect Symbol ${FLAG1_SYMBOL}
  71. END
  72. Fuzzy Encrypted Test
  73. [Arguments] ${message}
  74. @{path_info} = Path Splitter ${message}
  75. @{fuzzy_files} = List Files In Directory ${pathinfo}[0] pattern=${pathinfo}[1].fuzzy* absolute=1
  76. FOR ${i} IN @{fuzzy_files}
  77. ${result} = Run Rspamc -p -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_NORMAL} --key ${RSPAMD_FUZZY_ENCRYPTION_KEY} ${i}
  78. Check Rspamc ${result} ${FLAG1_SYMBOL}
  79. END
  80. Fuzzy Miss Test
  81. [Arguments] ${message}
  82. Scan File ${message}
  83. Do Not Expect Symbol ${FLAG1_SYMBOL}
  84. Fuzzy Overwrite Test
  85. [Arguments] ${message}
  86. ${flag_numbers} = Create List ${RSPAMD_FLAG1_NUMBER} ${RSPAMD_FLAG2_NUMBER}
  87. FOR ${i} IN @{flag_numbers}
  88. ${result} = Run Rspamc -h ${RSPAMD_LOCAL_ADDR}:${RSPAMD_PORT_CONTROLLER} -w 10
  89. ... -f ${i} fuzzy_add ${message}
  90. Check Rspamc ${result}
  91. END
  92. Sync Fuzzy Storage
  93. Scan File ${message}
  94. Do Not Expect Symbol ${FLAG1_SYMBOL}
  95. Expect Symbol ${FLAG2_SYMBOL}
  96. Fuzzy Setup Encrypted
  97. [Arguments] ${algorithm}
  98. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  99. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTED_ONLY} true
  100. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  101. Set Suite Variable ${RSPAMD_FUZZY_CLIENT_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  102. Set Suite Variable ${RSPAMD_FUZZY_INCLUDE} ${RSPAMD_TESTDIR}/configs/fuzzy-encryption-key.conf
  103. Rspamd Redis Setup
  104. Fuzzy Setup Encrypted Dyn1
  105. [Arguments] ${algorithm}
  106. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  107. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTED_ONLY} true
  108. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  109. Set Suite Variable ${RSPAMD_FUZZY_CLIENT_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB2}
  110. Set Suite Variable ${RSPAMD_FUZZY_INCLUDE} ${RSPAMD_TESTDIR}/configs/fuzzy-encryption-key.conf
  111. Rspamd Redis Setup
  112. Fuzzy Setup Encrypted Dyn2
  113. [Arguments] ${algorithm}
  114. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  115. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTED_ONLY} true
  116. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  117. Set Suite Variable ${RSPAMD_FUZZY_CLIENT_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB3}
  118. Set Suite Variable ${RSPAMD_FUZZY_INCLUDE} ${RSPAMD_TESTDIR}/configs/fuzzy-encryption-key.conf
  119. Rspamd Redis Setup
  120. Fuzzy Setup Encrypted Keyed
  121. [Arguments] ${algorithm}
  122. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  123. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTED_ONLY} true
  124. Set Suite Variable ${RSPAMD_FUZZY_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  125. Set Suite Variable ${RSPAMD_FUZZY_CLIENT_ENCRYPTION_KEY} ${RSPAMD_KEY_PUB1}
  126. Set Suite Variable ${RSPAMD_FUZZY_KEY} mYN888sydwLTfE32g2hN
  127. Set Suite Variable ${RSPAMD_FUZZY_SHINGLES_KEY} hXUCgul9yYY3Zlk1QIT2
  128. Rspamd Redis Setup
  129. Fuzzy Setup Plain
  130. [Arguments] ${algorithm}
  131. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  132. Rspamd Redis Setup
  133. Fuzzy Setup Keyed
  134. [Arguments] ${algorithm}
  135. Set Suite Variable ${RSPAMD_FUZZY_ALGORITHM} ${algorithm}
  136. Set Suite Variable ${RSPAMD_FUZZY_KEY} mYN888sydwLTfE32g2hN
  137. Set Suite Variable ${RSPAMD_FUZZY_SHINGLES_KEY} hXUCgul9yYY3Zlk1QIT2
  138. Rspamd Redis Setup
  139. Fuzzy Setup Plain Fasthash
  140. Fuzzy Setup Plain fasthash
  141. Fuzzy Setup Plain Mumhash
  142. Fuzzy Setup Plain mumhash
  143. Fuzzy Setup Plain Siphash
  144. Fuzzy Setup Plain siphash
  145. Fuzzy Setup Plain Xxhash
  146. Fuzzy Setup Plain xxhash
  147. Fuzzy Setup Keyed Fasthash
  148. Fuzzy Setup Keyed fasthash
  149. Fuzzy Setup Keyed Mumhash
  150. Fuzzy Setup Keyed mumhash
  151. Fuzzy Setup Keyed Siphash
  152. Fuzzy Setup Keyed siphash
  153. Fuzzy Setup Keyed Xxhash
  154. Fuzzy Setup Keyed xxhash
  155. Fuzzy Setup Encrypted Siphash
  156. Fuzzy Setup Encrypted siphash
  157. Fuzzy Setup Encrypted Dyn1 Siphash
  158. Fuzzy Setup Encrypted Dyn1 siphash
  159. Fuzzy Setup Encrypted Dyn2 Siphash
  160. Fuzzy Setup Encrypted Dyn2 siphash
  161. Fuzzy Skip Hash Test Message
  162. FOR ${i} IN @{MESSAGES_SKIP}
  163. Fuzzy Skip Add Test Base ${i}
  164. END
  165. Fuzzy Multimessage Add Test
  166. FOR ${i} IN @{MESSAGES}
  167. Fuzzy Add Test ${i}
  168. END
  169. Fuzzy Multimessage Fuzzy Test
  170. FOR ${i} IN @{MESSAGES}
  171. Fuzzy Fuzzy Test ${i}
  172. END
  173. Fuzzy Multimessage Fuzzy Encrypted Test
  174. FOR ${i} IN @{MESSAGES}
  175. Fuzzy Encrypted Test ${i}
  176. END
  177. Fuzzy Multimessage Miss Test
  178. FOR ${i} IN @{RANDOM_MESSAGES}
  179. Fuzzy Miss Test ${i}
  180. END
  181. Fuzzy Multimessage Delete Test
  182. FOR ${i} IN @{MESSAGES}
  183. Fuzzy Delete Test ${i}
  184. END
  185. Fuzzy Multimessage Overwrite Test
  186. FOR ${i} IN @{MESSAGES}
  187. Fuzzy Overwrite Test ${i}
  188. END