1package main; 2use strict; 3use warnings; 4 5#--------------------------------------------------------------------------# 6# requirements, fixtures and plan 7#--------------------------------------------------------------------------# 8 9use Test::More; 10use Proc::Background; 11use File::Spec; 12use IO::CaptureOutput qw/capture/; 13use Mail::Box::Manager; 14use Probe::Perl; 15 16# expected credentials for server and client 17my $username = 'johndoe'; 18my $password = '123456'; 19my $port = '31415'; 20 21# fire up the local mock server or skip tests 22my $imapd = Proc::Background->new( 23 { die_upon_destroy => 1 }, 24 Probe::Perl->find_perl_interpreter(), 25 File::Spec->rel2abs( File::Spec->catfile(qw/t bin imapd.pl/) ), 26 $port, $username, $password, 27); 28 29sleep 2; # give time for imapd to fire up and listen 30 31unless ( $imapd && $imapd->alive ) { 32 plan skip_all => "Couldn't launch mock imapd on localhost"; 33} 34 35plan tests => 3; 36 37my ( $stdout, $stderr, $rc ); 38 39#--------------------------------------------------------------------------# 40# tests begin here 41#--------------------------------------------------------------------------# 42 43$ENV{MAIL_BOX_IMAP4_SSL_NOVERIFY} = 1; 44 45ok( $imapd->alive, "mock imapd server is alive" ); 46 47my $mbm = Mail::Box::Manager->new; 48 49$mbm->registerType( 'imaps', 'Mail::Box::IMAP4::SSL' ); 50 51my $imap = $mbm->open( folder => "imaps://$username\:$password\@127.0.0.1:$port/" ); 52 53ok( $imap, "connected to mock imapd" ); 54is( $imap->type, 'imaps', "imaps folder has correct type" ); 55 56