rims 0.2.5 → 0.3.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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/CHANGELOG.md +96 -0
- data/ChangeLog +109 -0
- data/Rakefile +8 -4
- data/lib/rims.rb +31 -29
- data/lib/rims/channel.rb +35 -10
- data/lib/rims/cmd.rb +153 -31
- data/lib/rims/error.rb +15 -0
- data/lib/rims/protocol.rb +28 -7
- data/lib/rims/protocol/decoder.rb +763 -469
- data/lib/rims/protocol/parser.rb +316 -181
- data/lib/rims/service.rb +190 -57
- data/lib/rims/test.rb +46 -17
- data/lib/rims/version.rb +1 -1
- data/load_test/Rakefile +3 -1
- data/rims.gemspec +14 -12
- data/test/cmd/test_command.rb +135 -23
- data/test/test_channel.rb +2 -1
- data/test/test_error.rb +33 -1
- data/test/test_lock.rb +4 -4
- data/test/test_passwd.rb +1 -1
- data/test/test_protocol_decoder.rb +733 -75
- data/test/test_protocol_fetch.rb +384 -189
- data/test/test_protocol_request.rb +305 -280
- data/test/test_protocol_search.rb +771 -892
- data/test/test_service.rb +165 -0
- metadata +34 -8
- data/lib/rims/rfc822.rb +0 -463
- data/test/test_rfc822.rb +0 -696
data/test/test_protocol_fetch.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
+
require 'digest'
|
3
4
|
require 'logger'
|
4
5
|
require 'rims'
|
5
6
|
require 'set'
|
@@ -162,7 +163,7 @@ module RIMS::Test
|
|
162
163
|
assert_fetch(0, [ "BODY[] #{literal(@simple_mail.raw_source)}" ])
|
163
164
|
assert_fetch(1, [ "BODY[] #{literal(@mpart_mail.raw_source)}" ])
|
164
165
|
assert_fetch(2, [ 'BODY[] ""' ])
|
165
|
-
assert_fetch(3, [
|
166
|
+
assert_fetch(3, [ "BODY[] #{literal(@no_body_mail.raw_source)}" ])
|
166
167
|
}
|
167
168
|
|
168
169
|
parse_fetch_attribute(make_body('BODY[TEXT]')) {
|
@@ -176,7 +177,7 @@ module RIMS::Test
|
|
176
177
|
assert_fetch(0, [ "BODY[HEADER] #{literal(@simple_mail.header.raw_source)}" ])
|
177
178
|
assert_fetch(1, [ "BODY[HEADER] #{literal(@mpart_mail.header.raw_source)}" ])
|
178
179
|
assert_fetch(2, [ 'BODY[HEADER] ""' ])
|
179
|
-
assert_fetch(3, [
|
180
|
+
assert_fetch(3, [ "BODY[HEADER] #{literal(@no_body_mail.header.raw_source)}" ])
|
180
181
|
}
|
181
182
|
|
182
183
|
parse_fetch_attribute(make_body('BODY[HEADER.FIELDS (From To)]')) {
|
@@ -441,100 +442,251 @@ module RIMS::Test
|
|
441
442
|
add_mail_no_body
|
442
443
|
}
|
443
444
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
445
|
+
parse_fetch_attribute('BODY') {
|
446
|
+
assert_fetch(0,
|
447
|
+
[
|
448
|
+
'BODY ' +
|
449
|
+
encode_bodystructure([ 'TEXT',
|
450
|
+
'PLAIN',
|
451
|
+
%w[ charset us-ascii ],
|
452
|
+
nil,
|
453
|
+
nil,
|
454
|
+
'7BIT',
|
455
|
+
@simple_mail.raw_source.bytesize,
|
456
|
+
@simple_mail.raw_source.each_line.count
|
457
|
+
])
|
458
|
+
])
|
459
|
+
assert_fetch(1,
|
460
|
+
[
|
461
|
+
'BODY ' +
|
462
|
+
encode_bodystructure([ [ 'TEXT', 'PLAIN', %w[ charset us-ascii], nil, nil, nil,
|
463
|
+
@mpart_mail.parts[0].raw_source.bytesize,
|
464
|
+
@mpart_mail.parts[0].raw_source.each_line.count
|
465
|
+
],
|
466
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
467
|
+
@mpart_mail.parts[1].raw_source.bytesize
|
468
|
+
],
|
469
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
470
|
+
@mpart_mail.parts[2].raw_source.bytesize,
|
471
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
472
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
463
473
|
],
|
464
|
-
[ '
|
465
|
-
|
474
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
475
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.bytesize,
|
476
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.each_line.count
|
477
|
+
],
|
478
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
479
|
+
@mpart_mail.parts[2].message.parts[1].raw_source.bytesize
|
480
|
+
],
|
481
|
+
'MIXED'
|
466
482
|
],
|
467
|
-
[
|
468
|
-
|
483
|
+
@mpart_mail.parts[2].raw_source.each_line.count
|
484
|
+
],
|
485
|
+
[ [ 'IMAGE', 'GIF', nil, nil, nil, nil,
|
486
|
+
@mpart_mail.parts[3].parts[0].raw_source.bytesize
|
487
|
+
],
|
488
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
489
|
+
@mpart_mail.parts[3].parts[1].raw_source.bytesize,
|
469
490
|
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
470
491
|
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
471
492
|
],
|
472
493
|
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
473
|
-
@mpart_mail.parts[
|
474
|
-
@mpart_mail.parts[
|
494
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.bytesize,
|
495
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.each_line.count
|
475
496
|
],
|
476
|
-
[ '
|
477
|
-
|
497
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
498
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.bytesize,
|
499
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.each_line.count
|
500
|
+
],
|
501
|
+
[ 'TEXT', 'HTML', %w[ charset us-ascii ], nil, nil, nil,
|
502
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.bytesize,
|
503
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.each_line.count
|
504
|
+
],
|
505
|
+
'ALTERNATIVE'
|
478
506
|
],
|
479
507
|
'MIXED'
|
480
508
|
],
|
481
|
-
@mpart_mail.parts[
|
509
|
+
@mpart_mail.parts[3].parts[1].raw_source.each_line.count
|
510
|
+
],
|
511
|
+
'MIXED',
|
512
|
+
],
|
513
|
+
'MIXED'
|
514
|
+
])
|
515
|
+
])
|
516
|
+
assert_fetch(2,
|
517
|
+
[
|
518
|
+
'BODY ' +
|
519
|
+
encode_bodystructure([ 'TEXT',
|
520
|
+
'PLAIN',
|
521
|
+
nil,
|
522
|
+
nil,
|
523
|
+
nil,
|
524
|
+
nil,
|
525
|
+
@empty_mail.raw_source.bytesize,
|
526
|
+
@empty_mail.raw_source.each_line.count
|
527
|
+
])
|
528
|
+
])
|
529
|
+
assert_fetch(3,
|
530
|
+
[
|
531
|
+
'BODY ' +
|
532
|
+
encode_bodystructure([ 'TEXT',
|
533
|
+
'PLAIN',
|
534
|
+
nil,
|
535
|
+
nil,
|
536
|
+
nil,
|
537
|
+
nil,
|
538
|
+
@no_body_mail.raw_source.bytesize,
|
539
|
+
@no_body_mail.raw_source.each_line.count
|
540
|
+
])
|
541
|
+
])
|
542
|
+
}
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_parse_bodystructure_extension_data
|
546
|
+
make_fetch_parser{
|
547
|
+
add_mail_simple
|
548
|
+
add_mail_multipart
|
549
|
+
add_mail_empty
|
550
|
+
add_mail_no_body
|
551
|
+
}
|
552
|
+
|
553
|
+
parse_fetch_attribute('BODYSTRUCTURE') {
|
554
|
+
assert_fetch(0,
|
555
|
+
[
|
556
|
+
'BODYSTRUCTURE ' +
|
557
|
+
encode_bodystructure([ 'TEXT',
|
558
|
+
'PLAIN',
|
559
|
+
%w[ charset us-ascii ],
|
560
|
+
nil,
|
561
|
+
nil,
|
562
|
+
'7BIT',
|
563
|
+
@simple_mail.raw_source.bytesize,
|
564
|
+
@simple_mail.raw_source.each_line.count,
|
565
|
+
[ Digest::MD5.digest(@simple_mail_body) ].pack('m').strip,
|
566
|
+
nil,
|
567
|
+
%w[ EN-US EN ],
|
568
|
+
nil
|
569
|
+
])
|
570
|
+
])
|
571
|
+
assert_fetch(1,
|
572
|
+
[
|
573
|
+
'BODYSTRUCTURE ' +
|
574
|
+
encode_bodystructure([ [ 'TEXT', 'PLAIN', %w[ charset us-ascii], nil, nil, nil,
|
575
|
+
@mpart_mail.parts[0].raw_source.bytesize,
|
576
|
+
@mpart_mail.parts[0].raw_source.each_line.count,
|
577
|
+
nil, nil, nil, nil
|
578
|
+
],
|
579
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
580
|
+
@mpart_mail.parts[1].raw_source.bytesize,
|
581
|
+
nil,
|
582
|
+
[ 'ATTACHMENT', [ 'filename', 'test.dat', 'modification-date', 'Wed, 12 Feb 1997 16:29:51 -0500' ] ],
|
583
|
+
nil, nil
|
584
|
+
],
|
585
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
586
|
+
@mpart_mail.parts[2].raw_source.bytesize,
|
587
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
588
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
589
|
+
],
|
590
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
591
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.bytesize,
|
592
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.each_line.count,
|
593
|
+
nil, nil, nil, nil
|
594
|
+
],
|
595
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
596
|
+
@mpart_mail.parts[2].message.parts[1].raw_source.bytesize,
|
597
|
+
nil, nil, nil, nil
|
598
|
+
],
|
599
|
+
'MIXED',
|
600
|
+
%w[ boundary 1383.905529.351298 ],
|
601
|
+
[ 'ATTACHMENT', %w[ filename hello.txt ] ],
|
602
|
+
'EN',
|
603
|
+
'test'
|
482
604
|
],
|
483
|
-
[
|
484
|
-
|
605
|
+
@mpart_mail.parts[2].raw_source.each_line.count,
|
606
|
+
nil, nil, nil, nil
|
607
|
+
],
|
608
|
+
[ [ 'IMAGE', 'GIF', nil, nil, nil, nil,
|
609
|
+
@mpart_mail.parts[3].parts[0].raw_source.bytesize,
|
610
|
+
nil,
|
611
|
+
[ 'INLINE', nil ],
|
612
|
+
nil, nil
|
613
|
+
],
|
614
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
615
|
+
@mpart_mail.parts[3].parts[1].raw_source.bytesize,
|
616
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
617
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
485
618
|
],
|
486
|
-
[ '
|
487
|
-
|
488
|
-
|
489
|
-
|
619
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
620
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.bytesize,
|
621
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.each_line.count,
|
622
|
+
nil, nil, nil,
|
623
|
+
'foo'
|
490
624
|
],
|
491
625
|
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
492
|
-
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.bytesize,
|
493
|
-
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.each_line.count
|
626
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.bytesize,
|
627
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.each_line.count,
|
628
|
+
nil, nil, nil,
|
629
|
+
'bar'
|
494
630
|
],
|
495
|
-
[
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.bytesize,
|
501
|
-
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.each_line.count
|
502
|
-
],
|
503
|
-
'ALTERNATIVE'
|
631
|
+
[ 'TEXT', 'HTML', %w[ charset us-ascii ], nil, nil, nil,
|
632
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.bytesize,
|
633
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.each_line.count,
|
634
|
+
nil, nil, nil,
|
635
|
+
'baz'
|
504
636
|
],
|
505
|
-
'
|
637
|
+
'ALTERNATIVE',
|
638
|
+
%w[ boundary 1383.905529.351301 ],
|
639
|
+
nil, nil, nil
|
506
640
|
],
|
507
|
-
|
641
|
+
'MIXED',
|
642
|
+
%w[ boundary 1383.905529.351300 ],
|
643
|
+
nil, nil, nil
|
508
644
|
],
|
509
|
-
|
645
|
+
@mpart_mail.parts[3].parts[1].raw_source.each_line.count,
|
646
|
+
nil, nil, nil, nil
|
510
647
|
],
|
511
|
-
'MIXED'
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
648
|
+
'MIXED',
|
649
|
+
%w[ boundary 1383.905529.351299 ],
|
650
|
+
nil, nil, nil
|
651
|
+
],
|
652
|
+
'MIXED',
|
653
|
+
%w[ boundary 1383.905529.351297 ],
|
654
|
+
nil, nil, nil
|
655
|
+
])
|
656
|
+
])
|
657
|
+
assert_fetch(2, [
|
658
|
+
'BODYSTRUCTURE ' +
|
659
|
+
encode_bodystructure([ 'TEXT',
|
660
|
+
'PLAIN',
|
661
|
+
nil,
|
662
|
+
nil,
|
663
|
+
nil,
|
664
|
+
nil,
|
665
|
+
@empty_mail.raw_source.bytesize,
|
666
|
+
@empty_mail.raw_source.each_line.count,
|
667
|
+
nil,
|
668
|
+
nil,
|
669
|
+
nil,
|
670
|
+
nil
|
671
|
+
])
|
672
|
+
])
|
673
|
+
assert_fetch(3, [
|
674
|
+
'BODYSTRUCTURE ' +
|
675
|
+
encode_bodystructure([ 'TEXT',
|
676
|
+
'PLAIN',
|
677
|
+
nil,
|
678
|
+
nil,
|
679
|
+
nil,
|
680
|
+
nil,
|
681
|
+
@no_body_mail.raw_source.bytesize,
|
682
|
+
@no_body_mail.raw_source.each_line.count,
|
683
|
+
nil,
|
684
|
+
nil,
|
685
|
+
nil,
|
686
|
+
nil
|
687
|
+
])
|
688
|
+
])
|
689
|
+
}
|
538
690
|
end
|
539
691
|
|
540
692
|
def test_parse_envelope
|
@@ -590,7 +742,7 @@ module RIMS::Test
|
|
590
742
|
]
|
591
743
|
])
|
592
744
|
assert_fetch(3, [ 'ENVELOPE (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)' ])
|
593
|
-
assert_fetch(4, [ 'ENVELOPE (NIL
|
745
|
+
assert_fetch(4, [ 'ENVELOPE (NIL "foo" NIL NIL NIL NIL NIL NIL NIL NIL)' ])
|
594
746
|
assert_fetch(5, [
|
595
747
|
'ENVELOPE',
|
596
748
|
[ '"Fri, 8 Nov 2013 06:47:50 +0900 (JST)"', # Date
|
@@ -734,10 +886,10 @@ module RIMS::Test
|
|
734
886
|
@mpart_mail.parts[0].raw_source.bytesize,
|
735
887
|
@mpart_mail.parts[0].raw_source.each_line.count
|
736
888
|
],
|
737
|
-
[ 'APPLICATION', 'OCTET-STREAM',
|
889
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
738
890
|
@mpart_mail.parts[1].raw_source.bytesize
|
739
891
|
],
|
740
|
-
[ 'MESSAGE', 'RFC822',
|
892
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
741
893
|
@mpart_mail.parts[2].raw_source.bytesize,
|
742
894
|
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
743
895
|
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
@@ -746,7 +898,7 @@ module RIMS::Test
|
|
746
898
|
@mpart_mail.parts[2].message.parts[0].raw_source.bytesize,
|
747
899
|
@mpart_mail.parts[2].message.parts[0].raw_source.each_line.count
|
748
900
|
],
|
749
|
-
[ 'APPLICATION', 'OCTET-STREAM',
|
901
|
+
[ 'APPLICATION', 'OCTET-STREAM', nil, nil, nil, nil,
|
750
902
|
@mpart_mail.parts[2].message.parts[1].raw_source.bytesize
|
751
903
|
],
|
752
904
|
'MIXED'
|
@@ -754,10 +906,10 @@ module RIMS::Test
|
|
754
906
|
@mpart_mail.parts[2].raw_source.each_line.count
|
755
907
|
],
|
756
908
|
[
|
757
|
-
[ 'IMAGE', 'GIF',
|
909
|
+
[ 'IMAGE', 'GIF', nil, nil, nil, nil,
|
758
910
|
@mpart_mail.parts[3].parts[0].raw_source.bytesize
|
759
911
|
],
|
760
|
-
[ 'MESSAGE', 'RFC822',
|
912
|
+
[ 'MESSAGE', 'RFC822', nil, nil, nil, nil,
|
761
913
|
@mpart_mail.parts[3].parts[1].raw_source.bytesize,
|
762
914
|
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
763
915
|
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
@@ -932,112 +1084,155 @@ module RIMS::Test
|
|
932
1084
|
assert_equal(expected_value, RIMS::Protocol::FetchParser::Utils.encode_list(array))
|
933
1085
|
end
|
934
1086
|
|
935
|
-
data('text/plain' =>
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1087
|
+
data('text/plain' =>
|
1088
|
+
[ '("TEXT" "PLAIN" ("CHARSET" "UTF-8") NIL NIL "BASE64" 16722 335)',
|
1089
|
+
[ 'TEXT',
|
1090
|
+
'PLAIN',
|
1091
|
+
%w[ CHARSET UTF-8 ],
|
1092
|
+
nil,
|
1093
|
+
nil,
|
1094
|
+
'BASE64',
|
1095
|
+
16722,
|
1096
|
+
335
|
1097
|
+
]
|
1098
|
+
],
|
1099
|
+
|
1100
|
+
'multipart/alternative' =>
|
1101
|
+
[ '(("TEXT" "PLAIN" ("CHARSET" "UTF-8" "DELSP" "yes" "FORMAT" "flowed") NIL NIL "BASE64" 1756 36)("TEXT" "HTML" ("CHARSET" "UTF-8") NIL NIL "QUOTED-PRINTABLE" 5921 119) "ALTERNATIVE")',
|
1102
|
+
[ [ 'TEXT',
|
1103
|
+
'PLAIN',
|
1104
|
+
%w[ CHARSET UTF-8 DELSP yes FORMAT flowed ],
|
1105
|
+
nil,
|
1106
|
+
nil,
|
1107
|
+
'BASE64',
|
1108
|
+
1756,
|
1109
|
+
36
|
1110
|
+
],
|
1111
|
+
[ 'TEXT',
|
1112
|
+
'HTML',
|
1113
|
+
%w[ CHARSET UTF-8 ],
|
1114
|
+
nil,
|
1115
|
+
nil,
|
1116
|
+
'QUOTED-PRINTABLE',
|
1117
|
+
5921,
|
1118
|
+
119
|
1119
|
+
],
|
1120
|
+
'ALTERNATIVE'
|
1121
|
+
]
|
1122
|
+
],
|
1123
|
+
|
1124
|
+
'message/rfc822:plain/text' =>
|
1125
|
+
[ '("MESSAGE" "RFC822" NIL NIL NIL NIL 16822 ("8 Nov 2013 06:47:50 +0900 (JST)" "test" (NIL NIL "alice" "example.net") NIL NIL (NIL NIL "bob" "example.net") NIL NIL NIL NIL) ("TEXT" "PLAIN" ("CHARSET" "UTF-8") NIL NIL "BASE64" 16722 335) 345)',
|
1126
|
+
[ 'MESSAGE',
|
1127
|
+
'RFC822',
|
1128
|
+
nil, # not allowed empty body field parameters
|
1129
|
+
nil,
|
1130
|
+
nil,
|
1131
|
+
nil,
|
1132
|
+
16822,
|
1133
|
+
[ '8 Nov 2013 06:47:50 +0900 (JST)', # Date
|
1134
|
+
'test', # Subject
|
1135
|
+
[ nil, nil, 'alice', 'example.net' ], # From
|
1136
|
+
nil, # Reply-To
|
1137
|
+
nil, # Sender
|
1138
|
+
[ nil, nil, 'bob', 'example.net'], # To
|
1139
|
+
nil, # Cc
|
1140
|
+
nil, # Bcc
|
1141
|
+
nil, # In-Reply-To
|
1142
|
+
nil # Message-Id
|
1143
|
+
],
|
1144
|
+
[ 'TEXT',
|
1145
|
+
'PLAIN',
|
1146
|
+
%w[ CHARSET UTF-8 ],
|
1147
|
+
nil,
|
1148
|
+
nil,
|
1149
|
+
'BASE64',
|
1150
|
+
16722,
|
1151
|
+
335
|
1152
|
+
],
|
1153
|
+
345
|
1154
|
+
]
|
1155
|
+
],
|
1156
|
+
|
1157
|
+
'message/rfc822:multipart/alternative' =>
|
1158
|
+
[ '("MESSAGE" "RFC822" NIL NIL NIL NIL 16822 ("8 Nov 2013 06:47:50 +0900 (JST)" "test" (NIL NIL "alice" "example.net") NIL NIL (NIL NIL "bob" "example.net") NIL NIL NIL NIL) (("TEXT" "PLAIN" ("CHARSET" "UTF-8" "DELSP" "yes" "FORMAT" "flowed") NIL NIL "BASE64" 1756 36)("TEXT" "HTML" ("CHARSET" "UTF-8") NIL NIL "QUOTED-PRINTABLE" 5921 119) "ALTERNATIVE") 345)',
|
1159
|
+
[ 'MESSAGE',
|
1160
|
+
'RFC822',
|
1161
|
+
nil, # not allowed empty body field parameters
|
1162
|
+
nil,
|
1163
|
+
nil,
|
1164
|
+
nil,
|
1165
|
+
16822,
|
1166
|
+
[ '8 Nov 2013 06:47:50 +0900 (JST)', # Date
|
1167
|
+
'test', # Subject
|
1168
|
+
[ nil, nil, 'alice', 'example.net' ], # From
|
1169
|
+
nil, # Reply-To
|
1170
|
+
nil, # Sender
|
1171
|
+
[ nil, nil, 'bob', 'example.net'], # To
|
1172
|
+
nil, # Cc
|
1173
|
+
nil, # Bcc
|
1174
|
+
nil, # In-Reply-To
|
1175
|
+
nil # Message-Id
|
1176
|
+
],
|
1177
|
+
[ [ 'TEXT',
|
1178
|
+
'PLAIN',
|
1179
|
+
%w[ CHARSET UTF-8 DELSP yes FORMAT flowed ],
|
1180
|
+
nil,
|
1181
|
+
nil,
|
1182
|
+
'BASE64',
|
1183
|
+
1756,
|
1184
|
+
36
|
1185
|
+
],
|
1186
|
+
[ 'TEXT',
|
1187
|
+
'HTML',
|
1188
|
+
%w[ CHARSET UTF-8 ],
|
1189
|
+
nil,
|
1190
|
+
nil,
|
1191
|
+
'QUOTED-PRINTABLE',
|
1192
|
+
5921,
|
1193
|
+
119
|
1194
|
+
],
|
1195
|
+
'ALTERNATIVE'
|
1196
|
+
],
|
1197
|
+
345
|
1198
|
+
]
|
1199
|
+
],
|
1200
|
+
|
1201
|
+
'multipart/alternative:extension' =>
|
1202
|
+
[ '(("TEXT" "PLAIN" ("CHARSET" "UTF-8" "DELSP" "yes" "FORMAT" "flowed") NIL NIL "BASE64" 1756 36 "Q2hlY2sgSW50ZWdyaXR5IQ==" ("INLINE" NIL) NIL NIL)("TEXT" "HTML" ("CHARSET" "UTF-8") NIL NIL "QUOTED-PRINTABLE" 5921 119 NIL ("ATTACHMENT" ("filename" "halo.html")) ("EN-US" "EN") NIL) "ALTERNATIVE" ("boundary" "1383.905529.351297") NIL "EN" "test")',
|
1203
|
+
[ [ 'TEXT',
|
1204
|
+
'PLAIN',
|
1205
|
+
%w[ CHARSET UTF-8 DELSP yes FORMAT flowed ],
|
1206
|
+
nil,
|
1207
|
+
nil,
|
1208
|
+
'BASE64',
|
1209
|
+
1756,
|
1210
|
+
36,
|
1211
|
+
'Q2hlY2sgSW50ZWdyaXR5IQ==',
|
1212
|
+
[ 'INLINE', nil ],
|
1213
|
+
nil,
|
1214
|
+
nil
|
1215
|
+
],
|
1216
|
+
[ 'TEXT',
|
1217
|
+
'HTML',
|
1218
|
+
%w[ CHARSET UTF-8 ],
|
1219
|
+
nil,
|
1220
|
+
nil,
|
1221
|
+
'QUOTED-PRINTABLE',
|
1222
|
+
5921,
|
1223
|
+
119,
|
1224
|
+
nil,
|
1225
|
+
[ 'ATTACHMENT', %w[ filename halo.html ] ],
|
1226
|
+
%w[ EN-US EN ],
|
1227
|
+
nil
|
1228
|
+
],
|
1229
|
+
'ALTERNATIVE',
|
1230
|
+
%w[ boundary 1383.905529.351297 ],
|
1231
|
+
nil,
|
1232
|
+
"EN",
|
1233
|
+
"test"
|
1234
|
+
]
|
1235
|
+
])
|
1041
1236
|
def test_encode_bodystructure(data)
|
1042
1237
|
expected_value, array = data
|
1043
1238
|
assert_equal(expected_value, RIMS::Protocol::FetchParser::Utils.encode_bodystructure(array))
|