2008-03-11 04:35:43 -04:00
|
|
|
USING: smtp tools.test io.streams.string io.sockets threads
|
2008-03-07 02:55:38 -05:00
|
|
|
smtp.server kernel sequences namespaces logging accessors
|
2008-08-29 17:48:29 -04:00
|
|
|
assocs sorting smtp.private ;
|
2008-03-01 17:00:45 -05:00
|
|
|
IN: smtp.tests
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
{ 0 0 } [ [ ] with-smtp-connection ] must-infer-as
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ "hello\nworld" validate-address ] must-fail
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ "slava@factorcode.org" ]
|
|
|
|
[ "slava@factorcode.org" validate-address ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ { "hello" "." "world" } validate-message ] must-fail
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ "hello\r\nworld\r\n.\r\n" ] [
|
2008-03-07 02:55:38 -05:00
|
|
|
"hello\nworld" [ send-body ] with-string-writer
|
2008-02-07 02:03:27 -05:00
|
|
|
] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-10 04:12:44 -05:00
|
|
|
[ "500 syntax error" check-response ] must-fail
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-10 04:12:44 -05:00
|
|
|
[ ] [ "220 success" check-response ] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ "220 success" ] [
|
2008-02-15 23:20:31 -05:00
|
|
|
"220 success" [ receive-response ] with-string-reader
|
2008-02-07 02:03:27 -05:00
|
|
|
] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ "220 the end" ] [
|
2008-02-10 04:12:44 -05:00
|
|
|
"220-a multiline response\r\n250-another line\r\n220 the end"
|
2008-02-15 23:20:31 -05:00
|
|
|
[ receive-response ] with-string-reader
|
2008-02-07 02:03:27 -05:00
|
|
|
] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[ ] [
|
2008-02-10 04:12:44 -05:00
|
|
|
"220-a multiline response\r\n250-another line\r\n220 the end"
|
2008-02-15 23:20:31 -05:00
|
|
|
[ get-ok ] with-string-reader
|
2008-02-07 02:03:27 -05:00
|
|
|
] unit-test
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2008-02-07 02:03:27 -05:00
|
|
|
[
|
|
|
|
"Subject:\r\nsecurity hole" validate-header
|
|
|
|
] must-fail
|
|
|
|
|
|
|
|
[
|
2008-03-07 02:55:38 -05:00
|
|
|
{
|
2008-02-07 02:03:27 -05:00
|
|
|
{ "From" "Doug <erg@factorcode.org>" }
|
|
|
|
{ "Subject" "Factor rules" }
|
2008-03-07 02:55:38 -05:00
|
|
|
{ "To" "Slava <slava@factorcode.org>, Ed <dharmatech@factorcode.org>" }
|
2008-02-07 02:03:27 -05:00
|
|
|
}
|
|
|
|
{ "slava@factorcode.org" "dharmatech@factorcode.org" }
|
|
|
|
"erg@factorcode.org"
|
|
|
|
] [
|
2008-03-07 02:55:38 -05:00
|
|
|
<email>
|
|
|
|
"Factor rules" >>subject
|
|
|
|
{
|
|
|
|
"Slava <slava@factorcode.org>"
|
|
|
|
"Ed <dharmatech@factorcode.org>"
|
|
|
|
} >>to
|
|
|
|
"Doug <erg@factorcode.org>" >>from
|
2008-08-16 18:20:18 -04:00
|
|
|
[
|
|
|
|
email>headers sort-keys [
|
|
|
|
drop { "Date" "Message-Id" } member? not
|
|
|
|
] assoc-filter
|
|
|
|
]
|
|
|
|
[ to>> [ extract-email ] map ]
|
|
|
|
[ from>> extract-email ] tri
|
2008-02-07 02:03:27 -05:00
|
|
|
] unit-test
|
|
|
|
|
2008-05-09 18:11:20 -04:00
|
|
|
[ ] [ [ 4321 mock-smtp-server ] "SMTP server" spawn drop ] unit-test
|
|
|
|
|
|
|
|
[ ] [ yield ] unit-test
|
2008-02-07 02:03:27 -05:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
[
|
2008-03-11 04:35:43 -04:00
|
|
|
"localhost" 4321 <inet> smtp-server set
|
2008-02-07 02:03:27 -05:00
|
|
|
|
2008-03-07 02:55:38 -05:00
|
|
|
<email>
|
|
|
|
"Hi guys\nBye guys" >>body
|
|
|
|
"Factor rules" >>subject
|
|
|
|
{
|
|
|
|
"Slava <slava@factorcode.org>"
|
|
|
|
"Ed <dharmatech@factorcode.org>"
|
|
|
|
} >>to
|
|
|
|
"Doug <erg@factorcode.org>" >>from
|
2008-03-11 04:35:43 -04:00
|
|
|
send-email
|
2008-02-07 02:03:27 -05:00
|
|
|
] with-scope
|
2008-03-06 14:46:15 -05:00
|
|
|
] unit-test
|
2008-05-09 18:11:20 -04:00
|
|
|
|
|
|
|
[ ] [ yield ] unit-test
|