comparison 3rdparty/vmime/tests/net/pop3/POP3CommandTest.cpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library. Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23
24 #include "tests/testUtils.hpp"
25
26 #include "tests/net/pop3/POP3TestUtils.hpp"
27
28 #include "vmime/net/pop3/POP3Command.hpp"
29
30
31 using namespace vmime::net::pop3;
32
33
34 VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
35
36 VMIME_TEST_LIST_BEGIN
37 VMIME_TEST(testCreateCommand)
38 VMIME_TEST(testCreateCommandParams)
39 VMIME_TEST(testCAPA)
40 VMIME_TEST(testNOOP)
41 VMIME_TEST(testAUTH)
42 VMIME_TEST(testAUTH_InitialResponse)
43 VMIME_TEST(testSTLS)
44 VMIME_TEST(testAPOP)
45 VMIME_TEST(testUSER)
46 VMIME_TEST(testPASS)
47 VMIME_TEST(testSTAT)
48 VMIME_TEST(testLIST)
49 VMIME_TEST(testLISTMessage)
50 VMIME_TEST(testUIDL)
51 VMIME_TEST(testUIDLMessage)
52 VMIME_TEST(testDELE)
53 VMIME_TEST(testRETR)
54 VMIME_TEST(testTOP)
55 VMIME_TEST(testRSET)
56 VMIME_TEST(testQUIT)
57 VMIME_TEST(testWriteToSocket)
58 VMIME_TEST_LIST_END
59
60
61 void testCreateCommand()
62 {
63 vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND");
64
65 VASSERT_NOT_NULL("Not null", cmd);
66 VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
67 }
68
69 void testCreateCommandParams()
70 {
71 vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
72
73 VASSERT_NOT_NULL("Not null", cmd);
74 VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
75 }
76
77 void testCAPA()
78 {
79 vmime::shared_ptr <POP3Command> cmd = POP3Command::CAPA();
80
81 VASSERT_NOT_NULL("Not null", cmd);
82 VASSERT_EQ("Text", "CAPA", cmd->getText());
83 }
84
85 void testNOOP()
86 {
87 vmime::shared_ptr <POP3Command> cmd = POP3Command::NOOP();
88
89 VASSERT_NOT_NULL("Not null", cmd);
90 VASSERT_EQ("Text", "NOOP", cmd->getText());
91 }
92
93 void testAUTH()
94 {
95 vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism");
96
97 VASSERT_NOT_NULL("Not null", cmd);
98 VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
99 }
100
101 void testAUTH_InitialResponse()
102 {
103 vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism", "initial-response");
104
105 VASSERT_NOT_NULL("Not null", cmd);
106 VASSERT_EQ("Text", "AUTH saslmechanism initial-response", cmd->getText());
107 }
108
109 void testSTLS()
110 {
111 vmime::shared_ptr <POP3Command> cmd = POP3Command::STLS();
112
113 VASSERT_NOT_NULL("Not null", cmd);
114 VASSERT_EQ("Text", "STLS", cmd->getText());
115 }
116
117 void testAPOP()
118 {
119 vmime::shared_ptr <POP3Command> cmd = POP3Command::APOP("user", "digest");
120
121 VASSERT_NOT_NULL("Not null", cmd);
122 VASSERT_EQ("Text", "APOP user digest", cmd->getText());
123 }
124
125 void testUSER()
126 {
127 vmime::shared_ptr <POP3Command> cmd = POP3Command::USER("user");
128
129 VASSERT_NOT_NULL("Not null", cmd);
130 VASSERT_EQ("Text", "USER user", cmd->getText());
131 }
132
133 void testPASS()
134 {
135 vmime::shared_ptr <POP3Command> cmd = POP3Command::PASS("pass");
136
137 VASSERT_NOT_NULL("Not null", cmd);
138 VASSERT_EQ("Text", "PASS pass", cmd->getText());
139 }
140
141 void testSTAT()
142 {
143 vmime::shared_ptr <POP3Command> cmd = POP3Command::STAT();
144
145 VASSERT_NOT_NULL("Not null", cmd);
146 VASSERT_EQ("Text", "STAT", cmd->getText());
147 }
148
149 void testLIST()
150 {
151 vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST();
152
153 VASSERT_NOT_NULL("Not null", cmd);
154 VASSERT_EQ("Text", "LIST", cmd->getText());
155 }
156
157 void testLISTMessage()
158 {
159 vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST(42);
160
161 VASSERT_NOT_NULL("Not null", cmd);
162 VASSERT_EQ("Text", "LIST 42", cmd->getText());
163 }
164
165 void testUIDL()
166 {
167 vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL();
168
169 VASSERT_NOT_NULL("Not null", cmd);
170 VASSERT_EQ("Text", "UIDL", cmd->getText());
171 }
172
173 void testUIDLMessage()
174 {
175 vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL(42);
176
177 VASSERT_NOT_NULL("Not null", cmd);
178 VASSERT_EQ("Text", "UIDL 42", cmd->getText());
179 }
180
181 void testDELE()
182 {
183 vmime::shared_ptr <POP3Command> cmd = POP3Command::DELE(42);
184
185 VASSERT_NOT_NULL("Not null", cmd);
186 VASSERT_EQ("Text", "DELE 42", cmd->getText());
187 }
188
189 void testRETR()
190 {
191 vmime::shared_ptr <POP3Command> cmd = POP3Command::RETR(42);
192
193 VASSERT_NOT_NULL("Not null", cmd);
194 VASSERT_EQ("Text", "RETR 42", cmd->getText());
195 }
196
197 void testTOP()
198 {
199 vmime::shared_ptr <POP3Command> cmd = POP3Command::TOP(42, 567);
200
201 VASSERT_NOT_NULL("Not null", cmd);
202 VASSERT_EQ("Text", "TOP 42 567", cmd->getText());
203 }
204
205 void testRSET()
206 {
207 vmime::shared_ptr <POP3Command> cmd = POP3Command::RSET();
208
209 VASSERT_NOT_NULL("Not null", cmd);
210 VASSERT_EQ("Text", "RSET", cmd->getText());
211 }
212
213 void testQUIT()
214 {
215 vmime::shared_ptr <POP3Command> cmd = POP3Command::QUIT();
216
217 VASSERT_NOT_NULL("Not null", cmd);
218 VASSERT_EQ("Text", "QUIT", cmd->getText());
219 }
220
221 void testWriteToSocket()
222 {
223 vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
224
225 vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
226 vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
227 (vmime::dynamicCast <vmime::net::socket>(sok),
228 vmime::shared_ptr <vmime::net::timeoutHandler>());
229
230 cmd->send(conn);
231
232 vmime::string response;
233 sok->localReceive(response);
234
235 VASSERT_EQ("Sent buffer", "MY_COMMAND param1 param2\r\n", response);
236 }
237
238 VMIME_TEST_SUITE_END