| 1 |
#!/usr/bin/perl |
| 2 |
# |
| 3 |
# Copyright (c) 2011-2017 FastMail Pty Ltd. All rights reserved. |
| 4 |
# |
| 5 |
# Redistribution and use in source and binary forms, with or without |
| 6 |
# modification, are permitted provided that the following conditions |
| 7 |
# are met: |
| 8 |
# |
| 9 |
# 1. Redistributions of source code must retain the above copyright |
| 10 |
# notice, this list of conditions and the following disclaimer. |
| 11 |
# |
| 12 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
# notice, this list of conditions and the following disclaimer in |
| 14 |
# the documentation and/or other materials provided with the |
| 15 |
# distribution. |
| 16 |
# |
| 17 |
# 3. The name "Fastmail Pty Ltd" must not be used to |
| 18 |
# endorse or promote products derived from this software without |
| 19 |
# prior written permission. For permission or any legal |
| 20 |
# details, please contact |
| 21 |
# FastMail Pty Ltd |
| 22 |
# PO Box 234 |
| 23 |
# Collins St West 8007 |
| 24 |
# Victoria |
| 25 |
# Australia |
| 26 |
# |
| 27 |
# 4. Redistributions of any form whatsoever must retain the following |
| 28 |
# acknowledgment: |
| 29 |
# "This product includes software developed by Fastmail Pty. Ltd." |
| 30 |
# |
| 31 |
# FASTMAIL PTY LTD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 32 |
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 33 |
# EVENT SHALL OPERA SOFTWARE AUSTRALIA BE LIABLE FOR ANY SPECIAL, INDIRECT |
| 34 |
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF |
| 35 |
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 36 |
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 37 |
# OF THIS SOFTWARE. |
| 38 |
# |
| 39 |
|
| 40 |
package Cassandane::Cyrus::ID; |
| 41 |
use strict; |
| 42 |
use warnings; |
| 43 |
use Data::Dumper; |
| 44 |
|
| 45 |
use lib '.'; |
| 46 |
use base qw(Cassandane::Cyrus::TestCase); |
| 47 |
use Cassandane::Util::Log; |
| 48 |
use Cassandane::Instance; |
| 49 |
|
| 50 |
sub new |
| 51 |
{ |
| 52 |
my $class = shift; |
| 53 |
return $class->SUPER::new({ }, @_); |
| 54 |
} |
| 55 |
|
| 56 |
sub set_up |
| 57 |
{ |
| 58 |
my ($self) = @_; |
| 59 |
$self->SUPER::set_up(); |
| 60 |
} |
| 61 |
|
| 62 |
sub tear_down |
| 63 |
{ |
| 64 |
my ($self) = @_; |
| 65 |
$self->SUPER::tear_down(); |
| 66 |
} |
| 67 |
|
| 68 |
sub test_cmd_id |
| 69 |
{ |
| 70 |
my ($self) = @_; |
| 71 |
|
| 72 |
# Purge any syslog lines before this test runs. |
| 73 |
$self->{instance}->getsyslog(); |
| 74 |
|
| 75 |
my $imaptalk = $self->{store}->get_client(); |
| 76 |
|
| 77 |
return if not $imaptalk->capability()->{id}; |
| 78 |
|
| 79 |
my $res = $imaptalk->id(name => "cassandane"); |
| 80 |
xlog $self, Dumper $res; |
| 81 |
|
| 82 |
$self->assert_str_equals('ok', $imaptalk->get_last_completion_response()); |
| 83 |
|
| 84 |
# should have logged some timer output, which should include the sess id, |
| 85 |
# and since we sent a client id via IMAP ID, we should get that, too! |
| 86 |
if ($self->{instance}->{have_syslog_replacement}) { |
| 87 |
# make sure that the connection is ended so that imapd reset happens |
| 88 |
$imaptalk->logout(); |
| 89 |
undef $imaptalk; |
| 90 |
|
| 91 |
my @behavior_lines = $self->{instance}->getsyslog(qr/session ended/); |
| 92 |
|
| 93 |
$self->assert_num_gte(1, scalar @behavior_lines); |
| 94 |
|
| 95 |
$self->assert_matches(qr/\bid\.name=<cassandane>/, $_) for @behavior_lines; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
1; |