Skip to content

Commit

Permalink
Refactor securefiledrop unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jan 15, 2024
1 parent 969612d commit 13d5e2b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions test/testsecurefiledrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FolderMetadata> metadata(new FolderMetadata(_account, FolderMetadata::FolderType::Root));
QSignalSpy metadataSetupCompleteSpy(metadata.data(), &FolderMetadata::setupComplete);
metadataSetupCompleteSpy.wait();
Expand Down

0 comments on commit 13d5e2b

Please sign in to comment.