Skip to content

Commit

Permalink
ALPN: add tests for imaps (no starttls)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliefm committed Nov 13, 2024
1 parent 8ee522c commit 9f58024
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions cassandane/Cassandane/Cyrus/ALPN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,45 @@ sub test_imap_bad
$self->assert_str_equals('no', $talk->get_last_completion_response());
}

sub test_imaps_none
{
my ($self) = @_;

my $imaps = $self->{instance}->get_service('imaps');
my $store = $imaps->create_store(username => 'cassandane');
my $talk = $store->get_client(OverrideALPN => undef);

$talk->select("INBOX");
$self->assert_str_equals('ok', $talk->get_last_completion_response());
}

sub test_imaps_good
{
my ($self) = @_;

my $imaps = $self->{instance}->get_service('imaps');
my $store = $imaps->create_store(username => 'cassandane');
my $talk = $store->get_client(); # correct ALPN map is the default

$talk->select("INBOX");
$self->assert_str_equals('ok', $talk->get_last_completion_response());
}

sub test_imaps_bad
{
my ($self) = @_;

my $imaps = $self->{instance}->get_service('imaps');
my $store = $imaps->create_store(username => 'cassandane');
my $talk;

eval {
$talk = $store->get_client(OverrideALPN => [ 'bogus' ]);
};
my $e = $@;

$self->assert_not_null($e);
$self->assert_matches(qr{tlsv1 alert no application protocol}, $e);
}

1;

0 comments on commit 9f58024

Please sign in to comment.