Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a consistent public baseurl. #1011

Merged
merged 5 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SyTest/Homeserver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sub configure
my %params = @_;

exists $params{$_} and $self->{$_} = delete $params{$_} for qw(
recaptcha_config cas_config smtp_server_config
public_baseurl recaptcha_config cas_config smtp_server_config
app_service_config_files
);

Expand Down
19 changes: 17 additions & 2 deletions lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ sub start

my $listeners = [ $self->generate_listeners ];
my $bind_host = $self->{bind_host};
my $unsecure_port = $self->{ports}{synapse_unsecure};

my $macaroon_secret_key = "secret_$port";
my $registration_shared_secret = "reg_secret";
Expand All @@ -172,7 +171,7 @@ sub start
my $config_path = $self->{paths}{config} = $self->write_yaml_file( "config.yaml" => {
server_name => $self->server_name,
log_config => $log_config_file,
public_baseurl => "http://${bind_host}:$unsecure_port",
public_baseurl => $self->{public_baseurl},

# We configure synapse to use a TLS cert which is signed by our dummy CA...
tls_certificate_path => $self->{paths}{cert_file},
Expand Down Expand Up @@ -594,6 +593,16 @@ sub unsecure_port
return $self->{ports}{synapse_unsecure};
}

sub public_baseurl
{
my $self = shift;
# run-tests.pl defines whether TLS should be used or not.
my ( $want_tls ) = @_;
return $want_tls ?
"https://$self->{bind_host}:" . $self->secure_port() :
"http://$self->{bind_host}:" . $self->unsecure_port();
}

package SyTest::Homeserver::Synapse::Direct;
use base qw( SyTest::Homeserver::Synapse );

Expand Down Expand Up @@ -1108,6 +1117,12 @@ sub unsecure_port
die "haproxy does not have an unsecure port mode\n";
}

sub public_baseurl
{
my $self = shift;
return "https://$self->{bind_host}:" . $self->secure_port();
}

sub start
{
my $self = shift;
Expand Down
9 changes: 5 additions & 4 deletions tests/05homeserver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@

my $api_host = $server->http_api_host;

my $location = $WANT_TLS ?
"https://$api_host:" . $server->secure_port :
"http://$api_host:" . $server->unsecure_port;
my $location = $server->public_baseurl($WANT_TLS);

$server->configure(
smtp_server_config => $mail_server_info,
);

$server->configure(
# Annoyingly we ask the homeserver object for public_baseurl and then
# pass it back into the configuration since this is the only location
# we have $WANT_TLS.
public_baseurl => $location,
# Config for testing recaptcha. 90jira/SYT-8.pl
recaptcha_config => {
siteverify_api => $test_server_info->client_location .
Expand All @@ -70,7 +72,6 @@
private_key => "sytest_recaptcha_private_key",
}, cas_config => {
server_url => $test_server_info->client_location . "/cas",
service_url => $location,
},
);

Expand Down