1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 15:48:49 -05:00

ftpserver.pl: Moved specifying the test number from the RCPT address

...to the client address as this frees the RCPT strings to contain
just an email address and by passing the test number into curl as the
client address remains consistent with POP3 and IMAP tests as they are
specified in the URL.
This commit is contained in:
Steve Holme 2013-09-29 09:53:49 +01:00
parent ab7e6afd44
commit 49341628b5
23 changed files with 61 additions and 55 deletions

View File

@ -35,7 +35,7 @@ To: another
body
</stdin>
<command>
smtp://smtp.1320:%SMTPPORT/user --mail-rcpt 1320@example.com --mail-from 1320@example.com -T - -p -x %HOSTIP:%PROXYPORT
smtp://smtp.1320:%SMTPPORT/1320 --mail-rcpt 1320@example.com --mail-from 1320@example.com -T - -p -x %HOSTIP:%PROXYPORT
</command>
</client>
@ -46,7 +46,7 @@ smtp://smtp.1320:%SMTPPORT/user --mail-rcpt 1320@example.com --mail-from 1320@ex
^User-Agent: curl/.*
</strip>
<protocol>
EHLO user
EHLO 1320
MAIL FROM:<1320@example.com>
RCPT TO:<1320@example.com>
DATA

View File

@ -32,7 +32,7 @@ To: another
body
</file>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 1406@example.com --mail-rcpt 1406@foobar.example.com --mail-from 1406@example.com -T log/test1406.eml --libcurl log/test1406.c
smtp://%HOSTIP:%SMTPPORT/1406 --mail-rcpt 1406@example.com --mail-rcpt 1406@foobar.example.com --mail-from 1406@example.com -T log/test1406.eml --libcurl log/test1406.c
</command>
</client>
@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 1406@example.com --mail-rcpt 1406@foob
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 1406
MAIL FROM:<1406@example.com> SIZE=38
RCPT TO:<1406@example.com>
RCPT TO:<1406@foobar.example.com>
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38);
curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/user");
curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/1406");
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");

View File

@ -32,7 +32,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user
smtp://%HOSTIP:%SMTPPORT/1507
</command>
</client>
@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 1507
MAIL FROM:<1507-realuser@example.com>
RCPT TO:<1507-recipient@example.com>
DATA

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 900@example.com --mail-from 900@example.com -T -
smtp://%HOSTIP:%SMTPPORT/900 --mail-rcpt 900@example.com --mail-from 900@example.com -T -
</command>
</client>
@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 900@example.com --mail-from 900@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 900
MAIL FROM:<900@example.com>
RCPT TO:<900@example.com>
DATA

View File

@ -32,7 +32,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 901@example.com --mail-from 901@example.com -T -
smtp://%HOSTIP:%SMTPPORT/901 --mail-rcpt 901@example.com --mail-from 901@example.com -T -
</command>
</client>
@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 901@example.com --mail-from 901@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 901
MAIL FROM:<901@example.com>
RCPT TO:<901@example.com>
DATA

View File

@ -31,7 +31,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 902@example.com --mail-from 902@example.com -T -
smtp://%HOSTIP:%SMTPPORT/902 --mail-rcpt 902@example.com --mail-from 902@example.com -T -
</command>
</client>
@ -39,8 +39,8 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 902@example.com --mail-from 902@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
HELO user
EHLO 902
HELO 902
MAIL FROM:<902@example.com>
RCPT TO:<902@example.com>
DATA

View File

@ -31,7 +31,7 @@ SMTP plain authentication
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 903@example.com --mail-from 903@example.com -u test:1234 -T -
smtp://%HOSTIP:%SMTPPORT/903 --mail-rcpt 903@example.com --mail-from 903@example.com -u test:1234 -T -
</command>
</client>
@ -39,7 +39,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 903@example.com --mail-from 903@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 903
AUTH PLAIN
dGVzdAB0ZXN0ADEyMzQ=
MAIL FROM:<903@example.com>

View File

@ -31,7 +31,7 @@ SMTP login authentication
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 904@example.com --mail-from 904@example.com -u test:1234 -T -
smtp://%HOSTIP:%SMTPPORT/904 --mail-rcpt 904@example.com --mail-from 904@example.com -u test:1234 -T -
</command>
</client>
@ -39,7 +39,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 904@example.com --mail-from 904@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 904
AUTH LOGIN
dGVzdA==
MTIzNA==

View File

@ -34,7 +34,7 @@ SMTP CRAM-MD5 authentication
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 905@example.com --mail-from 905@example.com -u tim:tanstaaftanstaaf -T -
smtp://%HOSTIP:%SMTPPORT/905 --mail-rcpt 905@example.com --mail-from 905@example.com -u tim:tanstaaftanstaaf -T -
</command>
</client>
@ -42,7 +42,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 905@example.com --mail-from 905@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 905
AUTH CRAM-MD5
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw
MAIL FROM:<905@example.com>

View File

@ -39,7 +39,7 @@ LD_PRELOAD=%PWD/libtest/.libs/libhostname.so
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 906@example.com --mail-from 906@example.com -u testuser:testpass -T -
smtp://%HOSTIP:%SMTPPORT/906 --mail-rcpt 906@example.com --mail-from 906@example.com -u testuser:testpass -T -
</command>
</client>
@ -47,7 +47,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 906@example.com --mail-from 906@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 906
AUTH NTLM
TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q=

View File

@ -30,7 +30,7 @@ SMTP plain authentication with initial response
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 907@example.com --mail-from 907@example.com -u test:1234 --sasl-ir -T -
smtp://%HOSTIP:%SMTPPORT/907 --mail-rcpt 907@example.com --mail-from 907@example.com -u test:1234 --sasl-ir -T -
</command>
</client>
@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 907@example.com --mail-from 907@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 907
AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ=
MAIL FROM:<907@example.com>
RCPT TO:<907@example.com>

View File

@ -30,7 +30,7 @@ SMTP login authentication with initial response
mail body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 908@example.com --mail-from 908@example.com -u test:1234 --sasl-ir -T -
smtp://%HOSTIP:%SMTPPORT/908 --mail-rcpt 908@example.com --mail-from 908@example.com -u test:1234 --sasl-ir -T -
</command>
</client>
@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 908@example.com --mail-from 908@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 908
AUTH LOGIN dGVzdA==
MTIzNA==
MAIL FROM:<908@example.com>

View File

@ -30,7 +30,7 @@ To: another
body
</file>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 909@example.com --mail-from 909@example.com -T log/test909.eml
smtp://%HOSTIP:%SMTPPORT/909 --mail-rcpt 909@example.com --mail-from 909@example.com -T log/test909.eml
</command>
</client>
@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 909@example.com --mail-from 909@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 909
MAIL FROM:<909@example.com>
RCPT TO:<909@example.com>
DATA

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 910@example.com --mail-from 910@example.com -T -
smtp://%HOSTIP:%SMTPPORT/910 --mail-rcpt 910@example.com --mail-from 910@example.com -T -
</command>
</client>
@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 910@example.com --mail-from 910@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 910
MAIL FROM:<910@example.com>
RCPT TO:<910@example.com>
DATA

View File

@ -25,7 +25,7 @@ SMTP with no mail data
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 911@example.com --mail-from 911@example.com -T -
smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt 911@example.com --mail-from 911@example.com -T -
</command>
</client>
@ -33,7 +33,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 911@example.com --mail-from 911@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 911
MAIL FROM:<911@example.com>
RCPT TO:<911@example.com>
DATA

View File

@ -30,7 +30,7 @@ To: another
body
</file>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 912@example.com --mail-from 912@example.com -T log/test912.eml
smtp://%HOSTIP:%SMTPPORT/912 --mail-rcpt 912@example.com --mail-from 912@example.com -T log/test912.eml
</command>
</client>
@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 912@example.com --mail-from 912@exampl
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 912
MAIL FROM:<912@example.com> SIZE=38
RCPT TO:<912@example.com>
DATA

View File

@ -30,7 +30,7 @@ To: another
body
</file>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 913@example.com --mail-from 913@example.com -T log/test913.eml
smtp://%HOSTIP:%SMTPPORT/913 --mail-rcpt 913@example.com --mail-from 913@example.com -T log/test913.eml
</command>
</client>
@ -41,7 +41,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 913@example.com --mail-from 913@exampl
55
</errorcode>
<protocol>
EHLO user
EHLO 913
MAIL FROM:<913@example.com> SIZE=38
QUIT
</protocol>

View File

@ -26,7 +26,7 @@ To: another
body
</file>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 914@example.com --mail-from invalid -T log/test914.eml
smtp://%HOSTIP:%SMTPPORT/914 --mail-rcpt 914@example.com --mail-from invalid -T log/test914.eml
</command>
</client>
@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 914@example.com --mail-from invalid -T
55
</errorcode>
<protocol>
EHLO user
EHLO 914
MAIL FROM:<invalid>
QUIT
</protocol>

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 915@example.com -T -
smtp://%HOSTIP:%SMTPPORT/915 --mail-rcpt 915@example.com -T -
</command>
</client>
@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 915@example.com -T -
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 915
MAIL FROM:<>
RCPT TO:<915@example.com>
DATA

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt invalid --mail-from 916@example.com -T -
smtp://%HOSTIP:%SMTPPORT/916 --mail-rcpt invalid --mail-from 916@example.com -T -
</command>
</client>
@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt invalid --mail-from 916@example.com -T
55
</errorcode>
<protocol>
EHLO user
EHLO 916
MAIL FROM:<916@example.com>
RCPT TO:<invalid>
QUIT

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 917@example.com --mail-rcpt 917@foo.example.com --mail-rcpt 917@bar.example.com --mail-rcpt 917@foobar.example.com --mail-rcpt 917@another.example.com --mail-from 917@example.com -T -
smtp://%HOSTIP:%SMTPPORT/917 --mail-rcpt 917@example.com --mail-rcpt 917@foo.example.com --mail-rcpt 917@bar.example.com --mail-rcpt 917@foobar.example.com --mail-rcpt 917@another.example.com --mail-from 917@example.com -T -
</command>
</client>
@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 917@example.com --mail-rcpt 917@foo.ex
# Verify data after the test has been "shot"
<verify>
<protocol>
EHLO user
EHLO 917
MAIL FROM:<917@example.com>
RCPT TO:<917@example.com>
RCPT TO:<917@foo.example.com>

View File

@ -26,7 +26,7 @@ To: another
body
</stdin>
<command>
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 918@example.com --mail-rcpt invalid --mail-rcpt 918@bar.example.com --mail-rcpt sTrAnGe --mail-rcpt 918@another.example.com --mail-from 918@example.com -T -
smtp://%HOSTIP:%SMTPPORT/918 --mail-rcpt 918@example.com --mail-rcpt invalid --mail-rcpt 918@bar.example.com --mail-rcpt sTrAnGe --mail-rcpt 918@another.example.com --mail-from 918@example.com -T -
</command>
</client>
@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 918@example.com --mail-rcpt invalid --
55
</errorcode>
<protocol>
EHLO user
EHLO 918
MAIL FROM:<918@example.com>
RCPT TO:<918@example.com>
RCPT TO:<invalid>

View File

@ -685,12 +685,12 @@ sub close_dataconn {
################ SMTP commands
################
# what set by "RCPT"
my $smtp_rcpt;
# The type of server (SMTP or ESMTP)
my $smtp_type;
# The client (which normally contains the test number)
my $smtp_client;
sub EHLO_smtp {
my ($client) = @_;
@ -753,6 +753,9 @@ sub EHLO_smtp {
sendcontrol "250 $d\r\n";
}
}
# Store the client (as it may contain the test number)
$smtp_client = $client;
}
return 0;
@ -784,6 +787,9 @@ sub HELO_smtp {
# Send the HELO response
sendcontrol "250 $smtp_type pingpong test server Hello $client\r\n";
# Store the client (as it may contain the test number)
$smtp_client = $client;
}
return 0;
@ -854,11 +860,11 @@ sub RCPT_smtp {
sendcontrol "501 Unrecognized parameter\r\n";
}
else {
$smtp_rcpt = $1;
my $to = $1;
# Validate the to address (only a valid email address inside <> is
# allowed, such as <user@example.com>)
if ($smtp_rcpt !~
if ($to !~
/^<([a-zA-Z0-9._%+-]+)\@([a-zA-Z0-9.-]+).([a-zA-Z]{2,4})>$/) {
sendcontrol "501 Invalid address\r\n";
}
@ -872,17 +878,17 @@ sub RCPT_smtp {
sub DATA_smtp {
my ($args) = @_;
my $testno = $smtp_rcpt;
if ($args) {
sendcontrol "501 Unrecognized parameter\r\n";
}
elsif ($smtp_client !~ /^(\d*)$/)
sendcontrol "501 Invalid arguments\r\n";
}
else {
$testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
sendcontrol "354 Show me the mail\r\n";
logmsg "===> rcpt $testno was $smtp_rcpt\n";
my $testno = $smtp_client;
my $filename = "log/upload.$testno";
logmsg "Store test number $testno in $filename\n";