aboutsummaryrefslogtreecommitdiff
path: root/autotests
AgeCommit message (Collapse)Author
2022-09-26Wrap error reporting into facility macrosAlexey Rusakov
Facility macros to report Olm errors: QOLM_INTERNAL_ERROR[_X], QOLM_FAIL_OR_LOG[_X]
2022-09-26Cleanup across E2EE codeAlexey Rusakov
Notably: - simplified unnecessarily verbose constructs; - formally aligned (no re-numeration was necessary) QOlmMessage::Type with corresponding OLM_ constants; - dropped QOlmSession::encryptMessageType() because it's very sensitive to the order of calling with QOlmSession::encrypt() (and encrypt() itself already calls it and returns the message type); - simplify the return type of pickle() calls that can only fail due to an internal error; - replace const QString& with QStringView or const QByteArray& where appropriate; - use '\0' where it was meant to be instead of '0'.
2022-09-26Replace QOlmError with OlmErrorCodeAlexey Rusakov
QOlmError represents a subset of OlmErrorCode, and the associated fromString() function uses undocumented strings produced inside Olm; meanwhile OlmErrorCode is documented in its own header file. Each QOlm* class now has lastErrorCode() next to lastError() (that, from now, returns a textual representation straight from Olm, not QOlmError enum). Also: including olm/error.h in e2ee/e2ee.h required some rearrangement of the code to make sure non-E2EE configuration still builds.
2022-09-11TestKeyVerification: Add a missing allowed stateAlexey Rusakov
2022-09-11KeyVerificationEvent; KeyVerificationSession::handleEvent()Alexey Rusakov
Key verification events gain their own base type and KeyVerificationSession gets a single point of entry for all kinds of incoming events. This allows to drop a pile of `incoming*` signals in Connection and a stack of options inside switchOnType in processIfVerification(). KVS::handleEvent() also makes (some) allowed state transitions a bit clearer.
2022-09-10Remove header for keyverificationtestTobias Fella
2022-09-06Add autotest for key verification and fix several edge-casesTobias Fella
2022-09-04Disallow direct events construction from JSONAlexey Rusakov
Direct construction (using makeEvent() or explicitly constructing an event) from JSON may create an event that has a type conflicting with that stored in JSON. There's no such problem with loadEvent(), even though it's considerably slower. Driven by the fact that almost nowhere in the code direct construction is used on checked JSON (one test is the only valid case), this commit moves all JSON-loading constructors to the protected section, thereby disabling usage of makeEvent() in JSON-loading capacity, and switches such cases across the library to loadEvent().
2022-09-04CallEventBase -> CallEvent; pack up all call eventsAlexey Rusakov
These are small enough to comfortably reside in a single translation unit.
2022-07-08Adjust Synapse image for testsAlexey Rusakov
:latest stopped working for some reason.
2022-06-01Fix FTBFS after the mergeAlexey Rusakov
2022-05-31Merge branch 'dev' into update-api-updateAlexey Rusakov
2022-05-31Tweak QOlmAccount and data structures aroundAlexey Rusakov
This is mainly to plug the definition of a string-to-variant map for one-time keys (see https://spec.matrix.org/v1.2/client-server-api/#key-algorithms) into the CS API generated code (see the "shortcut OneTimeKeys" commit for gtad.yaml); but along with it came considerable streamlining of code in qolmaccount.cpp. Using std::variant to store that map also warranted converters.h to gain support for that type (even wider than toJson() that is already in dev - a non-trivial merge from dev is in order).
2022-05-30run-tests.sh: fix weird CI failure on Linux/ClangAlexey Rusakov
Also fix a leftover data/ prefix in adjust-config.sh
2022-05-29Merge #557: Refresh and organise run-tests.sh/adjust-config.shAlexey Rusakov
2022-05-29TestOlmAccount: fix testsAlexey Rusakov
Mainly the change is about eliminating the checks for an exact number of key-value pairs inside `one_time_key_counts` - these checks started failing with new Synapse throwing `signed_curve25519: 0` into this dict.
2022-05-29Refresh and organise run-tests.sh/adjust-config.shAlexey Rusakov
run-tests.sh now uses the latest version of Synapse and has less repetitive code; adjust-config.sh moved to autotests/ (it had nothing specific to CI, after all), works with the newest Synapse (that has an additional enable_registration_without_verification safeguard) and no more depends on the config directory being called "data" but rather should be called from inside that directory (for the case when it is used separately from run-tests.sh and the config directory is not called "data").
2022-05-29Move some Meg/Olm session logic from Room::Private to Connection::PrivateAlexey Rusakov
Functions (Room::Private::)createOlmSession, payloadForUserDevice and sendRoomKeyToDevices don't have a lot to do with the given Room object but deal with quite a few things stored in Connection. This commit moves them to Connection::Private, exposing sendSessionKeyToDevices (the new name for sendRoomKeyToDevices) in Connection so that Room could call it from Room::P::sendMegolmSession(). While moving these over, a few additional things were adjusted: - more functions marked as const - a few functions could be moved now from Connection to Connection::Private - false slots in Connection (such as picklingMode) are moved out of the slots block - keys.yml in Matrix CS API definitions has been adjusted to match the real structure of `/claim` response (see quotient-im/matrix-spec repo); csapi/keys.h has been regenerated accordingly.
2022-05-29Move encryptFile/decryptFile out of EncryptedFileMetadataAlexey Rusakov
These are not operations on EncryptedFileMetadata but rather on a combination of EncryptedFileMetadata and ciphertext. If C++ had multimethods these could be bound to such a combination.
2022-05-29Refactor EncryptedFile and EC::FileInfo::fileAlexey Rusakov
Besides having a misleading name (and it goes back to the spec), EncryptedFile under `file` key preempts the `url` (or `thumbnail_url`) string value so only one of the two should exist. This is a case for using std::variant<> - despite its clumsy syntax, it can actually simplify and streamline code when all the necessary bits are in place (such as conversion to JSON and getting the common piece - the URL - out of it). This commit replaces `FileInfo::url` and `FileInfo::file` with a common field `source` of type `FileSourceInfo` that is an alias for a variant type covering both underlying types; and `url()` is reintroduced as a function instead, to allow simplified access to whichever URL is available inside the variant. Oh, and EncryptedFile is EncryptedFileMetadata now, to clarify that it does not represent the file payload itself but rather the data necessary to obtain that payload.
2022-05-20Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-05-20Truncate ciphertext buffer to actual size during file encryptionTobias Fella
The ciphertext for AES CTR is exactly as large as the plaintext (not necessarily a multiple of the blocksize!). By truncating the ciphertext, we do not send bytes that will be decrypted to gibberish. As a side node, we probably do not need to initialize the ciphertext buffer larger than the plaintext size at all, but the OpenSSL docs are a bit vague about that.
2022-05-16Implement sending encrypted filesTobias Fella
2022-05-16Update autotests/testolmutility.cppAlexey Rusakov
Co-authored-by: Tobias Fella <9750016+TobiasFella@users.noreply.github.com>
2022-05-16QOlmExpected and associated refactoringAlexey Rusakov
As mentioned in the commit introducing `Expected`, `QOlmExpected` is simply an alias for `Expected<T, QOlmError>`. This simplifies quite a few function signatures in `QOlm*` classes and collapses unwieldy `std::holds_alternative<>`/`std::get<>` constructs into a neat contextual bool cast and an invocation of `operator*` or `value()`/`error()` accessors that don't need to specify the type. While refactoring the code, I found a couple of cases of mismatching `uint32_t` and `qint32_t` in return values; a couple of cases where `decrypt()` returns `QString` which is in fact `QByteArray` (e.g., in `QOlmSession::decrypt()`); there's a repetitive algorithm in `Connection::Private::sessionDecryptPrekey()` and `sessionDecryptGeneral()`
2022-05-16Simplify QOlmSession::matchesInboundSession*()Alexey Rusakov
There's no particular use in letting `QOlmError` out, only to confirm that, well, `QOlmError` is just another form of no-match.
2022-05-16Optimise #includes for QOlm* classesAlexey Rusakov
2022-02-24Fix all testsTobias Fella
2022-02-24Fix testTobias Fella
2022-02-23Fix tests a bitTobias Fella
2022-02-18TestOlmAccount::claimKeys(): auth bob as bob, not as aliceAlexey Rusakov
2022-02-18testolmaccount.cpp: cleanupAlexey Rusakov
2022-02-18TestOlmAccount: align homeserver address with that in run-tests.shAlexey Rusakov
It would probably be even better to pass the homeserver address in the environment but that's a bigger endeavour. Also: reformatted CREATE_CONNECTION macro.
2022-02-18testgroupsession.*: fix TestOlmSession copy-pastaAlexey Rusakov
2022-02-18run-tests.sh: use a trap for cleanupAlexey Rusakov
This both is more reliable (GHA executes scripts in fail-fast mode) and ensures that the return value is that of ctest.
2022-02-18Use QCoreApplication in autotestsAlexey Rusakov
QEventLoop refuses to work without an application object instance.
2022-02-18CI: setup mock Synapse before running ctestAlexey Rusakov
To use this in CI required extending/fixing autotests/run-tests.sh: it can now accept arguments that are further passed to ctest invocation, and it no more cd's to the build directory because build directories can be in all kinds of places, expecting the caller to pick the directory upfront.
2022-02-17Don't create QApplications in testsTobias Fella
2022-02-16TestOlmUtility: fix building with Qt 5.12Alexey Rusakov
QKeyValueIterator::operator->() only arrived in Qt 5.15.
2022-02-13Merge branch 'dev'Alexey Rusakov
The result is FTBFS as yet; next commits will fix that, along with a few other things.
2022-02-07Remove encryptionmanager and various fixesTobias Fella
2022-01-30Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-01-29Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
2022-01-23Move away Omittable static tests to autotests/Alexey Rusakov
These are not required to build libQuotient, and omittable.cpp entirely consisted of them.
2021-12-25Move run-tests.shTobias Fella
2021-12-24Apply suggestionsTobias Fella
2021-12-10Fix compilation of tests against older qtTobias Fella
2021-12-07Rename "crypto" -> "e2ee"Tobias Fella
2021-12-06autotests/: don't instantiate QApplicationAlexey Rusakov
Those tests don't even need an event loop.
2021-12-01Apply suggestions from code reviewTobias Fella
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>