aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
Diffstat (limited to 'autotests')
-rw-r--r--autotests/adjust-config.sh55
-rwxr-xr-xautotests/run-tests.sh30
-rw-r--r--autotests/testolmaccount.cpp36
3 files changed, 82 insertions, 39 deletions
diff --git a/autotests/adjust-config.sh b/autotests/adjust-config.sh
new file mode 100644
index 00000000..a55ac670
--- /dev/null
+++ b/autotests/adjust-config.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+CMD=""
+
+$CMD perl -pi -w -e \
+ 's/rc_messages_per_second.*/rc_messages_per_second: 1000/g;' homeserver.yaml
+$CMD perl -pi -w -e \
+ 's/rc_message_burst_count.*/rc_message_burst_count: 10000/g;' homeserver.yaml
+
+(
+cat <<HEREDOC
+rc_message:
+ per_second: 10000
+ burst_count: 100000
+rc_registration:
+ per_second: 10000
+ burst_count: 30000
+rc_login:
+ address:
+ per_second: 10000
+ burst_count: 30000
+ account:
+ per_second: 10000
+ burst_count: 30000
+ failed_attempts:
+ per_second: 10000
+ burst_count: 30000
+rc_admin_redaction:
+ per_second: 1000
+ burst_count: 5000
+rc_joins:
+ local:
+ per_second: 10000
+ burst_count: 100000
+ remote:
+ per_second: 10000
+ burst_count: 100000
+HEREDOC
+) | $CMD tee -a data/homeserver.yaml
+
+$CMD perl -pi -w -e \
+ 's/^#enable_registration: false/enable_registration: true/g;' homeserver.yaml
+$CMD perl -pi -w -e \
+ 's/^#enable_registration_without_verification: .+/enable_registration_without_verification: true/g;' homeserver.yaml
+$CMD perl -pi -w -e \
+ 's/tls: false/tls: true/g;' homeserver.yaml
+$CMD perl -pi -w -e \
+ 's/#tls_certificate_path:/tls_certificate_path:/g;' homeserver.yaml
+$CMD perl -pi -w -e \
+ 's/#tls_private_key_path:/tls_private_key_path:/g;' homeserver.yaml
+
+$CMD openssl req -x509 -newkey rsa:4096 -keyout localhost.tls.key -out localhost.tls.crt -days 365 -subj '/CN=localhost' -nodes
+
+$CMD chmod 0777 localhost.tls.crt
+$CMD chmod 0777 localhost.tls.key
diff --git a/autotests/run-tests.sh b/autotests/run-tests.sh
index 0d58e460..a3ee2ade 100755
--- a/autotests/run-tests.sh
+++ b/autotests/run-tests.sh
@@ -1,34 +1,32 @@
mkdir -p data
chmod 0777 data
+
rm ~/.local/share/testolmaccount -rf
docker run -v `pwd`/data:/data --rm \
- -e SYNAPSE_SERVER_NAME=localhost -e SYNAPSE_REPORT_STATS=no matrixdotorg/synapse:v1.24.0 generate
-./.ci/adjust-config.sh
+ -e SYNAPSE_SERVER_NAME=localhost -e SYNAPSE_REPORT_STATS=no matrixdotorg/synapse:latest generate
+pushd data
+. ../autotests/adjust-config.sh
+popd
docker run -d \
--name synapse \
-p 1234:8008 \
-p 8448:8008 \
-p 8008:8008 \
- -v `pwd`/data:/data matrixdotorg/synapse:v1.24.0
+ -v `pwd`/data:/data matrixdotorg/synapse:latest
trap "rm -rf ./data/*; docker rm -f synapse 2>&1 >/dev/null; trap - EXIT" EXIT
echo Waiting for synapse to start...
until curl -s -f -k https://localhost:1234/_matrix/client/versions; do echo "Checking ..."; sleep 2; done
echo Register alice
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice1 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice2 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice3 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice4 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice5 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice6 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice7 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice8 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u alice9 -p secret -c /data/homeserver.yaml https://localhost:8008'
+for i in 1 2 3 4 5 6 7 8 9; do
+ docker exec synapse /bin/sh -c "register_new_matrix_user --admin -u alice$i -p secret -c /data/homeserver.yaml https://localhost:8008"
+done
echo Register bob
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob1 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob2 -p secret -c /data/homeserver.yaml https://localhost:8008'
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u bob3 -p secret -c /data/homeserver.yaml https://localhost:8008'
+for i in 1 2 3; do
+ docker exec synapse /bin/sh -c "register_new_matrix_user --admin -u bob$i -p secret -c /data/homeserver.yaml https://localhost:8008"
+done
echo Register carl
-docker exec synapse /bin/sh -c 'register_new_matrix_user --admin -u carl -p secret -c /data/homeserver.yaml https://localhost:8008'
+docker exec synapse /bin/sh -c "register_new_matrix_user --admin -u carl -p secret -c /data/homeserver.yaml https://localhost:8008"
GTEST_COLOR=1 ctest --verbose "$@"
+
diff --git a/autotests/testolmaccount.cpp b/autotests/testolmaccount.cpp
index 3fb8ac24..505bdc5f 100644
--- a/autotests/testolmaccount.cpp
+++ b/autotests/testolmaccount.cpp
@@ -200,10 +200,13 @@ void TestOlmAccount::uploadIdentityKey()
OneTimeKeys unused;
auto request = olmAccount->createUploadKeyRequest(unused);
connect(request, &BaseJob::result, this, [request, conn] {
- QCOMPARE(request->oneTimeKeyCounts().size(), 0);
- });
- connect(request, &BaseJob::failure, this, [] {
- QFAIL("upload failed");
+ if (!request->status().good())
+ QFAIL("upload failed");
+ const auto& oneTimeKeyCounts = request->oneTimeKeyCounts();
+ // Allow the response to have entries with zero counts
+ QCOMPARE(std::accumulate(oneTimeKeyCounts.begin(),
+ oneTimeKeyCounts.end(), 0),
+ 0);
});
conn->run(request);
QSignalSpy spy3(request, &BaseJob::result);
@@ -227,12 +230,10 @@ void TestOlmAccount::uploadOneTimeKeys()
}
auto request = new UploadKeysJob(none, oneTimeKeysHash);
connect(request, &BaseJob::result, this, [request, conn] {
- QCOMPARE(request->oneTimeKeyCounts().size(), 1);
+ if (!request->status().good())
+ QFAIL("upload failed");
QCOMPARE(request->oneTimeKeyCounts().value(Curve25519Key), 5);
});
- connect(request, &BaseJob::failure, this, [] {
- QFAIL("upload failed");
- });
conn->run(request);
QSignalSpy spy3(request, &BaseJob::result);
QVERIFY(spy3.wait(10000));
@@ -255,12 +256,10 @@ void TestOlmAccount::uploadSignedOneTimeKeys()
}
auto request = new UploadKeysJob(none, oneTimeKeysHash);
connect(request, &BaseJob::result, this, [request, nKeys, conn] {
- QCOMPARE(request->oneTimeKeyCounts().size(), 1);
+ if (!request->status().good())
+ QFAIL("upload failed");
QCOMPARE(request->oneTimeKeyCounts().value(SignedCurve25519Key), nKeys);
});
- connect(request, &BaseJob::failure, this, [] {
- QFAIL("upload failed");
- });
conn->run(request);
QSignalSpy spy3(request, &BaseJob::result);
QVERIFY(spy3.wait(10000));
@@ -275,12 +274,10 @@ void TestOlmAccount::uploadKeys()
auto otks = olmAccount->oneTimeKeys();
auto request = olmAccount->createUploadKeyRequest(otks);
connect(request, &BaseJob::result, this, [request, conn] {
- QCOMPARE(request->oneTimeKeyCounts().size(), 1);
+ if (!request->status().good())
+ QFAIL("upload failed");
QCOMPARE(request->oneTimeKeyCounts().value(SignedCurve25519Key), 1);
});
- connect(request, &BaseJob::failure, this, [] {
- QFAIL("upload failed");
- });
conn->run(request);
QSignalSpy spy3(request, &BaseJob::result);
QVERIFY(spy3.wait(10000));
@@ -296,7 +293,6 @@ void TestOlmAccount::queryTest()
aliceOlm->generateOneTimeKeys(1);
auto aliceRes = aliceOlm->createUploadKeyRequest(aliceOlm->oneTimeKeys());
connect(aliceRes, &BaseJob::result, this, [aliceRes] {
- QCOMPARE(aliceRes->oneTimeKeyCounts().size(), 1);
QCOMPARE(aliceRes->oneTimeKeyCounts().value(SignedCurve25519Key), 1);
});
QSignalSpy spy(aliceRes, &BaseJob::result);
@@ -307,7 +303,6 @@ void TestOlmAccount::queryTest()
bobOlm->generateOneTimeKeys(1);
auto bobRes = bobOlm->createUploadKeyRequest(aliceOlm->oneTimeKeys());
connect(bobRes, &BaseJob::result, this, [bobRes] {
- QCOMPARE(bobRes->oneTimeKeyCounts().size(), 1);
QCOMPARE(bobRes->oneTimeKeyCounts().value(SignedCurve25519Key), 1);
});
QSignalSpy spy1(bobRes, &BaseJob::result);
@@ -367,7 +362,6 @@ void TestOlmAccount::claimKeys()
auto request = bobOlm->createUploadKeyRequest(bobOlm->oneTimeKeys());
connect(request, &BaseJob::result, this, [request, bob] {
- QCOMPARE(request->oneTimeKeyCounts().size(), 1);
QCOMPARE(request->oneTimeKeyCounts().value(SignedCurve25519Key), 1);
});
bob->run(request);
@@ -433,7 +427,6 @@ void TestOlmAccount::claimMultipleKeys()
auto res = olm->createUploadKeyRequest(olm->oneTimeKeys());
QSignalSpy spy(res, &BaseJob::result);
connect(res, &BaseJob::result, this, [res] {
- QCOMPARE(res->oneTimeKeyCounts().size(), 1);
QCOMPARE(res->oneTimeKeyCounts().value(SignedCurve25519Key), 10);
});
alice->run(res);
@@ -444,7 +437,6 @@ void TestOlmAccount::claimMultipleKeys()
auto res1 = olm1->createUploadKeyRequest(olm1->oneTimeKeys());
QSignalSpy spy1(res1, &BaseJob::result);
connect(res1, &BaseJob::result, this, [res1] {
- QCOMPARE(res1->oneTimeKeyCounts().size(), 1);
QCOMPARE(res1->oneTimeKeyCounts().value(SignedCurve25519Key), 10);
});
alice1->run(res1);
@@ -455,7 +447,6 @@ void TestOlmAccount::claimMultipleKeys()
auto res2 = olm2->createUploadKeyRequest(olm2->oneTimeKeys());
QSignalSpy spy2(res2, &BaseJob::result);
connect(res2, &BaseJob::result, this, [res2] {
- QCOMPARE(res2->oneTimeKeyCounts().size(), 1);
QCOMPARE(res2->oneTimeKeyCounts().value(SignedCurve25519Key), 10);
});
alice2->run(res2);
@@ -479,7 +470,6 @@ void TestOlmAccount::claimMultipleKeys()
QVERIFY(jobSpy.wait(10000));
const auto userId = alice->userId();
- QCOMPARE(job->oneTimeKeys().size(), 1);
QCOMPARE(job->oneTimeKeys().value(userId).size(), 3);
}