diff --git a/test/testsecurefiledrop.cpp b/test/testsecurefiledrop.cpp index 69f4a13d13b87..45d2c75e40f71 100644 --- a/test/testsecurefiledrop.cpp +++ b/test/testsecurefiledrop.cpp @@ -42,37 +42,43 @@ private slots: capabilities[QStringLiteral("end-to-end-encryption")] = QVariantMap{{QStringLiteral("enabled"), true}, {QStringLiteral("api-version"), "2.0"}}; _account = Account::create(); - QUrl url("http://example.de"); + const QUrl url("http://example.de"); _fakeQnam.reset(new FakeQNAM({})); - auto *cred = new FakeCredentials{_fakeQnam.data()}; + const auto cred = new FakeCredentials{_fakeQnam.data()}; cred->setUserName("test"); _account->setCredentials(cred); _account->setUrl(url); _account->setCapabilities(capabilities); + QSslCertificate cert; + QSslKey publicKey; + QByteArray privateKey; + { QFile e2eTestFakeCert(QStringLiteral("e2etestsfakecert.pem")); - if (e2eTestFakeCert.open(QFile::ReadOnly)) { - _account->e2e()->_certificate = QSslCertificate(e2eTestFakeCert.readAll()); - e2eTestFakeCert.close(); - } + QVERIFY(e2eTestFakeCert.open(QFile::ReadOnly)); + cert = QSslCertificate(e2eTestFakeCert.readAll()); } { QFile e2etestsfakecertpublickey(QStringLiteral("e2etestsfakecertpublickey.pem")); - if (e2etestsfakecertpublickey.open(QFile::ReadOnly)) { - _account->e2e()->_publicKey = - QSslKey(e2etestsfakecertpublickey.readAll(), QSsl::KeyAlgorithm::Rsa, QSsl::EncodingFormat::Pem, QSsl::KeyType::PublicKey); - e2etestsfakecertpublickey.close(); - } + QVERIFY(e2etestsfakecertpublickey.open(QFile::ReadOnly)); + publicKey = QSslKey(e2etestsfakecertpublickey.readAll(), QSsl::KeyAlgorithm::Rsa, QSsl::EncodingFormat::Pem, QSsl::KeyType::PublicKey); + e2etestsfakecertpublickey.close(); } { QFile e2etestsfakecertprivatekey(QStringLiteral("e2etestsfakecertprivatekey.pem")); - if (e2etestsfakecertprivatekey.open(QFile::ReadOnly)) { - _account->e2e()->_privateKey = e2etestsfakecertprivatekey.readAll(); - e2etestsfakecertprivatekey.close(); - } + QVERIFY(e2etestsfakecertprivatekey.open(QFile::ReadOnly)); + privateKey = e2etestsfakecertprivatekey.readAll(); } + QVERIFY(cert.isValid()); + QVERIFY(!publicKey.isNull()); + QVERIFY(!privateKey.isEmpty()); + + _account->e2e()->_certificate = cert; + _account->e2e()->_publicKey = publicKey; + _account->e2e()->_privateKey = privateKey; + QScopedPointer metadata(new FolderMetadata(_account, FolderMetadata::FolderType::Root)); QSignalSpy metadataSetupCompleteSpy(metadata.data(), &FolderMetadata::setupComplete); metadataSetupCompleteSpy.wait();