From 7196e4cc4bfc8e7be4a3bebb925e50641bfabc45 Mon Sep 17 00:00:00 2001 From: ellie timoney Date: Wed, 13 Nov 2024 10:43:24 +1100 Subject: [PATCH] WIP TestCase: support https for http service objects --- cassandane/Cassandane/Cyrus/TestCase.pm | 35 ++++++++++--------------- cassandane/Cassandane/Service.pm | 9 +++++++ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/cassandane/Cassandane/Cyrus/TestCase.pm b/cassandane/Cassandane/Cyrus/TestCase.pm index cb9a32aa96..6a4da85838 100644 --- a/cassandane/Cassandane/Cyrus/TestCase.pm +++ b/cassandane/Cassandane/Cyrus/TestCase.pm @@ -795,22 +795,23 @@ 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, ); @@ -818,26 +819,18 @@ sub _setup_http_service_objects 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/', ); } diff --git a/cassandane/Cassandane/Service.pm b/cassandane/Cassandane/Service.pm index 010ec123a9..d62aa6ee85 100644 --- a/cassandane/Cassandane/Service.pm +++ b/cassandane/Cassandane/Service.pm @@ -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