aboutsummaryrefslogtreecommitdiffstats
path: root/tests/preauth-plaintext/imapd
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2020-08-03 20:51:42 +0200
committerGuilhem Moulin <guilhem@fripost.org>2020-08-03 20:51:42 +0200
commit531e27c2dfd67b4ad600c2ad5e13e608a75f04d8 (patch)
treed669f8caf9c795d88ce3e72736157901dbcaec15 /tests/preauth-plaintext/imapd
parent887526e77f7a3b707c53457b076d098a1edefeb7 (diff)
parentfe5501d4bb4c7c6365ceb009ea715356cca27a50 (diff)
Merge tag 'upstream/0.5.2' into debian
Upstream version 0.5.2
Diffstat (limited to 'tests/preauth-plaintext/imapd')
-rwxr-xr-xtests/preauth-plaintext/imapd44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/preauth-plaintext/imapd b/tests/preauth-plaintext/imapd
new file mode 100755
index 0000000..8f3ac30
--- /dev/null
+++ b/tests/preauth-plaintext/imapd
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -T
+
+use warnings;
+use strict;
+
+use Errno qw/EINTR/;
+use Socket qw/INADDR_LOOPBACK AF_INET SOCK_STREAM pack_sockaddr_in
+ SOL_SOCKET SO_REUSEADDR SHUT_RDWR/;
+
+socket(my $S, AF_INET, SOCK_STREAM, 0) or die;
+setsockopt($S, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die;
+bind($S, pack_sockaddr_in(10143, INADDR_LOOPBACK)) or die "bind: $!\n";
+listen($S, 1) or die "listen: $!";
+
+while (1) {
+ my $sockaddr = accept(my $conn, $S) or do {
+ next if $! == EINTR;
+ die "accept: $!";
+ };
+
+ # minimum CAPABILITY list, see tests/snippets/dovecot/interimap-required-capabilities.conf
+ $conn->printflush("* PREAUTH [CAPABILITY IMAP4rev1 ENABLE UIDPLUS LIST-EXTENDED QRESYNC LIST-STATUS] IMAP4rev1 Server\r\n");
+ my $x;
+
+ $x = $conn->getline() // next;
+ $x =~ /\A(\S+) ENABLE QRESYNC\r\n/ or die;
+ $conn->printflush("* ENABLED QRESYNC\r\n$1 OK ENABLE completed\r\n");
+
+ $x = $conn->getline() // next;
+ $x =~ /\A(\S+) LIST .*\r\n/ or die;
+ $conn->print("* LIST (\\Noselect) \"~\" \"\"\r\n");
+ $conn->print("* LIST () \"~\" INBOX\r\n");
+ $conn->print("* STATUS INBOX (UIDNEXT 1 UIDVALIDITY 1 HIGHESTMODSEQ 1)\r\n");
+ $conn->printflush("$1 OK LIST completed\r\n");
+
+ close($conn);
+}
+
+END {
+ if (defined $S) {
+ shutdown($S, SHUT_RDWR) or warn "shutdown: $!";
+ close($S) or print STDERR "Can't close: $!\n";
+ }
+}