Skip to content

Commit d1c6763

Browse files
authored
Configure synapse to use the test mail server (#705)
Tweak the generated synapse config so that it uses the test mail server.
1 parent 6a3d4a2 commit d1c6763

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lib/SyTest/Homeserver.pm

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ validate recaptcha submissions.
6464
6565
=back
6666
67+
=head2 smtp_server_config => HASH
68+
69+
Details of an smtp server for things like 3pid validation. Should include the
70+
following keys:
71+
72+
=over
73+
74+
=item C<host>
75+
76+
The hostname where the SMTP server can be reached.
77+
78+
=item C<port>
79+
80+
The port where the SMTP server can be reached.
81+
82+
=back
83+
6784
=head2 cas_config => HASH
6885
6986
Parameters for testing the server's CAS integration. Should include the
@@ -149,7 +166,7 @@ sub configure
149166
my %params = @_;
150167

151168
exists $params{$_} and $self->{$_} = delete $params{$_} for qw(
152-
recaptcha_config cas_config
169+
recaptcha_config cas_config smtp_server_config
153170
app_service_config_files
154171
);
155172

lib/SyTest/Homeserver/Synapse.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ sub start
142142

143143
my $listeners = [ $self->generate_listeners ];
144144
my $bind_host = $self->{bind_host};
145+
my $unsecure_port = $self->{ports}{synapse_unsecure};
145146

146147
my $macaroon_secret_key = "secret_$port";
147148
my $registration_shared_secret = "reg_secret";
@@ -161,6 +162,7 @@ sub start
161162
my $config_path = $self->{paths}{config} = $self->write_yaml_file( "config.yaml" => {
162163
server_name => $self->server_name,
163164
log_config => $log_config_file,
165+
public_baseurl => "http://${bind_host}:$unsecure_port",
164166

165167
# We configure synapse to use a TLS cert which is signed by our dummy CA...
166168
tls_certificate_path => $self->{paths}{cert_file},
@@ -255,6 +257,14 @@ sub start
255257
recaptcha_private_key => $self->{recaptcha_config}->{private_key},
256258
) : (),
257259

260+
$self->{smtp_server_config} ? (
261+
email => {
262+
smtp_host => $self->{smtp_server_config}->{host},
263+
smtp_port => $self->{smtp_server_config}->{port},
264+
notif_from => 'synapse@localhost',
265+
},
266+
) : (),
267+
258268
map {
259269
defined $self->{$_} ? ( $_ => $self->{$_} ) : ()
260270
} qw(

tests/05homeserver.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
"https://$api_host:" . $server->secure_port :
5959
"http://$api_host:" . $server->unsecure_port;
6060

61+
$server->configure(
62+
smtp_server_config => $mail_server_info,
63+
);
64+
6165
$server->configure(
6266
# Config for testing recaptcha. 90jira/SYT-8.pl
6367
recaptcha_config => {

0 commit comments

Comments
 (0)