Net-IMAP-Server

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Net-IMAP-Server

1.39 2016-05-01T00:42:17Z
 - Use 127.0.0.1 instead of localhost in tests
 - Fix precedence error with "return" in
   Net::IMAP::Server::Mailbox->selected

1.38 2014-01-26T20:16:17Z
 - Pass tests with IO::Socket::SSL 1.950 and above, which verify server SSL
   certificates by default.

1.37 2014-01-26T19:14:17Z
 - Fix parsing par parenthesized expressions with recent Regexp::Common

1.36 2012-01-17T08:09:17Z
 - Fix string literals (such as for APPEND), which have counted characters
   incorrectly since 1.32 due to newline trimming.

1.35 2012-11-12T03:22:17Z

Changes  view on Meta::CPAN

   TCP connection is in state CLOSE_WAIT

1.32 2012-04-06T00:45:17Z
 - Trim newlines passed to all commands, including continuation lines
 - Remove erroneous extra \n on server SASL responses
 - Bump MIME::Base64 dependency, and adjust bad mime encoding techniques to
   compensate
 - Better mapping of SASL mechanism names to method names

1.31 2012-04-01T01:18:17Z
 - Add test dependency on IO::Socket::SSL
 - Minor ASCII art updates

1.30 2011-10-25T11:30:17Z
 - Beginnings of a testsuite based on the RFC spec
 - Prepend, rather then append, un-asked-for message attributes, for picky
   clients
 - Properly escape mailbox names with quotes in LIST/LSUB
 - Trap and report base64 errors during AUTH
 - Returning -1 from a SASL auth now returns BAD, while returning false
   returns NO

META.yml  view on Meta::CPAN

---
abstract: 'A single-threaded multiplexing IMAP server implementation, using L<Net::Server::Coro>.'
author:
  - 'Alex Vandiver <alexmv@bestpractical.com>'
build_requires:
  ExtUtils::MakeMaker: 6.59
  IO::Socket::SSL: 0
configure_requires:
  ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
generated_by: 'Module::Install version 1.16'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: Net-IMAP-Server

Makefile.PL  view on Meta::CPAN

requires('Email::MIME::ContentType');
requires('Email::Simple' => 1.999);
requires('Encode::IMAPUTF7');
requires('MIME::Base64' => 3.11);
requires('Net::SSLeay');
requires('Net::Server::Coro' => 0.6);
requires('Regexp::Common');
requires('Test::More');
requires('UNIVERSAL::require');

test_requires('IO::Socket::SSL');

WriteAll;

t/lib/Net/IMAP/Server/Test.pm  view on Meta::CPAN

package Net::IMAP::Server::Test;
use base qw/Test::More/;

use strict;
use warnings;

use Socket;
use AnyEvent;
AnyEvent::detect();
use IO::Socket::SSL;
use Time::HiRes qw();

my $PPID = $$;
sub PORT()     { 2000 + $PPID*2 }
sub SSL_PORT() { 2001 + $PPID*2 }

sub import_extra {
    my $class = shift;
    Test::More->export_to_level(2);
    binmode $class->builder->output, ":utf8";

t/lib/Net/IMAP/Server/Test.pm  view on Meta::CPAN

    return $newclass;
}

sub socket_key { "SOCKET" };

sub connect {
    my $class = shift;
    my %args = (
        PeerAddr        => '127.0.0.1',
        PeerPort        => SSL_PORT,
        Class           => "IO::Socket::SSL",
        SSL_ca_file     => "certs/server-cert.pem",
        @_
    );
    my $socketclass = delete $args{Class};
    my $start = Time::HiRes::time();
    while (Time::HiRes::time() - $start < 10) {
        my $socket = $socketclass->new( %args );
        return $class->builder->{$class->socket_key} = $socket if $socket;
        Time::HiRes::sleep(0.1);
    }
    return;
}

sub connected {
    my $class = shift;
    my $socket = $class->get_socket;
    return 0 unless $socket->connected;

    my $buf;
    # We intentionally use the non-OO recv function here,
    # IO::Socket::SSL doesn't define a recv, and we want the low-level,
    # not under a layer version, anyways.
    my $waiting = recv($socket, $buf, 1, MSG_PEEK | MSG_DONTWAIT);

    # Undef if there's nothing currently waiting
    return 1 if not defined $waiting;

    # True if there is, false if the connection is closed
    return $waiting;
}

t/lib/Net/IMAP/Server/Test.pm  view on Meta::CPAN

    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my $class = shift;
    my $msg = @_ % 2 ? shift @_ : "Connected successfully";
    my $socket = $class->connect(@_);
    Test::More::ok($socket, $msg);
    Test::More::like($socket->getline, qr/^\* OK\b/, "Got connection message");
}

sub start_tls {
    my $class = shift;
    IO::Socket::SSL->start_SSL(
        $class->get_socket,
        SSL_ca_file => "certs/server-cert.pem",
    );
}

sub start_tls_ok {
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my $class = shift;
    my ($msg) = @_;
    my $socket = $class->get_socket || return Test::More::fail("Not connected!");
    $class->start_tls($socket);
    Test::More::diag(IO::Socket::SSL::errstr())
        unless $socket->isa("IO::Socket::SSL");
    Test::More::ok(
        $socket->isa("IO::Socket::SSL"),
        $msg || "Negotiated TLS",
    );
}

sub send_cmd {
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my $class = shift;
    my $cmd = shift;
    $class->send_line("tag $cmd", @_);
}



( run in 0.316 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )