@n8n/imap 0.8.19 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +88 -0
- package/LICENSE_EE.md +27 -0
- package/dist/ImapSimple.d.ts +16 -0
- package/dist/ImapSimple.js +120 -0
- package/dist/ImapSimple.js.map +1 -0
- package/dist/PartData.d.ts +24 -0
- package/dist/PartData.js +109 -0
- package/dist/PartData.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +30 -0
- package/dist/errors.js.map +1 -0
- package/dist/helpers/getMessage.d.ts +3 -0
- package/dist/helpers/getMessage.js +37 -0
- package/dist/helpers/getMessage.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -18
- package/LICENSE +0 -19
- package/README.md +0 -754
- package/deps/encoding/encoding-indexes.js +0 -73
- package/deps/encoding/encoding.js +0 -2340
- package/deps/test/utf7-imap.js +0 -48
- package/deps/test/utf7-rfc2152.js +0 -78
- package/deps/utf7.js +0 -104
- package/index.d.ts +0 -396
- package/lib/Connection.js +0 -2131
- package/lib/Parser.js +0 -1026
- package/test/test-connection-fetch-dup.js +0 -92
- package/test/test-connection-fetch-frag.js +0 -92
- package/test/test-connection-fetch-spillover.js +0 -176
- package/test/test-connection-fetch-stringbody.js +0 -104
- package/test/test-connection-idle-normal.js +0 -144
- package/test/test-connection-idle-order.js +0 -138
- package/test/test-parse-bodystructure.js +0 -83
- package/test/test-parse-envelope-addrs.js +0 -117
- package/test/test-parse-expr.js +0 -92
- package/test/test-parse-header.js +0 -109
- package/test/test-parser.js +0 -543
- package/test/test.js +0 -4
package/test/test-parser.js
DELETED
|
@@ -1,543 +0,0 @@
|
|
|
1
|
-
var Parser = require('../lib/Parser').Parser;
|
|
2
|
-
|
|
3
|
-
var assert = require('assert'),
|
|
4
|
-
crypto = require('crypto'),
|
|
5
|
-
inspect = require('util').inspect;
|
|
6
|
-
|
|
7
|
-
var CR = '\r', LF = '\n', CRLF = CR + LF;
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
{ source: ['A1 OK LOGIN completed', CRLF],
|
|
11
|
-
expected: [ { type: 'ok',
|
|
12
|
-
tagnum: 1,
|
|
13
|
-
textCode: undefined,
|
|
14
|
-
text: 'LOGIN completed'
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
what: 'Tagged OK'
|
|
18
|
-
},
|
|
19
|
-
{ source: ['IDLE OK IDLE terminated', CRLF],
|
|
20
|
-
expected: [ 'IDLE OK IDLE terminated' ],
|
|
21
|
-
what: 'Unknown line'
|
|
22
|
-
},
|
|
23
|
-
{ source: ['IDLE OK Idle completed (0.002 + 1.783 + 1.783 secs).', CRLF],
|
|
24
|
-
expected: [ 'IDLE OK Idle completed (0.002 + 1.783 + 1.783 secs).' ],
|
|
25
|
-
what: 'Unknown line with + char'
|
|
26
|
-
},
|
|
27
|
-
{ source: ['+ idling', CRLF],
|
|
28
|
-
expected: [ { textCode: undefined,
|
|
29
|
-
text: 'idling'
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
what: 'Continuation'
|
|
33
|
-
},
|
|
34
|
-
{ source: ['+ [ALERT] idling', CRLF],
|
|
35
|
-
expected: [ { textCode: 'ALERT',
|
|
36
|
-
text: 'idling'
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
what: 'Continuation with text code'
|
|
40
|
-
},
|
|
41
|
-
{ source: ['+', CRLF],
|
|
42
|
-
expected: [ { textCode: undefined,
|
|
43
|
-
text: undefined
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
what: 'Continuation (broken -- RFC violation) sent by AOL IMAP'
|
|
47
|
-
},
|
|
48
|
-
{ source: ['* NAMESPACE ',
|
|
49
|
-
'(("" "/")) ',
|
|
50
|
-
'(("~" "/")) ',
|
|
51
|
-
'(("#shared/" "/")("#public/" "/")("#ftp/" "/")("#news." "."))',
|
|
52
|
-
CRLF],
|
|
53
|
-
expected: [ { type: 'namespace',
|
|
54
|
-
num: undefined,
|
|
55
|
-
textCode: undefined,
|
|
56
|
-
text: {
|
|
57
|
-
personal: [
|
|
58
|
-
{ prefix: '',
|
|
59
|
-
delimiter: '/',
|
|
60
|
-
extensions: undefined
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
other: [
|
|
64
|
-
{ prefix: '~',
|
|
65
|
-
delimiter: '/',
|
|
66
|
-
extensions: undefined
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
shared: [
|
|
70
|
-
{ prefix: '#shared/',
|
|
71
|
-
delimiter: '/',
|
|
72
|
-
extensions: undefined
|
|
73
|
-
},
|
|
74
|
-
{ prefix: '#public/',
|
|
75
|
-
delimiter: '/',
|
|
76
|
-
extensions: undefined
|
|
77
|
-
},
|
|
78
|
-
{ prefix: '#ftp/',
|
|
79
|
-
delimiter: '/',
|
|
80
|
-
extensions: undefined
|
|
81
|
-
},
|
|
82
|
-
{ prefix: '#news.',
|
|
83
|
-
delimiter: '.',
|
|
84
|
-
extensions: undefined
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
what: 'Multiple namespaces'
|
|
91
|
-
},
|
|
92
|
-
{ source: ['* NAMESPACE ',
|
|
93
|
-
'(("" "/" "X-PARAM" ("FLAG1" "FLAG2"))) ',
|
|
94
|
-
'NIL ',
|
|
95
|
-
'NIL',
|
|
96
|
-
CRLF],
|
|
97
|
-
expected: [ { type: 'namespace',
|
|
98
|
-
num: undefined,
|
|
99
|
-
textCode: undefined,
|
|
100
|
-
text: {
|
|
101
|
-
personal: [
|
|
102
|
-
{ prefix: '',
|
|
103
|
-
delimiter: '/',
|
|
104
|
-
extensions: {
|
|
105
|
-
'X-PARAM': [ 'FLAG1', 'FLAG2' ]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
other: null,
|
|
110
|
-
shared: null
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
what: 'Multiple namespaces'
|
|
115
|
-
},
|
|
116
|
-
{ source: ['* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)', CRLF],
|
|
117
|
-
expected: [ { type: 'flags',
|
|
118
|
-
num: undefined,
|
|
119
|
-
textCode: undefined,
|
|
120
|
-
text: [
|
|
121
|
-
'\\Answered',
|
|
122
|
-
'\\Flagged',
|
|
123
|
-
'\\Deleted',
|
|
124
|
-
'\\Seen',
|
|
125
|
-
'\\Draft'
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
what: 'Flags'
|
|
130
|
-
},
|
|
131
|
-
{ source: ['* SEARCH 2 3 6', CRLF],
|
|
132
|
-
expected: [ { type: 'search',
|
|
133
|
-
num: undefined,
|
|
134
|
-
textCode: undefined,
|
|
135
|
-
text: [ 2, 3, 6 ]
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
what: 'Search'
|
|
139
|
-
},
|
|
140
|
-
{ source: ['* XLIST (\\Noselect) "/" ~/Mail/foo', CRLF],
|
|
141
|
-
expected: [ { type: 'xlist',
|
|
142
|
-
num: undefined,
|
|
143
|
-
textCode: undefined,
|
|
144
|
-
text: {
|
|
145
|
-
flags: [ '\\Noselect' ],
|
|
146
|
-
delimiter: '/',
|
|
147
|
-
name: '~/Mail/foo'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
],
|
|
151
|
-
what: 'XList'
|
|
152
|
-
},
|
|
153
|
-
{ source: ['* LIST (\\Noselect) "/" ~/Mail/foo', CRLF],
|
|
154
|
-
expected: [ { type: 'list',
|
|
155
|
-
num: undefined,
|
|
156
|
-
textCode: undefined,
|
|
157
|
-
text: {
|
|
158
|
-
flags: [ '\\Noselect' ],
|
|
159
|
-
delimiter: '/',
|
|
160
|
-
name: '~/Mail/foo'
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
what: 'List'
|
|
165
|
-
},
|
|
166
|
-
{ source: ['* STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292)', CRLF],
|
|
167
|
-
expected: [ { type: 'status',
|
|
168
|
-
num: undefined,
|
|
169
|
-
textCode: undefined,
|
|
170
|
-
text: {
|
|
171
|
-
name: 'blurdybloop',
|
|
172
|
-
attrs: { messages: 231, uidnext: 44292 }
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
],
|
|
176
|
-
what: 'Status'
|
|
177
|
-
},
|
|
178
|
-
{ source: ['* OK [UNSEEN 17] Message 17 is the first unseen message', CRLF],
|
|
179
|
-
expected: [ { type: 'ok',
|
|
180
|
-
num: undefined,
|
|
181
|
-
textCode: {
|
|
182
|
-
key: 'UNSEEN',
|
|
183
|
-
val: 17
|
|
184
|
-
},
|
|
185
|
-
text: 'Message 17 is the first unseen message'
|
|
186
|
-
}
|
|
187
|
-
],
|
|
188
|
-
what: 'Untagged OK (with text code, with text)'
|
|
189
|
-
},
|
|
190
|
-
{ source: ['* OK [PERMANENTFLAGS (\\Deleted \\Seen \\*)] Limited', CRLF],
|
|
191
|
-
expected: [ { type: 'ok',
|
|
192
|
-
num: undefined,
|
|
193
|
-
textCode: {
|
|
194
|
-
key: 'PERMANENTFLAGS',
|
|
195
|
-
val: [ '\\Deleted', '\\Seen', '\\*' ]
|
|
196
|
-
},
|
|
197
|
-
text: 'Limited'
|
|
198
|
-
}
|
|
199
|
-
],
|
|
200
|
-
what: 'Untagged OK (with text code, with text)'
|
|
201
|
-
},
|
|
202
|
-
{ source: ['* OK [UNSEEN 17]', CRLF],
|
|
203
|
-
expected: [ { type: 'ok',
|
|
204
|
-
num: undefined,
|
|
205
|
-
textCode: {
|
|
206
|
-
key: 'UNSEEN',
|
|
207
|
-
val: 17
|
|
208
|
-
},
|
|
209
|
-
text: undefined
|
|
210
|
-
}
|
|
211
|
-
],
|
|
212
|
-
what: 'Untagged OK (no text code, with text) (RFC violation)'
|
|
213
|
-
},
|
|
214
|
-
{ source: ['* OK IMAP4rev1 Service Ready', CRLF],
|
|
215
|
-
expected: [ { type: 'ok',
|
|
216
|
-
num: undefined,
|
|
217
|
-
textCode: undefined,
|
|
218
|
-
text: 'IMAP4rev1 Service Ready'
|
|
219
|
-
}
|
|
220
|
-
],
|
|
221
|
-
what: 'Untagged OK (no text code, with text)'
|
|
222
|
-
},
|
|
223
|
-
{ source: ['* OK', CRLF], // I have seen servers that send stuff like this ..
|
|
224
|
-
expected: [ { type: 'ok',
|
|
225
|
-
num: undefined,
|
|
226
|
-
textCode: undefined,
|
|
227
|
-
text: undefined
|
|
228
|
-
}
|
|
229
|
-
],
|
|
230
|
-
what: 'Untagged OK (no text code, no text) (RFC violation)'
|
|
231
|
-
},
|
|
232
|
-
{ source: ['* 18 EXISTS', CRLF],
|
|
233
|
-
expected: [ { type: 'exists',
|
|
234
|
-
num: 18,
|
|
235
|
-
textCode: undefined,
|
|
236
|
-
text: undefined
|
|
237
|
-
}
|
|
238
|
-
],
|
|
239
|
-
what: 'Untagged EXISTS'
|
|
240
|
-
},
|
|
241
|
-
{ source: ['* 2 RECENT', CRLF],
|
|
242
|
-
expected: [ { type: 'recent',
|
|
243
|
-
num: 2,
|
|
244
|
-
textCode: undefined,
|
|
245
|
-
text: undefined
|
|
246
|
-
}
|
|
247
|
-
],
|
|
248
|
-
what: 'Untagged RECENT'
|
|
249
|
-
},
|
|
250
|
-
{ source: ['* 12 FETCH (BODY[HEADER] {342}', CRLF,
|
|
251
|
-
'Date: Wed, 17 Jul 1996 02:23:25 -0700 (PDT)', CRLF,
|
|
252
|
-
'From: Terry Gray <gray@cac.washington.edu>', CRLF,
|
|
253
|
-
'Subject: IMAP4rev1 WG mtg summary and minutes', CRLF,
|
|
254
|
-
'To: imap@cac.washington.edu', CRLF,
|
|
255
|
-
'cc: minutes@CNRI.Reston.VA.US, John Klensin <KLENSIN@MIT.EDU>', CRLF,
|
|
256
|
-
'Message-Id: <B27397-0100000@cac.washington.edu>', CRLF,
|
|
257
|
-
'MIME-Version: 1.0', CRLF,
|
|
258
|
-
'Content-Type: TEXT/PLAIN; CHARSET=US-ASCII', CRLF, CRLF,
|
|
259
|
-
')', CRLF],
|
|
260
|
-
expected: [ { seqno: 12,
|
|
261
|
-
which: 'HEADER',
|
|
262
|
-
size: 342
|
|
263
|
-
},
|
|
264
|
-
{ type: 'fetch',
|
|
265
|
-
num: 12,
|
|
266
|
-
textCode: undefined,
|
|
267
|
-
text: {}
|
|
268
|
-
}
|
|
269
|
-
],
|
|
270
|
-
bodySHA1s: ['1f96faf50f6410f99237791f9e3b89454bf93fa7'],
|
|
271
|
-
what: 'Untagged FETCH (body)'
|
|
272
|
-
},
|
|
273
|
-
{ source: ['* 12 FETCH (BODY[TEXT] "IMAP is terrible")', CRLF],
|
|
274
|
-
expected: [ { seqno: 12,
|
|
275
|
-
which: 'TEXT',
|
|
276
|
-
size: 16
|
|
277
|
-
},
|
|
278
|
-
{ type: 'fetch',
|
|
279
|
-
num: 12,
|
|
280
|
-
textCode: undefined,
|
|
281
|
-
text: {}
|
|
282
|
-
}
|
|
283
|
-
],
|
|
284
|
-
bodySHA1s: ['bac8a1528c133787a6969a10a1ff453ebb9adfc8'],
|
|
285
|
-
what: 'Untagged FETCH (quoted body)'
|
|
286
|
-
},
|
|
287
|
-
{ source: ['* 12 FETCH (BODY[TEXT] "\\"IMAP\\" is terrible :\\\\")', CRLF],
|
|
288
|
-
expected: [ { seqno: 12,
|
|
289
|
-
which: 'TEXT',
|
|
290
|
-
size: 21
|
|
291
|
-
},
|
|
292
|
-
{ type: 'fetch',
|
|
293
|
-
num: 12,
|
|
294
|
-
textCode: undefined,
|
|
295
|
-
text: {}
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
bodySHA1s: ['7570c08150050a404603f63f60b65b42378d7d42'],
|
|
299
|
-
what: 'Untagged FETCH (quoted body with escaped chars)'
|
|
300
|
-
},
|
|
301
|
-
{ source: ['* 12 FETCH (INTERNALDATE {26}', CRLF,
|
|
302
|
-
'17-Jul-1996 02:44:25 -0700)' + CRLF],
|
|
303
|
-
expected: [ { type: 'fetch',
|
|
304
|
-
num: 12,
|
|
305
|
-
textCode: undefined,
|
|
306
|
-
text: {
|
|
307
|
-
internaldate: new Date('17-Jul-1996 02:44:25 -0700')
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
],
|
|
311
|
-
what: 'Untagged FETCH with non-body literal'
|
|
312
|
-
},
|
|
313
|
-
{ source: ['* 12 FETCH (INTERNALDATE {2',
|
|
314
|
-
'6}' + CRLF + '17-Jul-1996 02:44:25 -0700)' + CRLF],
|
|
315
|
-
expected: [ { type: 'fetch',
|
|
316
|
-
num: 12,
|
|
317
|
-
textCode: undefined,
|
|
318
|
-
text: {
|
|
319
|
-
internaldate: new Date('17-Jul-1996 02:44:25 -0700')
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
],
|
|
323
|
-
what: 'Untagged FETCH with non-body literal (length split)'
|
|
324
|
-
},
|
|
325
|
-
{ source: ['* 12 FETCH (INTERNALDATE {26}', CRLF,
|
|
326
|
-
'17-Jul-1996 02:44:25 -0700)' + CR,
|
|
327
|
-
LF],
|
|
328
|
-
expected: [ { type: 'fetch',
|
|
329
|
-
num: 12,
|
|
330
|
-
textCode: undefined,
|
|
331
|
-
text: {
|
|
332
|
-
internaldate: new Date('17-Jul-1996 02:44:25 -0700')
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
],
|
|
336
|
-
what: 'Untagged FETCH with non-body literal (split CRLF)'
|
|
337
|
-
},
|
|
338
|
-
{ source: ['* 12 FETCH (FLAGS (\\Seen)',
|
|
339
|
-
' INTERNALDATE "17-Jul-1996 02:44:25 -0700"',
|
|
340
|
-
' RFC822.SIZE 4286',
|
|
341
|
-
' ENVELOPE ("Wed, 17 Jul 1996 02:23:25 -0700 (PDT)"',
|
|
342
|
-
' "IMAP4rev1 WG mtg summary and minutes"',
|
|
343
|
-
' (("Terry Gray" NIL "gray" "cac.washington.edu"))',
|
|
344
|
-
' (("Terry Gray" NIL "gray" "cac.washington.edu"))',
|
|
345
|
-
' (("Terry Gray" NIL "gray" "cac.washington.edu"))',
|
|
346
|
-
' ((NIL NIL "imap" "cac.washington.edu"))',
|
|
347
|
-
' ((NIL NIL "minutes" "CNRI.Reston.VA.US")',
|
|
348
|
-
'("John Klensin" NIL "KLENSIN" "MIT.EDU")) NIL NIL',
|
|
349
|
-
' "<B27397-0100000@cac.washington.edu>")',
|
|
350
|
-
' BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028',
|
|
351
|
-
' 92))',
|
|
352
|
-
CRLF],
|
|
353
|
-
expected: [ { type: 'fetch',
|
|
354
|
-
num: 12,
|
|
355
|
-
textCode: undefined,
|
|
356
|
-
text: {
|
|
357
|
-
flags: [ '\\Seen' ],
|
|
358
|
-
internaldate: new Date('17-Jul-1996 02:44:25 -0700'),
|
|
359
|
-
'rfc822.size': 4286,
|
|
360
|
-
envelope: {
|
|
361
|
-
date: new Date('Wed, 17 Jul 1996 02:23:25 -0700 (PDT)'),
|
|
362
|
-
subject: 'IMAP4rev1 WG mtg summary and minutes',
|
|
363
|
-
from: [
|
|
364
|
-
{ name: 'Terry Gray',
|
|
365
|
-
mailbox: 'gray',
|
|
366
|
-
host: 'cac.washington.edu'
|
|
367
|
-
}
|
|
368
|
-
],
|
|
369
|
-
sender: [
|
|
370
|
-
{ name: 'Terry Gray',
|
|
371
|
-
mailbox: 'gray',
|
|
372
|
-
host: 'cac.washington.edu'
|
|
373
|
-
}
|
|
374
|
-
],
|
|
375
|
-
replyTo: [
|
|
376
|
-
{ name: 'Terry Gray',
|
|
377
|
-
mailbox: 'gray',
|
|
378
|
-
host: 'cac.washington.edu'
|
|
379
|
-
}
|
|
380
|
-
],
|
|
381
|
-
to: [
|
|
382
|
-
{ name: null,
|
|
383
|
-
mailbox: 'imap',
|
|
384
|
-
host: 'cac.washington.edu'
|
|
385
|
-
}
|
|
386
|
-
],
|
|
387
|
-
cc: [
|
|
388
|
-
{ name: null,
|
|
389
|
-
mailbox: 'minutes',
|
|
390
|
-
host: 'CNRI.Reston.VA.US'
|
|
391
|
-
},
|
|
392
|
-
{ name: 'John Klensin',
|
|
393
|
-
mailbox: 'KLENSIN',
|
|
394
|
-
host: 'MIT.EDU'
|
|
395
|
-
}
|
|
396
|
-
],
|
|
397
|
-
bcc: null,
|
|
398
|
-
inReplyTo: null,
|
|
399
|
-
messageId: '<B27397-0100000@cac.washington.edu>'
|
|
400
|
-
},
|
|
401
|
-
body: [
|
|
402
|
-
{ partID: '1',
|
|
403
|
-
type: 'text',
|
|
404
|
-
subtype: 'plain',
|
|
405
|
-
params: { charset: 'US-ASCII' },
|
|
406
|
-
id: null,
|
|
407
|
-
description: null,
|
|
408
|
-
encoding: '7BIT',
|
|
409
|
-
size: 3028,
|
|
410
|
-
lines: 92
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
],
|
|
416
|
-
what: 'Untagged FETCH (flags, date, size, envelope, body[structure])'
|
|
417
|
-
},
|
|
418
|
-
// EXTENSIONS ================================================================
|
|
419
|
-
{ source: ['* ESEARCH (TAG "A285") UID MIN 7 MAX 3800', CRLF],
|
|
420
|
-
expected: [ { type: 'esearch',
|
|
421
|
-
num: undefined,
|
|
422
|
-
textCode: undefined,
|
|
423
|
-
text: { min: 7, max: 3800 }
|
|
424
|
-
}
|
|
425
|
-
],
|
|
426
|
-
what: 'ESearch UID, 2 items'
|
|
427
|
-
},
|
|
428
|
-
{ source: ['* ESEARCH (TAG "A284") MIN 4', CRLF],
|
|
429
|
-
expected: [ { type: 'esearch',
|
|
430
|
-
num: undefined,
|
|
431
|
-
textCode: undefined,
|
|
432
|
-
text: { min: 4 }
|
|
433
|
-
}
|
|
434
|
-
],
|
|
435
|
-
what: 'ESearch 1 item'
|
|
436
|
-
},
|
|
437
|
-
{ source: ['* ESEARCH (TAG "A283") ALL 2,10:11', CRLF],
|
|
438
|
-
expected: [ { type: 'esearch',
|
|
439
|
-
num: undefined,
|
|
440
|
-
textCode: undefined,
|
|
441
|
-
text: { all: [ '2', '10:11' ] }
|
|
442
|
-
}
|
|
443
|
-
],
|
|
444
|
-
what: 'ESearch ALL list'
|
|
445
|
-
},
|
|
446
|
-
{ source: ['* QUOTA "" (STORAGE 10 512)', CRLF],
|
|
447
|
-
expected: [ { type: 'quota',
|
|
448
|
-
num: undefined,
|
|
449
|
-
textCode: undefined,
|
|
450
|
-
text: {
|
|
451
|
-
root: '',
|
|
452
|
-
resources: {
|
|
453
|
-
storage: { usage: 10, limit: 512 }
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
],
|
|
458
|
-
what: 'Quota'
|
|
459
|
-
},
|
|
460
|
-
{ source: ['* QUOTAROOT INBOX ""', CRLF],
|
|
461
|
-
expected: [ { type: 'quotaroot',
|
|
462
|
-
num: undefined,
|
|
463
|
-
textCode: undefined,
|
|
464
|
-
text: {
|
|
465
|
-
roots: [ '' ],
|
|
466
|
-
mailbox: 'INBOX'
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
],
|
|
470
|
-
what: 'QuotaRoot'
|
|
471
|
-
},
|
|
472
|
-
{ source: ['A1 OK', CRLF], // some servers like ppops.net sends such response
|
|
473
|
-
expected: [ { type: 'ok',
|
|
474
|
-
tagnum: 1,
|
|
475
|
-
textCode: undefined,
|
|
476
|
-
text: ''
|
|
477
|
-
}
|
|
478
|
-
],
|
|
479
|
-
what: 'Tagged OK (no text code, no text)'
|
|
480
|
-
},
|
|
481
|
-
].forEach(function(v) {
|
|
482
|
-
var ss = new require('stream').Readable(), p, result = [];
|
|
483
|
-
ss._read = function(){};
|
|
484
|
-
|
|
485
|
-
p = new Parser(ss);
|
|
486
|
-
p.on('tagged', function(info) {
|
|
487
|
-
result.push(info);
|
|
488
|
-
});
|
|
489
|
-
p.on('untagged', function(info) {
|
|
490
|
-
result.push(info);
|
|
491
|
-
});
|
|
492
|
-
p.on('continue', function(info) {
|
|
493
|
-
result.push(info);
|
|
494
|
-
});
|
|
495
|
-
p.on('other', function(line) {
|
|
496
|
-
result.push(line);
|
|
497
|
-
});
|
|
498
|
-
p.on('body', function(stream, info) {
|
|
499
|
-
result.push(info);
|
|
500
|
-
if (Array.isArray(v.bodySHA1s)) {
|
|
501
|
-
var hash = crypto.createHash('sha1');
|
|
502
|
-
stream.on('data', function(d) {
|
|
503
|
-
hash.update(d);
|
|
504
|
-
});
|
|
505
|
-
stream.on('end', function() {
|
|
506
|
-
var calculated = hash.digest('hex'),
|
|
507
|
-
expected = v.bodySHA1s.shift();
|
|
508
|
-
assert.equal(calculated,
|
|
509
|
-
expected,
|
|
510
|
-
makeMsg(v.what,
|
|
511
|
-
'Body SHA1 mismatch:'
|
|
512
|
-
+ '\nCalculated: ' + calculated
|
|
513
|
-
+ '\nExpected: ' + expected
|
|
514
|
-
)
|
|
515
|
-
);
|
|
516
|
-
});
|
|
517
|
-
} else
|
|
518
|
-
stream.resume();
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
try {
|
|
522
|
-
v.source.forEach(function(chunk) {
|
|
523
|
-
ss.push(chunk);
|
|
524
|
-
});
|
|
525
|
-
} catch (e) {
|
|
526
|
-
console.log(makeMsg(v.what, 'JS Exception: ' + e.stack));
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
setImmediate(function() {
|
|
530
|
-
assert.deepEqual(result,
|
|
531
|
-
v.expected,
|
|
532
|
-
makeMsg(v.what,
|
|
533
|
-
'Result mismatch:'
|
|
534
|
-
+ '\nParsed: ' + inspect(result, false, 10)
|
|
535
|
-
+ '\nExpected: ' + inspect(v.expected, false, 10)
|
|
536
|
-
)
|
|
537
|
-
);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
function makeMsg(what, msg) {
|
|
542
|
-
return '[' + what + ']: ' + msg;
|
|
543
|
-
}
|
package/test/test.js
DELETED