Skip to content

Commit

Permalink
✅ Add RFC7162 example responses to parser tests
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
nevans committed Dec 12, 2023
1 parent a29563f commit 207fe5f
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
:tests:

"RFC7162 CONDSTORE 3.1.2.1. HIGHESTMODSEQ Response Code":
:response: "* OK [HIGHESTMODSEQ 715194045007]\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: OK
data: !ruby/struct:Net::IMAP::ResponseText
code: !ruby/struct:Net::IMAP::ResponseCode
name: HIGHESTMODSEQ
data: 715194045007
text: ''
raw_data: "* OK [HIGHESTMODSEQ 715194045007]\r\n"

"RFC7162 CONDSTORE 3.1.2.2. NOMODSEQ Response Code":
:response: "* OK [NOMODSEQ] Sorry, this mailbox format doesn't support
modsequences\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: OK
data: !ruby/struct:Net::IMAP::ResponseText
code: !ruby/struct:Net::IMAP::ResponseCode
name: NOMODSEQ
data:
text: Sorry, this mailbox format doesn't support modsequences
raw_data: "* OK [NOMODSEQ] Sorry, this mailbox format doesn't support
modsequences\r\n"

"RFC7162 CONDSTORE 3.1.3. Example 3 (FETCH MODSEQ)":
:response: "* 4 FETCH (UID 8 MODSEQ (12121230956))\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: FETCH
data: !ruby/struct:Net::IMAP::FetchData
seqno: 4
attr:
UID: 8
MODSEQ: 12121230956
raw_data: "* 4 FETCH (UID 8 MODSEQ (12121230956))\r\n"

"RFC7162 CONDSTORE 3.1.3. Example 4 (FETCH MODSEQ)":
:response: "* 50 FETCH (MODSEQ (12111230048))\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: FETCH
data: !ruby/struct:Net::IMAP::FetchData
seqno: 50
attr:
MODSEQ: 12111230048
raw_data: "* 50 FETCH (MODSEQ (12111230048))\r\n"

"RFC7162 CONDSTORE 3.1.3. Example 6 (MODIFIED Response Code)":
:response: "d105 OK [MODIFIED 7,9] Conditional STORE failed\r\n"
:expected: !ruby/struct:Net::IMAP::TaggedResponse
tag: d105
name: OK
data: !ruby/struct:Net::IMAP::ResponseText
code: !ruby/struct:Net::IMAP::ResponseCode
name: MODIFIED
data: !ruby/object:Net::IMAP::SequenceSet
str: '7,9'
tuples:
- - 7
- 7
- - 9
- 9
text: Conditional STORE failed
raw_data: "d105 OK [MODIFIED 7,9] Conditional STORE failed\r\n"

"RFC7162 CONDSTORE 3.1.5. MODSEQ Search Criterion in SEARCH":
:response: "* SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500)\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: SEARCH
data: !ruby/array:Net::IMAP::SearchResult
internal:
- 2
- 5
- 6
- 7
- 11
- 12
- 18
- 19
- 20
- 23
ivars:
:@modseq: 917162500
raw_data: "* SEARCH 2 5 6 7 11 12 18 19 20 23 (MODSEQ 917162500)\r\n"

"RFC7162 CONDSTORE 3.1.7. HIGHESTMODSEQ Status Data Items":
:response: "* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 HIGHESTMODSEQ
7011231777)\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: STATUS
data: !ruby/struct:Net::IMAP::StatusData
mailbox: blurdybloop
attr:
MESSAGES: 231
UIDNEXT: 44292
HIGHESTMODSEQ: 7011231777
raw_data: "* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292 HIGHESTMODSEQ
7011231777)\r\n"

"RFC7162 QRESYNC 3.2.5.1. Modification Sequence and UID Parameters":
:response: "* VANISHED (EARLIER) 41,43:116,118,120:211,214:540\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: VANISHED
data: !ruby/struct:Net::IMAP::UnparsedData
unparsed_data: "(EARLIER) 41,43:116,118,120:211,214:540"
raw_data: "* VANISHED (EARLIER) 41,43:116,118,120:211,214:540\r\n"
comment: |
Note that QRESYNC isn't supported yet, so the data is unparsed.
"RFC7162 QRESYNC 3.2.7. EXPUNGE Command":
:response: "* VANISHED 405,407,410,425\r\n"
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
name: VANISHED
data: !ruby/struct:Net::IMAP::UnparsedData
unparsed_data: '405,407,410,425'
raw_data: "* VANISHED 405,407,410,425\r\n"
comment: |
Note that QRESYNC isn't supported yet, so the data is unparsed.
3 changes: 3 additions & 0 deletions test/net/imap/test_imap_response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def teardown
# RFC 5256: THREAD response
generate_tests_from fixture_file: "thread_responses.yml"

# RFC 7164: CONDSTORE and QRESYNC responses
generate_tests_from fixture_file: "rfc7162_condstore_qresync_responses.yml"

# RFC 8474: OBJECTID responses
generate_tests_from fixture_file: "rfc8474_objectid_responses.yml"

Expand Down

0 comments on commit 207fe5f

Please sign in to comment.