factor/extra/smtp/smtp-tests.factor

111 lines
2.4 KiB
Factor
Raw Normal View History

USING: smtp tools.test io.streams.string io.logging threads
smtp.server kernel sequences namespaces ;
IN: temporary
2007-09-20 18:09:08 -04:00
{ 0 0 } [ [ ] with-smtp-connection ] must-infer-as
2007-09-20 18:09:08 -04:00
[ "hello\nworld" validate-address ] must-fail
2007-09-20 18:09:08 -04:00
[ "slava@factorcode.org" ]
[ "slava@factorcode.org" validate-address ] unit-test
2007-09-20 18:09:08 -04:00
[ { "hello" "." "world" } validate-message ] must-fail
2007-09-20 18:09:08 -04:00
[ "hello\r\nworld\r\n.\r\n" ] [
{ "hello" "world" } [ send-body ] string-out
] unit-test
2007-09-20 18:09:08 -04:00
[
[
"500 syntax error" check-response
] with-log-stdio
] must-fail
2007-09-20 18:09:08 -04:00
[ ] [
[
"220 success" check-response
] with-log-stdio
] unit-test
2007-09-20 18:09:08 -04:00
[ "220 success" ] [
"220 success" [ receive-response ] string-in
] unit-test
2007-09-20 18:09:08 -04:00
[ "220 the end" ] [
[
"220-a multiline response\r\n250-another line\r\n220 the end"
[ receive-response ] string-in
] with-log-stdio
] unit-test
2007-09-20 18:09:08 -04:00
[ ] [
[
"220-a multiline response\r\n250-another line\r\n220 the end"
[ get-ok ] string-in
] with-log-stdio
] unit-test
2007-09-20 18:09:08 -04:00
[
"Subject:\r\nsecurity hole" validate-header
] must-fail
[
V{
{ "To" "Slava <slava@factorcode.org>, Ed <dharmatech@factorcode.org>" }
{ "From" "Doug <erg@factorcode.org>" }
{ "Subject" "Factor rules" }
}
{ "slava@factorcode.org" "dharmatech@factorcode.org" }
"erg@factorcode.org"
] [
"Factor rules"
{
"Slava <slava@factorcode.org>"
"Ed <dharmatech@factorcode.org>"
}
"Doug <erg@factorcode.org>"
simple-headers >r >r 2 head* r> r>
] unit-test
[
{
"To: Slava <slava@factorcode.org>, Ed <dharmatech@factorcode.org>"
"From: Doug <erg@factorcode.org>"
"Subject: Factor rules"
f
f
" "
"Hi guys"
"Bye guys"
}
{ "slava@factorcode.org" "dharmatech@factorcode.org" }
"erg@factorcode.org"
] [
"Hi guys\nBye guys"
"Factor rules"
{
"Slava <slava@factorcode.org>"
"Ed <dharmatech@factorcode.org>"
}
"Doug <erg@factorcode.org>"
prepare-simple-message
>r >r f 3 pick set-nth f 4 pick set-nth r> r>
] unit-test
[ ] [ [ 4321 smtp-server ] in-thread ] unit-test
[ ] [
[
4321 smtp-port set
"Hi guys\nBye guys"
"Factor rules"
{
"Slava <slava@factorcode.org>"
"Ed <dharmatech@factorcode.org>"
}
"Doug <erg@factorcode.org>"
send-simple-message
] with-scope
] unit-test