#!perl
use Cassandane::Tiny;

sub test_sasl_ir ($self)
{
    my $svc = $self->{instance}->get_service('imap');
    my $host = $svc->host();
    my $port = $svc->port();

    my $imtest = $self->{instance}->_find_binary('imtest');
    my $out = $self->{instance}->get_basedir() . "/imtest.$$.out";

    $self->{instance}->run_command(
        { redirects => { stdin => \". logout\r\n", stdout => $out } },
        $imtest, '-a', 'cassandane', '-w', 'password', '-m', 'plain',
                 '-p', $port, $host
    );

    my $exchange = slurp_file($out);

    # expect to have passed the hashed password in the authenticate line
    my $re = qr{^C: A01 AUTHENTICATE PLAIN AGNhc3NhbmRhbmUAcGFzc3dvcmQ=\r$}m;
    $self->assert_matches($re, $exchange);
}
