rims 0.2.5 → 0.2.6

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