Skip to content

Commit

Permalink
WIP TestCase: support https for http service objects
Browse files Browse the repository at this point in the history
  • Loading branch information
elliefm committed Nov 13, 2024
1 parent 61af0f4 commit 1beb833
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
35 changes: 14 additions & 21 deletions cassandane/Cassandane/Cyrus/TestCase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -795,49 +795,42 @@ sub _setup_http_service_objects
{
my ($self) = @_;

# nothing to do if no http service
require Mail::JMAPTalk;
require Net::CalDAVTalk;
require Net::CardDAVTalk;

# nothing to do if no http or https service
my $service = $self->{instance}->get_service("http");
$service ||= $self->{instance}->get_service("https");
return if !$service;

my %common_args = (
user => 'cassandane',
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => ($service->is_ssl() ? 'https' : 'http'),
);

if ($self->{instance}->{config}->get_bit('httpmodules', 'carddav')) {
require Net::CardDAVTalk;
$self->{carddav} = Net::CardDAVTalk->new(
user => 'cassandane',
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
%common_args,
url => '/',
expandurl => 1,
);
}
if ($self->{instance}->{config}->get_bit('httpmodules', 'caldav')) {
require Net::CalDAVTalk;
$self->{caldav} = Net::CalDAVTalk->new(
user => 'cassandane',
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
%common_args,
url => '/',
expandurl => 1,
);
$self->{caldav}->UpdateAddressSet("Test User",
"cassandane\@example.com");
"cassandane\@example.com");
}
if ($self->{instance}->{config}->get_bit('httpmodules', 'jmap')) {
require Mail::JMAPTalk;
$ENV{DEBUGJMAP} = 1;
$self->{jmap} = Mail::JMAPTalk->new(
user => 'cassandane',
password => 'pass',
host => $service->host(),
port => $service->port(),
scheme => 'http',
%common_args,
url => '/jmap/',
);
}
Expand Down
9 changes: 9 additions & 0 deletions cassandane/Cassandane/Service.pm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ sub set_port
return $self->{_listener}->set_port($port);
}

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

# assume '-s' service argument indicates SSL and its absense
# indicates plaintext
return scalar grep { $_ eq '-s' } @{$self->{argv}};
}

# Return a hash of parameters suitable for passing
# to MessageStoreFactory::create.
sub store_params
Expand Down

0 comments on commit 1beb833

Please sign in to comment.