@@ -636,6 +636,45 @@ func TestServer_LFDotLF(t *testing.T) {
636
636
}
637
637
}
638
638
639
+ func TestServer_EmptyMessage (t * testing.T ) {
640
+ be , s , c , scanner := testServerAuthenticated (t )
641
+ defer s .Close ()
642
+ defer c .Close ()
643
+
644
+ io .WriteString (c , "MAIL FROM:<root@nsa.gov>\r \n " )
645
+ scanner .Scan ()
646
+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
647
+ t .Fatal ("Invalid MAIL response:" , scanner .Text ())
648
+ }
649
+
650
+ io .WriteString (c , "RCPT TO:<root@gchq.gov.uk>\r \n " )
651
+ scanner .Scan ()
652
+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
653
+ t .Fatal ("Invalid RCPT response:" , scanner .Text ())
654
+ }
655
+
656
+ io .WriteString (c , "DATA\r \n " )
657
+ scanner .Scan ()
658
+ if ! strings .HasPrefix (scanner .Text (), "354 " ) {
659
+ t .Fatal ("Invalid DATA response:" , scanner .Text ())
660
+ }
661
+
662
+ io .WriteString (c , "\r \n \r \n .\r \n " )
663
+ scanner .Scan ()
664
+ if ! strings .HasPrefix (scanner .Text (), "250 " ) {
665
+ t .Fatal ("Invalid DATA response:" , scanner .Text ())
666
+ }
667
+
668
+ if len (be .messages ) != 1 || len (be .anonmsgs ) != 0 {
669
+ t .Fatal ("Invalid number of sent messages:" , be .messages , be .anonmsgs )
670
+ }
671
+
672
+ msg := be .messages [0 ]
673
+ if string (msg .Data ) != "\r \n \r \n " {
674
+ t .Fatal ("Invalid mail data:" , string (msg .Data ), msg .Data )
675
+ }
676
+ }
677
+
639
678
func TestServer_authDisabled (t * testing.T ) {
640
679
_ , s , c , scanner , caps := testServerEhlo (t , authDisabled )
641
680
defer s .Close ()
0 commit comments