1use lib 't/lib'; 2use strict; 3use warnings; 4 5use Net::IMAP::Server::Test; 6my $t = "Net::IMAP::Server::Test"; 7 8$t->start_server_ok; 9 10# Non-SSL 11$t->connect_ok( "Non-SSL connection OK", 12 Class => "IO::Socket::INET", 13 PeerPort => $t->PORT, 14); 15ok($t->connected, "Is connected"); 16$t->cmd_like( 17 "LOGOUT", 18 "* BYE", 19 "tag OK", 20); 21ok(!$t->connected, "Is now disconnected"); 22 23# SSL connection 24$t->connect_ok; 25ok($t->connected, "Is connected"); 26$t->cmd_like( 27 "LOGOUT", 28 "* BYE", 29 "tag OK", 30); 31ok(!$t->connected, "Is now disconnected"); 32 33# Logged in 34$t->connect_ok; 35ok($t->connected, "Is now connected"); 36$t->cmd_ok("LOGIN username password"); 37ok($t->connected, "Still connected after LOGIN"); 38$t->cmd_like( 39 "LOGOUT", 40 "* BYE", 41 "tag OK", 42); 43ok(!$t->connected, "Is now disconnected"); 44 45# And selected 46$t->connect_ok; 47ok($t->connected, "Is now connected"); 48$t->cmd_ok("LOGIN username password"); 49ok($t->connected, "Still connected after LOGIN"); 50$t->cmd_ok("SELECT INBOX"); 51ok($t->connected, "Still connected after SELECT"); 52$t->cmd_like( 53 "LOGOUT", 54 "* BYE", 55 "tag OK", 56); 57ok(!$t->connected, "Is now disconnected"); 58 59done_testing; 60