Skip to content

Commit 6c69f3e

Browse files
authored
Fix end-to-end tests for recent Synapse features (matrix-org#8159)
* Ensure a useful logfile gets recorded for synapse startup failures * Update synapse config to stop complaining about key servers * Add flag to turn on registrations again From matrix-org/synapse#12091
1 parent 61231ee commit 6c69f3e

File tree

4 files changed

+79
-13
lines changed

4 files changed

+79
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
const path = require('path');
18+
19+
// used from run.sh as getopts doesn't support long parameters
20+
const idx = process.argv.indexOf("--log-directory");
21+
if (idx !== -1) {
22+
const value = process.argv[idx + 1];
23+
process.stdout.write(path.join(path.resolve(value), 'homeserver.log'));
24+
} else {
25+
process.stdout.write(path.join(process.cwd(), 'homeserver.log'));
26+
}

test/end-to-end-tests/run.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ echo "Please first run $BASE_DIR/install.sh"
1010
fi
1111

1212
has_custom_app=$(node has-custom-app.js $@)
13+
synapse_log_file=$(node pick-synapse-log-file.js $@)
14+
touch $synapse_log_file
1315

1416
if [ ! -d "element/element-web" ] && [ $has_custom_app -ne "1" ]; then
1517
echo "Please provide an instance of Element to test against by passing --app-url <url> or running $BASE_DIR/element/install.sh"
@@ -25,13 +27,14 @@ stop_servers() {
2527

2628
handle_error() {
2729
EXIT_CODE=$?
30+
echo "Tests fell over with a non-zero exit code: stopping servers"
2831
stop_servers
2932
exit $EXIT_CODE
3033
}
3134

3235
trap 'handle_error' ERR
3336

34-
./synapse/start.sh
37+
LOGFILE=$synapse_log_file ./synapse/start.sh
3538
reg_secret=`./synapse/getcfg.sh registration_shared_secret`
3639
if [ $has_custom_app -ne "1" ]; then
3740
./element/start.sh

test/end-to-end-tests/synapse/config-templates/consent/homeserver.yaml

+49-6
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ uploads_path: "{{SYNAPSE_ROOT}}uploads"
633633
#
634634
enable_registration: true
635635

636+
# Enable registration without email or captcha verification. Note: this option is *not* recommended,
637+
# as registration without verification is a known vector for spam and abuse. Defaults to false. Has no effect
638+
# unless `enable_registration` is also enabled.
639+
#
640+
enable_registration_without_verification: true
641+
636642
# The user must provide all of the below types of 3PID when registering.
637643
#
638644
#registrations_require_3pid:
@@ -792,13 +798,50 @@ signing_key_path: "{{SYNAPSE_ROOT}}localhost.signing.key"
792798

793799
# The trusted servers to download signing keys from.
794800
#
795-
#perspectives:
796-
# servers:
797-
# "matrix.org":
798-
# verify_keys:
799-
# "ed25519:auto":
800-
# key: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw"
801+
# When we need to fetch a signing key, each server is tried in parallel.
802+
#
803+
# Normally, the connection to the key server is validated via TLS certificates.
804+
# Additional security can be provided by configuring a `verify key`, which
805+
# will make synapse check that the response is signed by that key.
806+
#
807+
# This setting supercedes an older setting named `perspectives`. The old format
808+
# is still supported for backwards-compatibility, but it is deprecated.
809+
#
810+
# 'trusted_key_servers' defaults to matrix.org, but using it will generate a
811+
# warning on start-up. To suppress this warning, set
812+
# 'suppress_key_server_warning' to true.
813+
#
814+
# Options for each entry in the list include:
815+
#
816+
# server_name: the name of the server. required.
817+
#
818+
# verify_keys: an optional map from key id to base64-encoded public key.
819+
# If specified, we will check that the response is signed by at least
820+
# one of the given keys.
821+
#
822+
# accept_keys_insecurely: a boolean. Normally, if `verify_keys` is unset,
823+
# and federation_verify_certificates is not `true`, synapse will refuse
824+
# to start, because this would allow anyone who can spoof DNS responses
825+
# to masquerade as the trusted key server. If you know what you are doing
826+
# and are sure that your network environment provides a secure connection
827+
# to the key server, you can set this to `true` to override this
828+
# behaviour.
829+
#
830+
# An example configuration might look like:
831+
#
832+
#trusted_key_servers:
833+
# - server_name: "my_trusted_server.example.com"
834+
# verify_keys:
835+
# "ed25519:auto": "abcdefghijklmnopqrstuvwxyzabcdefghijklmopqr"
836+
# - server_name: "my_other_trusted_server.example.com"
837+
#
838+
trusted_key_servers:
839+
- server_name: "matrix.org"
801840

841+
# Uncomment the following to disable the warning that is emitted when the
842+
# trusted_key_servers include 'matrix.org'. See above.
843+
#
844+
suppress_key_server_warning: true
802845

803846
# Enable SAML2 for registration and login. Uses pysaml2.
804847
#

test/end-to-end-tests/synapse/start.sh

-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@ BASE_DIR=$(cd $(dirname $0) && pwd)
55
cd $BASE_DIR
66
cd installations/consent/env/bin/
77
source activate
8-
LOGFILE=$(mktemp)
98
echo "Synapse log file at $LOGFILE"
109
./synctl start 2> $LOGFILE
11-
EXIT_CODE=$?
12-
if [ $EXIT_CODE -ne 0 ]; then
13-
cat $LOGFILE
14-
fi
15-
exit $EXIT_CODE

0 commit comments

Comments
 (0)