rims 0.2.4 → 0.2.5
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/ChangeLog +65 -0
- data/lib/rims.rb +0 -2
- data/lib/rims/cksum_kvs.rb +1 -1
- data/lib/rims/cmd.rb +67 -8
- data/lib/rims/lock.rb +2 -2
- data/lib/rims/mail_store.rb +38 -52
- data/lib/rims/protocol/decoder.rb +1274 -789
- data/lib/rims/protocol/parser.rb +79 -39
- data/lib/rims/rfc822.rb +31 -24
- data/lib/rims/service.rb +67 -20
- data/lib/rims/test.rb +4 -1
- data/lib/rims/version.rb +1 -1
- data/test/cmd/test_command.rb +1103 -108
- data/test/test_mail_store.rb +23 -137
- data/test/test_protocol_auth.rb +8 -1
- data/test/test_protocol_decoder.rb +615 -175
- data/test/test_protocol_fetch.rb +276 -147
- data/test/test_protocol_request.rb +6 -0
- data/test/test_protocol_search.rb +27 -1
- data/test/test_service.rb +99 -6
- metadata +2 -3
- data/lib/rims/pool.rb +0 -85
data/test/test_protocol_fetch.rb
CHANGED
@@ -34,11 +34,7 @@ module RIMS::Test
|
|
34
34
|
|
35
35
|
def make_fetch_parser(read_only: false)
|
36
36
|
yield if block_given?
|
37
|
-
|
38
|
-
@folder = @mail_store.examine_mbox(@inbox_id).reload
|
39
|
-
else
|
40
|
-
@folder = @mail_store.select_mbox(@inbox_id).reload
|
41
|
-
end
|
37
|
+
@folder = @mail_store.open_folder(@inbox_id, read_only: read_only).reload
|
42
38
|
@parser = RIMS::Protocol::FetchParser.new(@mail_store, @folder)
|
43
39
|
end
|
44
40
|
private :make_fetch_parser
|
@@ -449,93 +445,93 @@ module RIMS::Test
|
|
449
445
|
parse_fetch_attribute(fetch_att_bodystruct) {
|
450
446
|
assert_fetch(0, [
|
451
447
|
"#{fetch_att_bodystruct} " +
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
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
|
+
])
|
461
457
|
])
|
462
458
|
assert_fetch(1, [
|
463
459
|
"#{fetch_att_bodystruct} " +
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
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
|
463
|
+
],
|
464
|
+
[ 'APPLICATION', 'OCTET-STREAM', [], nil, nil, nil,
|
465
|
+
@mpart_mail.parts[1].raw_source.bytesize
|
466
|
+
],
|
467
|
+
[ 'MESSAGE', 'RFC822', [], nil, nil, nil,
|
468
|
+
@mpart_mail.parts[2].raw_source.bytesize,
|
469
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
470
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
471
|
+
],
|
472
|
+
[ [ '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
|
475
|
+
],
|
476
|
+
[ 'APPLICATION', 'OCTET-STREAM', [], nil, nil, nil,
|
477
|
+
@mpart_mail.parts[2].message.parts[1].raw_source.bytesize
|
478
|
+
],
|
479
|
+
'MIXED'
|
480
|
+
],
|
481
|
+
@mpart_mail.parts[2].raw_source.each_line.count
|
482
|
+
],
|
483
|
+
[ [ 'IMAGE', 'GIF', [], nil, nil, nil,
|
484
|
+
@mpart_mail.parts[3].parts[0].raw_source.bytesize
|
485
|
+
],
|
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
|
490
|
+
],
|
491
|
+
[ [ '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
|
494
|
+
],
|
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'
|
504
|
+
],
|
505
|
+
'MIXED'
|
506
|
+
],
|
507
|
+
@mpart_mail.parts[3].parts[1].raw_source.each_line.count
|
508
|
+
],
|
509
|
+
'MIXED',
|
510
|
+
],
|
511
|
+
'MIXED'
|
512
|
+
])
|
517
513
|
])
|
518
514
|
assert_fetch(2, [
|
519
515
|
"#{fetch_att_bodystruct} " +
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
516
|
+
encode_bodystructure([ 'APPLICATION',
|
517
|
+
'OCTET-STREAM',
|
518
|
+
[],
|
519
|
+
nil,
|
520
|
+
nil,
|
521
|
+
nil,
|
522
|
+
@empty_mail.raw_source.bytesize
|
523
|
+
])
|
528
524
|
])
|
529
525
|
assert_fetch(3, [
|
530
526
|
"#{fetch_att_bodystruct} " +
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
527
|
+
encode_bodystructure([ 'APPLICATION',
|
528
|
+
'OCTET-STREAM',
|
529
|
+
[],
|
530
|
+
nil,
|
531
|
+
nil,
|
532
|
+
nil,
|
533
|
+
@no_body_mail.raw_source.bytesize
|
534
|
+
])
|
539
535
|
])
|
540
536
|
}
|
541
537
|
end
|
@@ -589,7 +585,7 @@ module RIMS::Test
|
|
589
585
|
'((NIL NIL "alice" "test.com") ("bob" NIL "bob" "test.com"))', # To
|
590
586
|
'(("Kate" NIL "kate" "test.com"))', # Cc
|
591
587
|
'((NIL NIL "foo" "nonet.com"))', # Bcc
|
592
|
-
'"<20131106081723.5KJU1774292@smtp.
|
588
|
+
'"<20131106081723.5KJU1774292@smtp.test.com>"', # In-Reply-To
|
593
589
|
'"<20131107214750.445A1255B9F@smtp.nonet.com>"' # Message-Id
|
594
590
|
]
|
595
591
|
])
|
@@ -707,15 +703,15 @@ module RIMS::Test
|
|
707
703
|
'NIL' # Message-Id
|
708
704
|
],
|
709
705
|
'BODY',
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
706
|
+
encode_bodystructure([ 'TEXT',
|
707
|
+
'PLAIN',
|
708
|
+
%w[ charset us-ascii ],
|
709
|
+
nil,
|
710
|
+
nil,
|
711
|
+
'7BIT',
|
712
|
+
@simple_mail.raw_source.bytesize,
|
713
|
+
@simple_mail.raw_source.each_line.count
|
714
|
+
])
|
719
715
|
])
|
720
716
|
assert_fetch(1, [
|
721
717
|
'FLAGS (\Recent)',
|
@@ -734,60 +730,60 @@ module RIMS::Test
|
|
734
730
|
'NIL' # Message-Id
|
735
731
|
],
|
736
732
|
'BODY',
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
733
|
+
encode_bodystructure([ [ 'TEXT', 'PLAIN', %w[ charset us-ascii], nil, nil, nil,
|
734
|
+
@mpart_mail.parts[0].raw_source.bytesize,
|
735
|
+
@mpart_mail.parts[0].raw_source.each_line.count
|
736
|
+
],
|
737
|
+
[ 'APPLICATION', 'OCTET-STREAM', [], nil, nil, nil,
|
738
|
+
@mpart_mail.parts[1].raw_source.bytesize
|
739
|
+
],
|
740
|
+
[ 'MESSAGE', 'RFC822', [], nil, nil, nil,
|
741
|
+
@mpart_mail.parts[2].raw_source.bytesize,
|
742
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
743
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
744
|
+
],
|
745
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
746
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.bytesize,
|
747
|
+
@mpart_mail.parts[2].message.parts[0].raw_source.each_line.count
|
748
|
+
],
|
749
|
+
[ 'APPLICATION', 'OCTET-STREAM', [], nil, nil, nil,
|
750
|
+
@mpart_mail.parts[2].message.parts[1].raw_source.bytesize
|
751
|
+
],
|
752
|
+
'MIXED'
|
753
|
+
],
|
754
|
+
@mpart_mail.parts[2].raw_source.each_line.count
|
755
|
+
],
|
756
|
+
[
|
757
|
+
[ 'IMAGE', 'GIF', [], nil, nil, nil,
|
758
|
+
@mpart_mail.parts[3].parts[0].raw_source.bytesize
|
759
|
+
],
|
760
|
+
[ 'MESSAGE', 'RFC822', [], nil, nil, nil,
|
761
|
+
@mpart_mail.parts[3].parts[1].raw_source.bytesize,
|
762
|
+
[ 'Fri, 8 Nov 2013 19:31:03 +0900', 'inner multipart',
|
763
|
+
[ [ nil, nil, 'foo', 'nonet.com' ] ], nil, nil, [ [ nil, nil, 'bar', 'nonet.com' ] ], nil, nil, nil, nil
|
764
|
+
],
|
765
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
766
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.bytesize,
|
767
|
+
@mpart_mail.parts[3].parts[1].message.parts[0].raw_source.each_line.count
|
768
|
+
],
|
769
|
+
[ [ 'TEXT', 'PLAIN', %w[ charset us-ascii ], nil, nil, nil,
|
770
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.bytesize,
|
771
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[0].raw_source.each_line.count
|
772
|
+
],
|
773
|
+
[ 'TEXT', 'HTML', %w[ charset us-ascii ], nil, nil, nil,
|
774
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.bytesize,
|
775
|
+
@mpart_mail.parts[3].parts[1].message.parts[1].parts[1].raw_source.each_line.count
|
776
|
+
],
|
777
|
+
'ALTERNATIVE'
|
778
|
+
],
|
779
|
+
'MIXED'
|
780
|
+
],
|
781
|
+
@mpart_mail.parts[3].parts[1].raw_source.each_line.count
|
782
|
+
],
|
783
|
+
'MIXED',
|
784
|
+
],
|
785
|
+
'MIXED'
|
786
|
+
])
|
791
787
|
])
|
792
788
|
}
|
793
789
|
end
|
@@ -914,6 +910,139 @@ module RIMS::Test
|
|
914
910
|
class ProtocolFetchParserUtilsTest < Test::Unit::TestCase
|
915
911
|
include ProtocolFetchMailSample
|
916
912
|
|
913
|
+
data('symbol' => [ '(foo)', [ :foo ] ],
|
914
|
+
'string' => [ '("Hello world.")', [ 'Hello world.' ] ],
|
915
|
+
'integer' => [ '(128)', [ 128 ] ],
|
916
|
+
'nil' => [ '(NIL)', [ nil ] ],
|
917
|
+
'array' => [ '(())', [ [] ] ],
|
918
|
+
'all' => [ '(foo "Hello world." 128 NIL (bar "Good bye." 256 NIL))',
|
919
|
+
[ :foo,
|
920
|
+
'Hello world.',
|
921
|
+
128,
|
922
|
+
nil,
|
923
|
+
[ :bar,
|
924
|
+
'Good bye.',
|
925
|
+
256,
|
926
|
+
nil
|
927
|
+
]
|
928
|
+
]
|
929
|
+
])
|
930
|
+
def test_encode_list(data)
|
931
|
+
expected_value, array = data
|
932
|
+
assert_equal(expected_value, RIMS::Protocol::FetchParser::Utils.encode_list(array))
|
933
|
+
end
|
934
|
+
|
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
|
+
])
|
1041
|
+
def test_encode_bodystructure(data)
|
1042
|
+
expected_value, array = data
|
1043
|
+
assert_equal(expected_value, RIMS::Protocol::FetchParser::Utils.encode_bodystructure(array))
|
1044
|
+
end
|
1045
|
+
|
917
1046
|
def test_encode_header
|
918
1047
|
assert_equal("To: foo@nonet.org\r\n" +
|
919
1048
|
"From: bar@nonet.org\r\n" +
|