diff options
| author | Steve Holme <steve_holme@hotmail.com> | 2013-09-14 20:45:58 +0100 | 
|---|---|---|
| committer | Steve Holme <steve_holme@hotmail.com> | 2013-09-14 20:46:45 +0100 | 
| commit | 84ad1569e5fc939eb8bdac2baf4836806c519579 (patch) | |
| tree | 872fcf917725ffe750b50910c945aa501304986f /tests | |
| parent | 45e0a661cece6a2c2af2e946b5ef67b5aac01c68 (diff) | |
ftpserver.pl: Moved POP3 USER and PASS handlers into own functions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/test856 | 4 | ||||
| -rwxr-xr-x | tests/ftpserver.pl | 39 | 
2 files changed, 38 insertions, 5 deletions
| diff --git a/tests/data/test856 b/tests/data/test856 index 7076cf6a9..55991c7b6 100644 --- a/tests/data/test856 +++ b/tests/data/test856 @@ -2,6 +2,7 @@  <info>  <keywords>  POP3 +LOGIN
  FAILURE  </keywords>  </info> @@ -9,9 +10,6 @@ FAILURE  #  # Server-side  <reply> -<servercmd> -REPLY PASS -ERR invalid login -</servercmd>  </reply>  # diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 78e50c6a5..4f67207cd 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -561,16 +561,16 @@ sub protocolsetup {              'DELE' => \&DELE_pop3,              'LIST' => \&LIST_pop3,              'NOOP' => \&NOOP_pop3, +            'PASS' => \&PASS_pop3,              'QUIT' => \&QUIT_pop3,              'RETR' => \&RETR_pop3,              'RSET' => \&RSET_pop3,              'STAT' => \&STAT_pop3,              'TOP'  => \&TOP_pop3,              'UIDL' => \&UIDL_pop3, +            'USER' => \&USER_pop3,          );          %displaytext = ( -            'USER' => '+OK We are happy you popped in!', -            'PASS' => '+OK Access granted',              'welcome' => join("",              '        _   _ ____  _     '."\r\n",              '    ___| | | |  _ \| |    '."\r\n", @@ -1366,6 +1366,9 @@ sub LOGOUT_imap {  ################ POP3 commands  ################ +# Who is attempting to log in +my $username; +  sub CAPA_pop3 {      my ($testno) = @_; @@ -1438,6 +1441,38 @@ sub AUTH_pop3 {      return 0;  } +sub USER_pop3 { +    my ($user) = @_; + +    logmsg "USER_pop3 got $user\n"; + +    if (!$user) { +        sendcontrol "-ERR Protocol error\r\n"; +    } +    else { +        $username = $user; + +        sendcontrol "+OK\r\n"; +    } + +    return 0; +} + +sub PASS_pop3 { +    my ($password) = @_; + +    logmsg "PASS_pop3 got $password\n"; + +    if (($username ne "user") && ($password ne "secret")) { +        sendcontrol "-ERR Login failure\r\n"; +    } +    else { +        sendcontrol "+OK Login successful\r\n"; +    } + +    return 0; +} +  sub RETR_pop3 {      my ($testno) = @_;      my @data; | 
