Debian Codegraph @

test/functional/cases/560_metadata_exporter_structured.robot

raw
1 *** Settings ***
2 Test Setup Metadata Exporter Structured Setup
3 Test Teardown Metadata Exporter Structured 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/metadata_exporter_structured.conf
11 ${MESSAGE} ${RSPAMD_TESTDIR}/messages/spam_message.eml
12 ${ATTACHMENT_MESSAGE} ${RSPAMD_TESTDIR}/messages/zip.eml
13 ${RSPAMD_LUA_SCRIPT} ${RSPAMD_TESTDIR}/lua/metadata_exporter_structured.lua
14 ${RSPAMD_SCOPE} Suite
15 ${RSPAMD_URL_TLD} ${RSPAMD_TESTDIR}/../lua/unit/test_tld.dat
16 ${REDIS_SCOPE} Suite
17
18 *** Test Cases ***
19 Structured export to Redis stream - UUID v7 and metadata
20 [Documentation] Export structured metadata to Redis stream, decode msgpack and verify UUID v7 format
21 # Scan message - triggers default selector
22 Scan File ${MESSAGE}
23 ... Settings={symbols_enabled = []}
24
25 # Wait for async export to complete
26 Sleep 1s
27
28 # Read and decode msgpack from Redis stream
29 ${data} = Redis Stream Read Msgpack ${RSPAMD_REDIS_ADDR} ${RSPAMD_REDIS_PORT} test:structured
30 Log ${data}
31
32 # Validate required fields and UUID v7 format
33 Validate Structured Metadata ${data} uuid,ip,score,action
34
35 Structured export with zstd compression
36 [Documentation] Export with zstd compression on content fields
37 Scan File ${MESSAGE}
38 ... Settings={symbols_enabled = []}
39
40 # Wait for async export
41 Sleep 1s
42
43 # Read from zstd stream
44 ${data} = Redis Stream Read Msgpack ${RSPAMD_REDIS_ADDR} ${RSPAMD_REDIS_PORT} test:structured_zstd
45 Log ${data}
46
47 # Validate required fields
48 Validate Structured Metadata ${data} uuid,ip,score
49
50 # Verify zstd compression markers are set
51 ${count} = Validate Zstd Compressed Fields ${data}
52 Log Compressed fields count: ${count}
53
54 Attachment with detected MIME type
55 [Documentation] Scan message with attachment and verify content_type in export
56 Scan File ${ATTACHMENT_MESSAGE}
57 ... Settings={symbols_enabled = []}
58
59 # Wait for async export
60 Sleep 1s
61
62 # Read from stream
63 ${data} = Redis Stream Read Msgpack ${RSPAMD_REDIS_ADDR} ${RSPAMD_REDIS_PORT} test:structured
64 Log ${data}
65
66 # Validate required fields
67 Validate Structured Metadata ${data} uuid,ip,score
68
69 # Verify attachments have content_type
70 ${count} = Validate Attachments Have Content Type ${data}
71 Should Be True ${count} >= 1 msg=Expected at least 1 attachment with content_type
72
73 *** Keywords ***
74 Metadata Exporter Structured Setup
75 Run Redis
76 Rspamd Setup
77
78 Metadata Exporter Structured Teardown
79 Rspamd Teardown
80 Redis Teardown