Skip to content

Commit 2b804cc

Browse files
authored
Drop --no-tls and clean up Homeserver object API (#1014)
This was getting to be a bit of a mess, with unused/duplicate functions, and undocumented methods named the same as undocumented fields with different functions. Clean it all up.
1 parent 2180c0e commit 2b804cc

File tree

6 files changed

+24
-76
lines changed

6 files changed

+24
-76
lines changed

lib/SyTest/Homeserver.pm

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ Homeserver interface.
116116
This method should return the server_name for the server (ie, the 'domain' part
117117
of any Matrix IDs it generates).
118118
119-
=head2 http_api_host
119+
=head2 federation_host
120120
121121
This method should return the hostname where the homeserver exposes the
122-
client-server and server-server APIs.
122+
server-server API.
123123
124124
=head2 federation_port
125125
@@ -129,19 +129,12 @@ This method should return the port number where the homeserver exposes a
129129
server-server API (over HTTPS). It may return undef if there is no known
130130
federation port.
131131
132-
=head2 secure_port
132+
=head2 public_baseurl
133133
134-
$hs->secure_port
134+
$hs->public_baseurl
135135
136-
This method should return the port number where the homeserver exposes a
137-
client-server API over HTTPS.
138-
139-
=head2 unsecure_port
140-
141-
$hs->unsecure_port
142-
143-
This method should return the port number where the homeserver exposes a
144-
client-server API over HTTP.
136+
This method should returns the public base URL for the client-server API for
137+
this server.
145138
146139
=cut
147140

@@ -166,7 +159,7 @@ sub configure
166159
my %params = @_;
167160

168161
exists $params{$_} and $self->{$_} = delete $params{$_} for qw(
169-
public_baseurl recaptcha_config cas_config smtp_server_config
162+
recaptcha_config cas_config smtp_server_config
170163
app_service_config_files
171164
);
172165

lib/SyTest/Homeserver/Dendrite.pm

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ sub _check_db_config
6969
return $self->SUPER::_check_db_config( @_ );
7070
}
7171

72-
sub http_api_host
72+
sub federation_host
7373
{
7474
my $self = shift;
7575
return $self->{bind_host};
@@ -332,13 +332,9 @@ sub unsecure_port
332332

333333
sub public_baseurl
334334
{
335-
my $self = shift;
336-
# run-tests.pl defines whether TLS should be used or not.
337-
my ( $want_tls ) = @_;
338-
return $want_tls ?
339-
"https://$self->{bind_host}:" . $self->secure_port() :
340-
"http://$self->{bind_host}:" . $self->unsecure_port();
341-
}
335+
my $self = shift;
336+
return "https://$self->{bind_host}:" . $self->secure_port();
337+
}
342338

343339
sub start
344340
{

lib/SyTest/Homeserver/Manual.pm

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sub server_name
5252
return $self->{server_name};
5353
}
5454

55-
sub http_api_host
55+
sub federation_host
5656
{
5757
my $self = shift;
5858
return $self->{host};
@@ -61,33 +61,18 @@ sub http_api_host
6161
sub federation_port
6262
{
6363
my $self = shift;
64-
return $self->secure_port;
65-
}
66-
67-
sub secure_port
68-
{
69-
my $self = shift;
70-
7164
return $self->{secure_port};
7265
}
7366

74-
sub unsecure_port
67+
sub public_baseurl
7568
{
7669
my $self = shift;
7770

78-
return $self->{unsecure_port};
71+
return defined $self->{secure_port} ?
72+
"https://$self->{host}:" . $self->{secure_port} :
73+
"http://$self->{host}:" . $self->{unsecure_port};
7974
}
8075

81-
sub public_baseurl
82-
{
83-
my $self = shift;
84-
# run-tests.pl defines whether TLS should be used or not.
85-
my ( $want_tls ) = @_;
86-
return $want_tls ?
87-
"https://$self->{bind_host}:" . $self->secure_port() :
88-
"http://$self->{bind_host}:" . $self->unsecure_port();
89-
}
90-
9176
sub start
9277
{
9378
my $self = shift;

lib/SyTest/Homeserver/Synapse.pm

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ sub start
171171
my $config_path = $self->{paths}{config} = $self->write_yaml_file( "config.yaml" => {
172172
server_name => $self->server_name,
173173
log_config => $log_config_file,
174-
public_baseurl => $self->{public_baseurl},
174+
public_baseurl => $self->public_baseurl,
175175

176176
# We configure synapse to use a TLS cert which is signed by our dummy CA...
177177
tls_certificate_path => $self->{paths}{cert_file},
@@ -569,7 +569,7 @@ sub server_name
569569
return $self->{bind_host} . ":" . $self->secure_port;
570570
}
571571

572-
sub http_api_host
572+
sub federation_host
573573
{
574574
my $self = shift;
575575
return $self->{bind_host};
@@ -587,20 +587,10 @@ sub secure_port
587587
return $self->{ports}{synapse};
588588
}
589589

590-
sub unsecure_port
591-
{
592-
my $self = shift;
593-
return $self->{ports}{synapse_unsecure};
594-
}
595-
596590
sub public_baseurl
597591
{
598592
my $self = shift;
599-
# run-tests.pl defines whether TLS should be used or not.
600-
my ( $want_tls ) = @_;
601-
return $want_tls ?
602-
"https://$self->{bind_host}:" . $self->secure_port() :
603-
"http://$self->{bind_host}:" . $self->unsecure_port();
593+
return "https://$self->{bind_host}:" . $self->secure_port;
604594
}
605595

606596
package SyTest::Homeserver::Synapse::Direct;
@@ -1111,12 +1101,6 @@ sub secure_port
11111101
return $self->{ports}{haproxy};
11121102
}
11131103

1114-
sub unsecure_port
1115-
{
1116-
my $self = shift;
1117-
die "haproxy does not have an unsecure port mode\n";
1118-
}
1119-
11201104
sub public_baseurl
11211105
{
11221106
my $self = shift;

run-tests.pl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353

5454
binmode(STDOUT, ":utf8");
5555

56-
our $WANT_TLS = 1; # This is shared with the test scripts
57-
5856
our $BIND_HOST = "localhost";
5957

6058
# a unique ID for this test run. It is used in some tests to create user IDs
@@ -101,8 +99,6 @@
10199

102100
'v|verbose+' => \(my $VERBOSE = 0),
103101

104-
'n|no-tls' => sub { $WANT_TLS = 0 },
105-
106102
'work-directory=s' => \$WORK_DIR,
107103

108104
'room-version=s' => \$TEST_ROOM_VERSION,

tests/05homeserver.pl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,11 @@
5151

5252
$loop->add( $server );
5353

54-
my $api_host = $server->http_api_host;
55-
56-
my $location = $server->public_baseurl($WANT_TLS);
57-
5854
$server->configure(
5955
smtp_server_config => $mail_server_info,
6056
);
6157

6258
$server->configure(
63-
# Annoyingly we ask the homeserver object for public_baseurl and then
64-
# pass it back into the configuration since this is the only location
65-
# we have $WANT_TLS.
66-
public_baseurl => $location,
6759
# Config for testing recaptcha. 90jira/SYT-8.pl
6860
recaptcha_config => {
6961
siteverify_api => $test_server_info->client_location .
@@ -75,8 +67,10 @@
7567
},
7668
);
7769

78-
my $info = ServerInfo( $server->server_name, $location,
79-
$api_host, $server->federation_port );
70+
my $info = ServerInfo(
71+
$server->server_name, $server->public_baseurl,
72+
$server->federation_host, $server->federation_port,
73+
);
8074

8175
if( $idx == 0 ) {
8276
# Configure application services on first instance only
@@ -129,7 +123,7 @@
129123
return Future->done( $info );
130124
})->on_fail( sub {
131125
my ( $exn, @details ) = @_;
132-
warn( "Error starting server-$idx (on port ${\$server->secure_port}): $exn" );
126+
warn( "Error starting server-$idx: $exn" );
133127

134128
# if we can't start the first homeserver, we really might as well go home.
135129
if( $idx == 0 ) {

0 commit comments

Comments
 (0)