| 1 |
*** Settings *** |
| 2 |
Test Setup Http Early Response Setup |
| 3 |
Test Teardown Http Early Response Teardown |
| 4 |
Library Process |
| 5 |
Library ${RSPAMD_TESTDIR}/lib/rspamd.py |
| 6 |
Resource ${RSPAMD_TESTDIR}/lib/rspamd.robot |
| 7 |
Variables ${RSPAMD_TESTDIR}/lib/vars.py |
| 8 |
|
| 9 |
*** Variables *** |
| 10 |
${CONFIG} ${RSPAMD_TESTDIR}/configs/lua_test.conf |
| 11 |
${MESSAGE} ${RSPAMD_TESTDIR}/messages/spam_message.eml |
| 12 |
${RSPAMD_LUA_SCRIPT} ${RSPAMD_TESTDIR}/lua/http_early_response.lua |
| 13 |
${RSPAMD_SCOPE} Suite |
| 14 |
${RSPAMD_URL_TLD} ${RSPAMD_TESTDIR}/../lua/unit/test_tld.dat |
| 15 |
|
| 16 |
*** Test Cases *** |
| 17 |
HTTP Early Reply |
| 18 |
[Documentation] Test server sending response before reading request body |
| 19 |
Scan File ${MESSAGE} test-type=early-reply |
| 20 |
... Settings={symbols_enabled = [HTTP_EARLY_RESPONSE_TEST]} |
| 21 |
# We expect either success (200) or an error - both indicate the client handled |
| 22 |
# the early response scenario (success = client received response, error = connection issue) |
| 23 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_EARLY_REPLY_200 |
| 24 |
IF not ${result} |
| 25 |
Expect Symbol HTTP_EARLY_REPLY_ERROR |
| 26 |
END |
| 27 |
|
| 28 |
HTTP Early 413 Error |
| 29 |
[Documentation] Test server sending 413 error before reading request body |
| 30 |
Scan File ${MESSAGE} test-type=early-413 |
| 31 |
... Settings={symbols_enabled = [HTTP_EARLY_RESPONSE_TEST]} |
| 32 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_EARLY_413_413 |
| 33 |
IF not ${result} |
| 34 |
Expect Symbol HTTP_EARLY_413_ERROR |
| 35 |
END |
| 36 |
|
| 37 |
HTTP Keepalive Early Response |
| 38 |
[Documentation] Test keepalive with server sending early response |
| 39 |
Scan File ${MESSAGE} test-type=keepalive-early |
| 40 |
... Settings={symbols_enabled = [HTTP_EARLY_RESPONSE_TEST]} |
| 41 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_KEEPALIVE_EARLY_200 |
| 42 |
IF not ${result} |
| 43 |
Expect Symbol HTTP_KEEPALIVE_EARLY_ERROR |
| 44 |
END |
| 45 |
|
| 46 |
HTTP Early Reply Coroutine |
| 47 |
[Documentation] Test early response with coroutine-based HTTP request |
| 48 |
Scan File ${MESSAGE} test-type=early-coro |
| 49 |
... Settings={symbols_enabled = [HTTP_EARLY_RESPONSE_TEST]} |
| 50 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_EARLY_CORO_200 |
| 51 |
IF not ${result} |
| 52 |
Expect Symbol HTTP_EARLY_CORO_ERROR |
| 53 |
END |
| 54 |
|
| 55 |
HTTP Normal Request Baseline |
| 56 |
[Documentation] Baseline test with normal request handling |
| 57 |
Scan File ${MESSAGE} test-type=normal |
| 58 |
... Settings={symbols_enabled = [HTTP_EARLY_RESPONSE_TEST]} |
| 59 |
Expect Symbol HTTP_NORMAL_200 |
| 60 |
|
| 61 |
HTTP Keepalive Sequential |
| 62 |
[Documentation] Test sequential keepalive requests |
| 63 |
Scan File ${MESSAGE} |
| 64 |
... Settings={symbols_enabled = [HTTP_KEEPALIVE_SEQUENTIAL_TEST]} |
| 65 |
# Should have at least some successful requests |
| 66 |
Expect Symbol HTTP_KEEPALIVE_SEQ_SUCCESS |
| 67 |
|
| 68 |
HTTP Early Keepalive Stress |
| 69 |
[Documentation] Stress test mixing early responses with keepalive |
| 70 |
Scan File ${MESSAGE} |
| 71 |
... Settings={symbols_enabled = [HTTP_EARLY_KEEPALIVE_STRESS_TEST]} |
| 72 |
Expect Symbol HTTP_EARLY_KEEPALIVE_STRESS |
| 73 |
|
| 74 |
HTTP Immediate Close Large Body |
| 75 |
[Documentation] Test server immediately closing connection during large body send |
| 76 |
[Tags] aggressive |
| 77 |
Scan File ${MESSAGE} |
| 78 |
... Settings={symbols_enabled = [HTTP_IMMEDIATE_CLOSE_TEST]} |
| 79 |
# Either we get the 413 response OR an error - both are valid outcomes |
| 80 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_IMMEDIATE_CLOSE_413 |
| 81 |
IF not ${result} |
| 82 |
Expect Symbol HTTP_IMMEDIATE_CLOSE_ERROR |
| 83 |
END |
| 84 |
|
| 85 |
HTTP Slow Response Large Body |
| 86 |
[Documentation] Test server responding slowly while client sends large body |
| 87 |
[Tags] aggressive |
| 88 |
Scan File ${MESSAGE} |
| 89 |
... Settings={symbols_enabled = [HTTP_SLOW_RESPONSE_TEST]} |
| 90 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_SLOW_RESPONSE_200 |
| 91 |
IF not ${result} |
| 92 |
Expect Symbol HTTP_SLOW_RESPONSE_ERROR |
| 93 |
END |
| 94 |
|
| 95 |
HTTP Rapid Close Requests |
| 96 |
[Documentation] Rapid sequential requests to server that closes immediately |
| 97 |
[Tags] aggressive |
| 98 |
Scan File ${MESSAGE} |
| 99 |
... Settings={symbols_enabled = [HTTP_RAPID_CLOSE_TEST]} |
| 100 |
Expect Symbol HTTP_RAPID_CLOSE_RESULTS |
| 101 |
|
| 102 |
HTTP Block And Reply |
| 103 |
[Documentation] TRUE early response test - 512KB body with server not reading |
| 104 |
[Tags] early-response critical |
| 105 |
Scan File ${MESSAGE} |
| 106 |
... Settings={symbols_enabled = [HTTP_BLOCK_REPLY_TEST]} |
| 107 |
# Ideal: HTTP_BLOCK_REPLY_413 (got early response) |
| 108 |
# Acceptable: HTTP_BLOCK_REPLY_ERROR (connection error, but no crash) |
| 109 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_BLOCK_REPLY_413 |
| 110 |
IF not ${result} |
| 111 |
Expect Symbol HTTP_BLOCK_REPLY_ERROR |
| 112 |
END |
| 113 |
|
| 114 |
HTTP Block And Reply Coroutine |
| 115 |
[Documentation] Coroutine version of block-and-reply test |
| 116 |
[Tags] early-response critical |
| 117 |
Scan File ${MESSAGE} |
| 118 |
... Settings={symbols_enabled = [HTTP_BLOCK_REPLY_CORO_TEST]} |
| 119 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_BLOCK_REPLY_CORO_413 |
| 120 |
IF not ${result} |
| 121 |
Expect Symbol HTTP_BLOCK_REPLY_CORO_ERROR |
| 122 |
END |
| 123 |
|
| 124 |
HTTP Block Slow Response |
| 125 |
[Documentation] Server waits 1s then responds - 1MB body |
| 126 |
[Tags] early-response slow |
| 127 |
Scan File ${MESSAGE} |
| 128 |
... Settings={symbols_enabled = [HTTP_BLOCK_SLOW_TEST]} |
| 129 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_BLOCK_SLOW_503 |
| 130 |
IF not ${result} |
| 131 |
Expect Symbol HTTP_BLOCK_SLOW_ERROR |
| 132 |
END |
| 133 |
|
| 134 |
HTTP Instant Reply |
| 135 |
[Documentation] Server responds BEFORE reading headers - most aggressive early response |
| 136 |
[Tags] early-response critical |
| 137 |
Scan File ${MESSAGE} |
| 138 |
... Settings={symbols_enabled = [HTTP_INSTANT_REPLY_TEST]} |
| 139 |
${result} = Run Keyword And Return Status Expect Symbol HTTP_INSTANT_REPLY_413 |
| 140 |
IF not ${result} |
| 141 |
Expect Symbol HTTP_INSTANT_REPLY_ERROR |
| 142 |
END |
| 143 |
|
| 144 |
*** Keywords *** |
| 145 |
Http Early Response Setup |
| 146 |
Run Dummy Http Early Response |
| 147 |
Rspamd Setup |
| 148 |
|
| 149 |
Http Early Response Teardown |
| 150 |
Rspamd Teardown |
| 151 |
Dummy Http Early Teardown |