From 414536608b40640d22617bdadea6fc273cb5163b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20=C3=87etin?= Date: Mon, 18 Sep 2023 15:39:25 +0300 Subject: [PATCH] structure test file --- Packet++/header/SmtpLayer.h | 109 ++++++++++++------------- Packet++/src/SmtpLayer.cpp | 1 - Tests/Packet++Test/CMakeLists.txt | 1 + Tests/Packet++Test/Tests/SmtpTests.cpp | 28 +++++++ 4 files changed, 83 insertions(+), 56 deletions(-) create mode 100644 Tests/Packet++Test/Tests/SmtpTests.cpp diff --git a/Packet++/header/SmtpLayer.h b/Packet++/header/SmtpLayer.h index 38477ad89f..02823094ac 100644 --- a/Packet++/header/SmtpLayer.h +++ b/Packet++/header/SmtpLayer.h @@ -12,7 +12,6 @@ */ namespace pcpp { - /** * Class for general SMTP message */ @@ -182,60 +181,60 @@ namespace pcpp */ enum class SmtpStatusCode : int { - /// System status, or system help reply - SYSTEM_STATUS = 211, - /// Help message - HELP_MESSAGE = 214, - /// Server ready - SERVER_READY = 220, - /// Server closing transmission channel - SERVER_CLOSE = 221, - /// Requested mail action okay, completed - COMMAND_COMPLETE = 250, - /// User not local; will forward - FORWARD_PATH = 251, - /// Cannot VRFY user, but will accept message and attempt delivery - CANNOT_VERIFY = 252, - /// Server challenge - SERVER_CHALLENGE = 334, - /// Start mail input - START_MAIL = 354, - /// Service not available, closing transmission channel - SERVER_UNAVAILABLE = 421, - /// Requested mail action not taken: mailbox unavailable (mailbox busy or temporarily blocked) - MAILBOX_UNAVAILABLE_TEMP = 450, - /// Requested action aborted: local error in processing - SERVER_ABORT_LOCAL = 451, - /// Requested action not taken: insufficient system storage - SERVER_ABORT_STORAGE = 452, - /// Server unable to accommodate parameters - PARAM_NOT_ACCOMMODATED = 455, - /// Syntax error, command unrecognized - SYNTAXX_ERROR_CMD = 500, - /// Syntax error in parameters or arguments - SYNTAX_ERROR_PARAM = 501, - /// Command not implemented - CMD_NOT_IMPLEMENTED = 502, - /// Bad sequence of commands - BAD_CMD_SEQUENCE = 503, - /// Command parameter not implemented - PARAM_NOT_IMPLEMENTED = 504, - /// Server does not accept mail - NOT_ACCEPT = 521, - /// Encryption needed - ENCRYPT_NEED = 523, - /// Requested action not taken: mailbox unavailable (mailbox not found) - MAILBOX_UNAVAILABLE = 550, - /// User not local - USER_NOT_LOCAL = 551, - /// Requested mail action aborted: exceeded storage allocation - EXCEED_STORAGE = 552, - /// Requested action not taken: mailbox name not allowed - NAME_NOT_ALLOWED = 553, - /// Transaction failed - TRANSACTION_FAIL = 554, - /// Domain does not accept mail - DOMAIN_NOT_ACCEPT = 556 + /// System status, or system help reply + SYSTEM_STATUS = 211, + /// Help message + HELP_MESSAGE = 214, + /// Server ready + SERVER_READY = 220, + /// Server closing transmission channel + SERVER_CLOSE = 221, + /// Requested mail action okay, completed + COMMAND_COMPLETE = 250, + /// User not local; will forward + FORWARD_PATH = 251, + /// Cannot VRFY user, but will accept message and attempt delivery + CANNOT_VERIFY = 252, + /// Server challenge + SERVER_CHALLENGE = 334, + /// Start mail input + START_MAIL = 354, + /// Service not available, closing transmission channel + SERVER_UNAVAILABLE = 421, + /// Requested mail action not taken: mailbox unavailable (mailbox busy or temporarily blocked) + MAILBOX_UNAVAILABLE_TEMP = 450, + /// Requested action aborted: local error in processing + SERVER_ABORT_LOCAL = 451, + /// Requested action not taken: insufficient system storage + SERVER_ABORT_STORAGE = 452, + /// Server unable to accommodate parameters + PARAM_NOT_ACCOMMODATED = 455, + /// Syntax error, command unrecognized + SYNTAXX_ERROR_CMD = 500, + /// Syntax error in parameters or arguments + SYNTAX_ERROR_PARAM = 501, + /// Command not implemented + CMD_NOT_IMPLEMENTED = 502, + /// Bad sequence of commands + BAD_CMD_SEQUENCE = 503, + /// Command parameter not implemented + PARAM_NOT_IMPLEMENTED = 504, + /// Server does not accept mail + NOT_ACCEPT = 521, + /// Encryption needed + ENCRYPT_NEED = 523, + /// Requested action not taken: mailbox unavailable (mailbox not found) + MAILBOX_UNAVAILABLE = 550, + /// User not local + USER_NOT_LOCAL = 551, + /// Requested mail action aborted: exceeded storage allocation + EXCEED_STORAGE = 552, + /// Requested action not taken: mailbox name not allowed + NAME_NOT_ALLOWED = 553, + /// Transaction failed + TRANSACTION_FAIL = 554, + /// Domain does not accept mail + DOMAIN_NOT_ACCEPT = 556 }; /** A constructor that creates the layer from an existing packet raw data diff --git a/Packet++/src/SmtpLayer.cpp b/Packet++/src/SmtpLayer.cpp index 0f039b4262..4036b60f8c 100644 --- a/Packet++/src/SmtpLayer.cpp +++ b/Packet++/src/SmtpLayer.cpp @@ -4,7 +4,6 @@ namespace pcpp { - // ----------------- Class SmtpRequestLayer ----------------- bool SmtpRequestLayer::setCommand(SmtpCommand code) { return setCommandInternal(getCommandAsString(code)); } diff --git a/Tests/Packet++Test/CMakeLists.txt b/Tests/Packet++Test/CMakeLists.txt index 3f781b52ac..77dfcce681 100644 --- a/Tests/Packet++Test/CMakeLists.txt +++ b/Tests/Packet++Test/CMakeLists.txt @@ -27,6 +27,7 @@ add_executable( Tests/SipSdpTests.cpp Tests/Sll2Tests.cpp Tests/SllNullLoopbackTests.cpp + Tests/SmtpTests.cpp Tests/SomeIpSdTests.cpp Tests/SomeIpTests.cpp Tests/SSHTests.cpp diff --git a/Tests/Packet++Test/Tests/SmtpTests.cpp b/Tests/Packet++Test/Tests/SmtpTests.cpp new file mode 100644 index 0000000000..7dc27e835e --- /dev/null +++ b/Tests/Packet++Test/Tests/SmtpTests.cpp @@ -0,0 +1,28 @@ +#include "../TestDefinition.h" +#include "../Utils/TestUtils.h" +#include "EndianPortable.h" +#include "EthLayer.h" +#include "IPv4Layer.h" +#include "IPv6Layer.h" +#include "Packet.h" +#include "SmtpLayer.h" +#include "SystemUtils.h" +#include "TcpLayer.h" + +PTF_TEST_CASE(SmtpParsingTests) +{ + timeval time; + gettimeofday(&time, nullptr); +} + +PTF_TEST_CASE(SmtpCreationTests) +{ + timeval time; + gettimeofday(&time, nullptr); +} + +PTF_TEST_CASE(SmtpEditTests) +{ + timeval time; + gettimeofday(&time, nullptr); +}