]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: test-smtp-server-errors - Add actual HELO tests to "bad HELO" test.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 8 Apr 2021 23:49:21 +0000 (01:49 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 12 Apr 2021 12:14:08 +0000 (12:14 +0000)
Before, it only tested the EHLO command.

src/lib-smtp/test-smtp-server-errors.c

index d3e672f9f71647b0aab0d30766df370b5228c66a..44fc25d353ad2d89b04aefd9c9e54aab4d2beb7c 100644 (file)
@@ -993,7 +993,8 @@ static void test_bad_helo_client_input(struct client_connection *conn)
        int ret;
 
        for (;;) {
-               if (ctx->reply != 1) {
+               if (ctx->reply != 1 ||
+                   client_index == 0 || client_index == 2) {
                        ret = smtp_reply_parse_next(ctx->parser, FALSE, &reply,
                                                    &error);
                } else {
@@ -1012,10 +1013,10 @@ static void test_bad_helo_client_input(struct client_connection *conn)
                        break;
                case 1: /* bad command reply */
                        switch (client_index) {
-                       case 0:
+                       case 0: case 1:
                                i_assert(reply->status == 501);
                                break;
-                       case 1:
+                       case 2: case 3:
                                i_assert(reply->status == 250);
                                break;
                        default:
@@ -1045,9 +1046,15 @@ static void test_bad_helo_client_connected(struct client_connection *conn)
 
        switch (client_index) {
        case 0:
-               o_stream_nsend_str(conn->conn.output, "EHLO\r\n");
+               o_stream_nsend_str(conn->conn.output, "HELO\r\n");
                break;
        case 1:
+               o_stream_nsend_str(conn->conn.output, "EHLO\r\n");
+               break;
+       case 2:
+               o_stream_nsend_str(conn->conn.output, "HELO frop\r\n");
+               break;
+       case 3:
                o_stream_nsend_str(conn->conn.output, "EHLO frop\r\n");
                break;
        default:
@@ -1139,7 +1146,7 @@ static void test_bad_helo(void)
        test_begin("bad HELO");
        test_run_client_server(&smtp_server_set,
                               test_server_bad_helo,
-                              test_client_bad_helo, 2);
+                              test_client_bad_helo, 4);
        test_end();
 }