Merge ~bryce/ubuntu/+source/fetchmail:fix-2035-hirsute into ubuntu/+source/fetchmail:ubuntu/devel
- Git
- lp:~bryce/ubuntu/+source/fetchmail
- fix-2035-hirsute
- Merge into ubuntu/devel
Status: | Approved | ||||
---|---|---|---|---|---|
Approved by: | Bryce Harrington | ||||
Approved revision: | 9010333408c717a67ae36689238ffd12b5847831 | ||||
Proposed branch: | ~bryce/ubuntu/+source/fetchmail:fix-2035-hirsute | ||||
Merge into: | ubuntu/+source/fetchmail:ubuntu/devel | ||||
Diff against target: |
309 lines (+277/-0) 4 files modified
debian/changelog (+9/-0) debian/tests/control (+7/-0) debian/tests/mock-pop3-server.py (+214/-0) debian/tests/operation (+47/-0) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Utkarsh Gupta (community) | Approve | ||
Lucas Kanashiro (community) | Approve | ||
git-ubuntu developers | Pending | ||
Review via email: mp+398937@code.launchpad.net |
Commit message
Description of the change
Implements a basic DEP8 test for fetchmail against POP3.
Fetchmail operates against a mock POP3 server with stubs for the corresponding POP3 calls, and provides a single email message
This can be manually tested by running mock-pop3-server.py in one terminal window (or in the background), copying in the fetchmailrc settings from the dep3 test into your ~/.fetchmailrc and then running fetchmail.
I did not implement UIDL support in the server (just laziness), but fetchmail is supposed to fall back to LAST anyway, so for a basic test I think that's fine.
I did not also implement an IMAP mock server. Maybe that can be added later.
I've added a make check test as well, although I think the CI may already be doing make check, so this might be superfluous.
PPA: https:/
- d6e774e... by Bryce Harrington
-
* d/t/control, d/t/operation, d/t/mock-
pop3-server. py: Add DEP8 test for checking fetchmail's POP3 functionality. (LP: #1677818) - 9010333... by Bryce Harrington
-
changelog
Lucas Kanashiro (lucaskanashiro) wrote : | # |
The new test you added to call "make check" is not working for me locally:
autopkgtest [15:36:23]: test command1: make check
autopkgtest [15:36:23]: test command1: [------
make: *** No rule to make target 'check'. Stop.
autopkgtest [15:36:24]: test command1: -------
autopkgtest [15:36:24]: test command1: - - - - - - - - - - results - - - - - - - - - -
command1 FAIL non-zero exit status 2
The "operation" test and the others are working fine:
autopkgtest [15:39:20]: @@@@@@@
command1 FAIL non-zero exit status 2
installation PASS
service PASS
operation PASS
I am not a Python expert but the code looks good. Good job! The only thing I might add is that I'd use also "set -x" in the shell script to print the commands being executed, they can be handy when debugging failures.
Moreover, I'd strongly recommend to forward the "operation" test to Debian.
Bryce Harrington (bryce) wrote : | # |
Thank you for the review feedback!
I've noted your two suggestions, to add set -x and the issue with the make check. Both quite sensible review feedback, but both are causing some weird stuff I don't quite understand.
Easier piece first. The weirdness is that 'make check' works fine for me. But, the solution almost certainly is to run ./configure first. This causes no issue on my end so I've added it and pushed to this MP. Please re-test and verify it works for you. I'm fine with pushing this, but kinda would like to understand why it's needed.
Harder piece is that adding 'set -x' should be a completely cosmetic change, yet it results in autopkgtest failing for me with it set. I've pushed the changes with this set, and would appreciate if you would run the tests and see if it also fails for you, and then if it does, if you have ideas what's causing it? If you're not sure, I'd like to propose chalking it up to some sort of bash bug, punt, and omit 'set -x' for now?
Sergio Durigan Junior (sergiodj) wrote : | # |
Without having seen or tested this, 'set -x' outputs to stderr, so you will need the allow-stderr restriction on the test.
Utkarsh Gupta (utkarsh) wrote : | # |
Hi Bryce,
Awesome work with this MP!
As for the "make check" part, it still doesn't work for me. I've pasted the logs below.
Simplest way to reproduce is to run sbuild and then autopkgtest via:
`autopkgtest -U -s --apt-pocket=
8<---8<
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/autopkgte
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
autopkgtest [14:31:35]: test command1: -------
autopkgtest [14:31:36]: test command1: - - - - - - - - - - results - - - - - - - - - -
command1 FAIL non-zero exit status 1
8<---8<
I started to take a look at it and after installing gcc, here's where it fails[1]: https:/
But I further studied the log and it shows that you also need python, python3, and build-essential packages in order to ./configure to work.
After installing those 4 packages, the next problem I hit was:
`configure: error: SSL support enabled, but OpenSSL not found`
This means, installing libssl-dev. And then there were no errors. Yay! \o/
So the final diff that I know have, looks like:
8<---8<
--- a/debian/
+++ b/debian/
@@ -1,5 +1,5 @@
Test-Command: ./configure && make check
-Depends: @
+Depends: @, build-essential, gcc, libssl-dev, python, python3
Restrictions: allow-stderr
Tests: installation
8<---8<
With this diff applied, I now have the tests passing:
8<---8<
make check-TESTS
make[3]: Entering directory '/tmp/autopkgte
make[4]: Entering directory '/tmp/autopkgte
PASS: t.smoke
SKIP: t.validate-xhtml10
SKIP: t.validate-xhtml
PASS: t.x509_name_match
PASS: t.realpath
PASS: t.tls-aux
=======
Testsuite summary for fetchmail 6.4.16
=======
# TOTAL: 6
# PASS: 4
# SKIP: 2
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
=======
make[4]: Leaving directory '/tmp/autopkgte
make[3]: Leaving directory '/tmp/autopkgte
make[2]: Leaving directory '/tmp/autopkgte
Making check in po
make[2]: Entering directory '/tmp/autopkgte
make[2]: Nothing to be done for 'check'.
make[2]: Leaving directory '/tmp/autopkgte
make[1]: Leaving directory '/tmp/autopkgte
autopkgtest [15:11:35]: test command1: -------
autopkgtest [15:11:35]: test command1: - - - - - - - - - - results - -
command1 PASS
8<---8<
-------
Now, onto the next test: "operation".
R...
Lucas Kanashiro (lucaskanashiro) wrote : | # |
TBH I am not sure if we will benefit from the "make check" test considering autopkgtest is more about testing the installed version of the package. Which kind of issue we could spot with it?
About the "set -x" in the operation test, what happens is what Sergio mentioned, the commands will be printed to stderr by default. We have three options here:
1) Do nothing and leave it as-is, without printing the commands;
2) Add the allow-stderr restriction as Utkarsh mentioned above;
3) Add "exec 2>&1" to the top of the shell script to pipe everything to stdout.
I'd go with option 3 (I have done that in some of my packages in Debian), but feel free to pick whatever you think makes more sense to you.
Bryce Harrington (bryce) wrote : | # |
> TBH I am not sure if we will benefit from the "make check" test
> considering autopkgtest is more about testing the installed
> version of the package. Which kind of issue we could spot with it?
My thought process here was that running the upstream testsuite is a standard practice for inclusion in autopkgtests. fetchmail has a handful of test cases, triggered by running make check, via Perl's standard testing tooling:
PASS: t.smoke
SKIP: t.validate-xhtml10
SKIP: t.validate-xhtml
PASS: t.x509_name_match
PASS: t.realpath
PASS: t.tls-aux
Admittedly, these test cases are super trivial, which is why I went ahead with creating the POP3 test. But, perhaps future development will add more tests, and in any case they seemed to pass (for me), so figured it couldn't hurt to hook them up. It doesn't look like 'make check' is triggered during the fetchmail build process, so to me it seemed appropriate to do in a DEP8.
Bryce Harrington (bryce) wrote : | # |
'set -x' implies 'allow-stderr' will be needed. Duh. Yeah why was I overthinking this.
However, I would prefer not to set allow-stderr, because actually it's been quite useful in development to be strict about stderr messages, and I took efforts to deal with all "regular" stderr messages, so if more pop up I'd like to treat them as actual problems. I am guessing the same problem will exist with adding "exec 2>&1", although that does seem like a clever approach I'll try to remember for other situations.
However, I think it may be okay to just go with option #1. In the mock server, I sprinkled dbg() commands at keep points to assist in spotting where errors might occur. Most of the problems I ran into during development were in either serve() or process(), which is why they have 10 dbg()'s between the two of them.
So, to sum up, I'd like to stay strict with treating stderr content as erroneous, and just rely on being verbose with debug messages for tracing program flow.
Bryce Harrington (bryce) wrote : | # |
I've pushed latest changes, please re-review.
As mentioned in the last 2 comments, I'm opting to take the make check dependencies from Utkarsh's analysis, and opting to take Lucas' #1 suggestion (drop 'set -x'). With these changes, autopkgtest passes both inside a build container (via `sudo autopkgtest ./fetchmail_
Thanks again!
Lucas Kanashiro (lucaskanashiro) wrote : | # |
> My thought process here was that running the upstream testsuite is a standard
> practice for inclusion in autopkgtests. fetchmail has a handful of test
> cases, triggered by running make check, via Perl's standard testing tooling:
IMO running upstream more code level tests (like unit tests) makes sense when you are testing a library, where when it is installed you want it behaving well when imported by other programs. AFAICS fetchmail ships only the binaries, docs, and config files. In short, we do not care if the library is behaving as expected because there is no library, what really matters is what we ship as a .deb. That's what autopkgtest was created for, test the installed binary packages.
I am not telling you to not do this, but this is how I rationale about testing installed version of the packages.
> Admittedly, these test cases are super trivial, which is why I went ahead with
> creating the POP3 test. But, perhaps future development will add more tests,
> and in any case they seemed to pass (for me), so figured it couldn't hurt to
> hook them up. It doesn't look like 'make check' is triggered during the
> fetchmail build process, so to me it seemed appropriate to do in a DEP8.
Maybe a good idea is to submit a salsa MR to call "make check" during the build process.
Lucas Kanashiro (lucaskanashiro) wrote : | # |
I am fine with you not using "set -x", you already have some debug info as you said.
autopkgtest is happy for me now:
autopkgtest [18:51:00]: @@@@@@@
command1 PASS
installation PASS
service PASS
operation PASS
Bryce Harrington (bryce) wrote : | # |
Thanks Lucas, I'll forward those changes to Debian.
$ dput ubuntu fetchmail_
Checking signature on .changes
gpg: /home/bryce/
Checking signature on .dsc
gpg: /home/bryce/
Uploading to ubuntu (via ftp to upload.ubuntu.com):
Uploading fetchmail_
Uploading fetchmail_
Uploading fetchmail_
Uploading fetchmail_
Successfully uploaded packages.
$ git ubuntu tag --upload
$ git push pkg upload/
Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 12 threads
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 4.99 KiB | 1.25 MiB/s, done.
Total 17 (delta 8), reused 0 (delta 0), pack-reused 0
To ssh://git.
* [new tag] upload/
Bryce Harrington (bryce) wrote : | # |
Looks like fetchmail isn't in salsa for some reason. I filed a bug report instead.
Utkarsh Gupta (utkarsh) wrote : | # |
Awesome, works at my end as well! Great work!
Matthias Andree (matthias-andree) wrote : | # |
Bryce,
as upstream fetchmail maintainer: thanks for writing such a test, I am considering taking it into upstream fetchmail 6.5 (Git branch legacy_6x).
One remark, writing network-based self-tests for FreeBSD's OpenVPN package I figured that hardcoding ports as done here can cause false-negative test results so I suggest to either retry with waiting and random different ports and random delay times a few times, and ultimately going for a three-state result (at least upstream I can exit 77 to "SKIP" a test within the automake testing framework).
Matthias Andree (matthias-andree) wrote : | # |
https:/
https:/
(not yet integrated at the time of this writing)
Unmerged commits
- 9010333... by Bryce Harrington
-
changelog
- d6e774e... by Bryce Harrington
-
* d/t/control, d/t/operation, d/t/mock-
pop3-server. py: Add DEP8 test for checking fetchmail's POP3 functionality. (LP: #1677818) - 1deb68e... by Bryce Harrington
-
* d/t/control: Invoke upstream testsuite via make check
- 750dd5b... by Dimitri John Ledkov
-
6.4.16-1build1 (patches unapplied)
Imported using git-ubuntu import.
Preview Diff
1 | diff --git a/debian/changelog b/debian/changelog |
2 | index fdcfa8a..dcc9109 100644 |
3 | --- a/debian/changelog |
4 | +++ b/debian/changelog |
5 | @@ -1,3 +1,12 @@ |
6 | +fetchmail (6.4.16-1ubuntu1) hirsute; urgency=medium |
7 | + |
8 | + * d/t/control: Invoke upstream testsuite via make check. |
9 | + * d/t/control, d/t/operation, d/t/mock-pop3-server.py: Add DEP8 test |
10 | + for checking fetchmail's POP3 functionality. |
11 | + (LP: #1677818) |
12 | + |
13 | + -- Bryce Harrington <bryce@canonical.com> Thu, 04 Mar 2021 18:40:28 +0000 |
14 | + |
15 | fetchmail (6.4.16-1build1) hirsute; urgency=medium |
16 | |
17 | * No change rebuild with fixed ownership. |
18 | diff --git a/debian/tests/control b/debian/tests/control |
19 | index cec627b..c69d44d 100644 |
20 | --- a/debian/tests/control |
21 | +++ b/debian/tests/control |
22 | @@ -1,3 +1,7 @@ |
23 | +Test-Command: ./configure && make check |
24 | +Depends: @, build-essential, gcc, libssl-dev, python, python3 |
25 | +Restrictions: allow-stderr |
26 | + |
27 | Tests: installation |
28 | Depends: @ |
29 | Restrictions: |
30 | @@ -6,3 +10,6 @@ Tests: service |
31 | Depends: @, systemd-sysv |
32 | Restrictions: needs-root, allow-stderr |
33 | |
34 | +Tests: operation |
35 | +Depends: @, python3 |
36 | +Restrictions: needs-root |
37 | diff --git a/debian/tests/mock-pop3-server.py b/debian/tests/mock-pop3-server.py |
38 | new file mode 100644 |
39 | index 0000000..159069b |
40 | --- /dev/null |
41 | +++ b/debian/tests/mock-pop3-server.py |
42 | @@ -0,0 +1,214 @@ |
43 | +#!/usr/bin/env python3 |
44 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
45 | + |
46 | +# Copyright (C) 2019 Bryce W. Harrington |
47 | +# |
48 | +# Released under GNU GPLv2 or later, read the file 'LICENSE.GPLv2+' for |
49 | +# more information. |
50 | +# |
51 | +# Permission is hereby granted, free of charge, to any person obtaining |
52 | +# a copy of this software and associated documentation files (the |
53 | +# "Software"), to deal in the Software without restriction, including |
54 | +# without limitation the rights to use, copy, modify, merge, publish, |
55 | +# distribute, sublicense, and/or sell copies of the Software, and to |
56 | +# permit persons to whom the Software is furnished to do so, subject to |
57 | +# the following conditions: |
58 | +# |
59 | +# The above copyright notice and this permission notice shall be included |
60 | +# in all copies or substantial portions of the Software. |
61 | +# |
62 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
63 | +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
64 | +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
65 | +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
66 | +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
67 | +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
68 | +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
69 | +# |
70 | +# Author: Bryce Harrington <bryce@canonical.com> |
71 | + |
72 | +import os |
73 | +import sys |
74 | +import socket |
75 | +from tempfile import mkstemp |
76 | + |
77 | +DEBUGGING = True |
78 | +DEFAULT_HOST = '' |
79 | +DEFAULT_PORT = 11110 |
80 | +NEWLINE = b"\r\n" |
81 | +MESSAGE_CONTENT = b''' |
82 | +From: test@example.com\r |
83 | +Subject: Test message\r |
84 | +\r |
85 | +This is a body for testing\r |
86 | +\r |
87 | +''' |
88 | + |
89 | +def dbg(msg): |
90 | + """Prints information to stdout if debugging is enabled""" |
91 | + if DEBUGGING: |
92 | + sys.stdout.write("{}\n".format(msg)) |
93 | + |
94 | +def command_user(data, msg): |
95 | + return b'+OK user accepted' |
96 | + |
97 | +def command_pass(data, msg): |
98 | + return b'+OK pass accepted' |
99 | + |
100 | +def command_stat(data, msg): |
101 | + return b'+OK 1 %i' %(msg.size) |
102 | + |
103 | +def command_list(data, msg): |
104 | + if data == b'LIST': |
105 | + return b'+OK 1 messages (%i octets)'%(msg.size) \ |
106 | + + NEWLINE \ |
107 | + + b'1 %i'%(msg.size) \ |
108 | + + NEWLINE \ |
109 | + + b'.' |
110 | + else: |
111 | + cmd, num = data.split() |
112 | + return b'+OK 1 (%i octects)'%(msg.size) |
113 | + |
114 | +def command_last(data, msg): |
115 | + return b'+OK 0' |
116 | + |
117 | +def command_top(data, msg): |
118 | + cmd, num, lines = data.split() |
119 | + assert num == b'1', "unknown message number: {num}".format(num) |
120 | + bottom = NEWLINE.join(msg.bottom[:int(lines)]) |
121 | + text = msg.top + NEWLINE + NEWLINE + bottom |
122 | + dbg(text) |
123 | + return b'+OK top of message follows%s' % (NEWLINE + text + NEWLINE + b'.') |
124 | + |
125 | +def command_retr(data, msg): |
126 | + return b'+OK %i octets'%(msg.size) \ |
127 | + + NEWLINE \ |
128 | + + data \ |
129 | + + NEWLINE \ |
130 | + + b'.' |
131 | + |
132 | +def command_dele(data, msg): |
133 | + return b'+OK 1 %i'%(msg.size) |
134 | + |
135 | +def command_noop(data, msg): |
136 | + return b'+OK 1 %i'%(msg.size) |
137 | + |
138 | +def command_quit(data, msg): |
139 | + return b'+OK mock pop3 server signing off' |
140 | + |
141 | +COMMANDS = { |
142 | + b'USER' : command_user, |
143 | + b'PASS' : command_pass, |
144 | + b'STAT' : command_stat, |
145 | + b'LIST' : command_list, |
146 | + b'LAST' : command_last, |
147 | + b'TOP' : command_top, |
148 | + b'RETR' : command_retr, |
149 | + b'DELE' : command_dele, |
150 | + b'NOOP' : command_noop, |
151 | + b'QUIT' : command_quit, |
152 | +} |
153 | + |
154 | +class Mailbox: |
155 | + """Encapsulates a mailbox containing a single email message""" |
156 | + def __init__(self, message_filename): |
157 | + with open(message_filename, "rb") as msg: |
158 | + data = msg.read() |
159 | + self.data = data |
160 | + self.size = len(data) |
161 | + self.top, rest = data.split(NEWLINE + NEWLINE, 1) |
162 | + self.bottom = rest.split(NEWLINE) |
163 | + |
164 | + |
165 | +class Mailserver: |
166 | + def __init__(self, conn, mbox): |
167 | + self._conn = conn |
168 | + self._mbox = mbox |
169 | + self._chunk_size = 4096 |
170 | + |
171 | + def close(self): |
172 | + dbg(" - Server exiting") |
173 | + self._conn.close() |
174 | + |
175 | + def send(self, data): |
176 | + dbg(" - Server sending") |
177 | + self._conn.sendall(data + NEWLINE) |
178 | + |
179 | + def receive(self): |
180 | + dbg(" - Server receiving") |
181 | + data = [] |
182 | + while True: |
183 | + chunk = self._conn.recv(self._chunk_size) |
184 | + if NEWLINE in chunk: |
185 | + data.append(chunk[:chunk.index(NEWLINE)]) |
186 | + break |
187 | + data.append(chunk) |
188 | + return b"".join(data) |
189 | + |
190 | + def process(self): |
191 | + data = self.receive() |
192 | + dbg(" - Received: '{}'".format(data)) |
193 | + command = data.split(None, 1)[0] |
194 | + if command in COMMANDS.keys(): |
195 | + response = COMMANDS[command](data, self._mbox) |
196 | + dbg(" - Response: {}".format(response)) |
197 | + try: |
198 | + self.send(response) |
199 | + if command == b'QUIT': |
200 | + return False |
201 | + except BrokenPipeError: |
202 | + dbg(" - Client terminated connection") |
203 | + return False |
204 | + else: |
205 | + self.send(b"-ERR unrecognized command") |
206 | + return True |
207 | + |
208 | +def serve(messages_filename, host=DEFAULT_HOST, port=DEFAULT_PORT): |
209 | + dbg("Serving for {} on {}".format(host, port)) |
210 | + |
211 | + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
212 | + sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
213 | + sock.bind((host, port)) |
214 | + |
215 | + mailbox = Mailbox(messages_filename) |
216 | + |
217 | + try: |
218 | + dbg("* mock-pop3-server ready on {}:{}".format(host, port)) |
219 | + while True: |
220 | + sock.listen(1) |
221 | + conn, address = sock.accept() |
222 | + dbg("* Connection from {}".format(address)) |
223 | + server = Mailserver(conn, mailbox) |
224 | + server.send(b"+OK mock-pop3-server pop3 server ready") |
225 | + try: |
226 | + dbg("* Processing commands for connection...") |
227 | + while server.process(): |
228 | + dbg("* Finished command") |
229 | + pass |
230 | + finally: |
231 | + dbg("* Closing remote connection") |
232 | + server.close() |
233 | + except KeyboardInterrupt: |
234 | + dbg("* mock-pop3-server interrupted") |
235 | + return 1 |
236 | + except SystemExit: |
237 | + dbg("* mock-pop3-server exiting") |
238 | + return 1 |
239 | + finally: |
240 | + sock.shutdown(socket.SHUT_RDWR) |
241 | + sock.close() |
242 | + return 0 |
243 | + |
244 | + |
245 | +if __name__ == "__main__": |
246 | + fd, message_filename = mkstemp(prefix='message-', suffix='.txt') |
247 | + dbg("Creating message file '{}'".format(message_filename)) |
248 | + |
249 | + with open(message_filename, 'wb') as f: |
250 | + f.write(MESSAGE_CONTENT.lstrip()) |
251 | + |
252 | + try: |
253 | + exit(serve(message_filename, host=DEFAULT_HOST, port=DEFAULT_PORT)) |
254 | + except KeyError: |
255 | + sys.stderr.write("Exiting\n") |
256 | + sys.exit(1) |
257 | diff --git a/debian/tests/operation b/debian/tests/operation |
258 | new file mode 100755 |
259 | index 0000000..c36dfb6 |
260 | --- /dev/null |
261 | +++ b/debian/tests/operation |
262 | @@ -0,0 +1,47 @@ |
263 | +#!/bin/sh |
264 | + |
265 | +########################### |
266 | +### Test fetching email ### |
267 | +########################### |
268 | + |
269 | +set -e |
270 | + |
271 | +POP3_SERVER=127.0.0.1 |
272 | +POP3_PORT=11110 |
273 | +USER=${USER:-user} |
274 | +PASSWORD=ubuntu |
275 | +WORKDIR=$(mktemp -d) |
276 | +trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM |
277 | + |
278 | +LOG="${WORKDIR}/fetchmail.log" |
279 | +MBOX="${WORKDIR}/test-mbox-$(date +%''s_%N)" |
280 | +CONFIG="${WORKDIR}/fetchmailrc" |
281 | + |
282 | +echo "Configuring a functional local mail system" |
283 | + |
284 | +python3 "$(dirname ${0})/mock-pop3-server.py" & |
285 | +SERVER_PID=$! |
286 | +sleep 1 |
287 | + |
288 | +# Configure fetchmail |
289 | +cat > "${CONFIG}" <<EOF |
290 | +poll ${POP3_SERVER} port ${POP3_PORT} no uidl with protocol POP3: |
291 | + auth password |
292 | + user '${USER}' there with password '${PASSWORD}' |
293 | + is ${USER} here |
294 | + sslproto '' |
295 | + mda "/bin/sh -c 'cat > ${MBOX}'" |
296 | +EOF |
297 | +chmod 700 "${CONFIG}" |
298 | +chown -R fetchmail "${WORKDIR}" |
299 | + |
300 | +# Run fetchmail |
301 | +echo "Checking fetchmail operates" |
302 | +sudo -u fetchmail /usr/bin/fetchmail -d0 -vvv -f "${CONFIG}" "${POP3_SERVER}" |
303 | + |
304 | +# TODO: Verify the test email was delivered to expected destination |
305 | +echo "Checking test email was received" |
306 | +grep "Received: from " "${MBOX}" |
307 | + |
308 | +kill ${SERVER_PID} |
309 | +echo "OK" |
I've rebased this MP on the new fetchmail that sync'd in recently.