Skip to content

Commit 207fe5f

Browse files
committed
✅ Add RFC7162 example responses to parser tests
Note that QRESYNC isn't actually supported yet, so `VANISHED` responses are parsed as `response_data__unhandled`, which simply returns a string wrapped in `UnparsedData`.
1 parent a29563f commit 207fe5f

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
:tests:
3+
4+
"RFC7162 CONDSTORE 3.1.2.1. HIGHESTMODSEQ Response Code":
5+
:response: "* OK [HIGHESTMODSEQ 715194045007]\r\n"
6+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
7+
name: OK
8+
data: !ruby/struct:Net::IMAP::ResponseText
9+
code: !ruby/struct:Net::IMAP::ResponseCode
10+
name: HIGHESTMODSEQ
11+
data: 715194045007
12+
text: ''
13+
raw_data: "* OK [HIGHESTMODSEQ 715194045007]\r\n"
14+
15+
"RFC7162 CONDSTORE 3.1.2.2. NOMODSEQ Response Code":
16+
:response: "* OK [NOMODSEQ] Sorry, this mailbox format doesn't support
17+
modsequences\r\n"
18+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
19+
name: OK
20+
data: !ruby/struct:Net::IMAP::ResponseText
21+
code: !ruby/struct:Net::IMAP::ResponseCode
22+
name: NOMODSEQ
23+
data:
24+
text: Sorry, this mailbox format doesn't support modsequences
25+
raw_data: "* OK [NOMODSEQ] Sorry, this mailbox format doesn't support
26+
modsequences\r\n"
27+
28+
"RFC7162 CONDSTORE 3.1.3. Example 3 (FETCH MODSEQ)":
29+
:response: "* 4 FETCH (UID 8 MODSEQ (12121230956))\r\n"
30+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
31+
name: FETCH
32+
data: !ruby/struct:Net::IMAP::FetchData
33+
seqno: 4
34+
attr:
35+
UID: 8
36+
MODSEQ: 12121230956
37+
raw_data: "* 4 FETCH (UID 8 MODSEQ (12121230956))\r\n"
38+
39+
"RFC7162 CONDSTORE 3.1.3. Example 4 (FETCH MODSEQ)":
40+
:response: "* 50 FETCH (MODSEQ (12111230048))\r\n"
41+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
42+
name: FETCH
43+
data: !ruby/struct:Net::IMAP::FetchData
44+
seqno: 50
45+
attr:
46+
MODSEQ: 12111230048
47+
raw_data: "* 50 FETCH (MODSEQ (12111230048))\r\n"
48+
49+
"RFC7162 CONDSTORE 3.1.3. Example 6 (MODIFIED Response Code)":
50+
:response: "d105 OK [MODIFIED 7,9] Conditional STORE failed\r\n"
51+
:expected: !ruby/struct:Net::IMAP::TaggedResponse
52+
tag: d105
53+
name: OK
54+
data: !ruby/struct:Net::IMAP::ResponseText
55+
code: !ruby/struct:Net::IMAP::ResponseCode
56+
name: MODIFIED
57+
data: !ruby/object:Net::IMAP::SequenceSet
58+
str: '7,9'
59+
tuples:
60+
- - 7
61+
- 7
62+
- - 9
63+
- 9
64+
text: Conditional STORE failed
65+
raw_data: "d105 OK [MODIFIED 7,9] Conditional STORE failed\r\n"
66+
67+
"RFC7162 CONDSTORE 3.1.5. MODSEQ Search Criterion in SEARCH":
68+
:response: "* SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500)\r\n"
69+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
70+
name: SEARCH
71+
data: !ruby/array:Net::IMAP::SearchResult
72+
internal:
73+
- 2
74+
- 5
75+
- 6
76+
- 7
77+
- 11
78+
- 12
79+
- 18
80+
- 19
81+
- 20
82+
- 23
83+
ivars:
84+
:@modseq: 917162500
85+
raw_data: "* SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500)\r\n"
86+
87+
"RFC7162 CONDSTORE 3.1.7. HIGHESTMODSEQ Status Data Items":
88+
:response: "* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 HIGHESTMODSEQ
89+
7011231777)\r\n"
90+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
91+
name: STATUS
92+
data: !ruby/struct:Net::IMAP::StatusData
93+
mailbox: blurdybloop
94+
attr:
95+
MESSAGES: 231
96+
UIDNEXT: 44292
97+
HIGHESTMODSEQ: 7011231777
98+
raw_data: "* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 HIGHESTMODSEQ
99+
7011231777)\r\n"
100+
101+
"RFC7162 QRESYNC 3.2.5.1. Modification Sequence and UID Parameters":
102+
:response: "* VANISHED (EARLIER) 41,43:116,118,120:211,214:540\r\n"
103+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
104+
name: VANISHED
105+
data: !ruby/struct:Net::IMAP::UnparsedData
106+
unparsed_data: "(EARLIER) 41,43:116,118,120:211,214:540"
107+
raw_data: "* VANISHED (EARLIER) 41,43:116,118,120:211,214:540\r\n"
108+
comment: |
109+
Note that QRESYNC isn't supported yet, so the data is unparsed.
110+
111+
"RFC7162 QRESYNC 3.2.7. EXPUNGE Command":
112+
:response: "* VANISHED 405,407,410,425\r\n"
113+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
114+
name: VANISHED
115+
data: !ruby/struct:Net::IMAP::UnparsedData
116+
unparsed_data: '405,407,410,425'
117+
raw_data: "* VANISHED 405,407,410,425\r\n"
118+
comment: |
119+
Note that QRESYNC isn't supported yet, so the data is unparsed.

test/net/imap/test_imap_response_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ def teardown
9090
# RFC 5256: THREAD response
9191
generate_tests_from fixture_file: "thread_responses.yml"
9292

93+
# RFC 7164: CONDSTORE and QRESYNC responses
94+
generate_tests_from fixture_file: "rfc7162_condstore_qresync_responses.yml"
95+
9396
# RFC 8474: OBJECTID responses
9497
generate_tests_from fixture_file: "rfc8474_objectid_responses.yml"
9598

0 commit comments

Comments
 (0)