WIPx2
This commit is contained in:
parent
16f9af908a
commit
82bc73dd9b
15 changed files with 51 additions and 95 deletions
|
@ -184,7 +184,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
} else if(parser.isSet("encryption-info")) {
|
} else if(parser.isSet("encryption-info")) {
|
||||||
DeviceDbusInterface dev(device);
|
DeviceDbusInterface dev(device);
|
||||||
QDBusPendingReply<QByteArray> devReply = dev.encryptionInfo(); // QSsl::Der = 1
|
QDBusPendingReply<QString> devReply = dev.encryptionInfo(); // QSsl::Der = 1
|
||||||
devReply.waitForFinished();
|
devReply.waitForFinished();
|
||||||
QTextStream(stderr) << devReply.value() << endl;
|
QTextStream(stderr) << devReply.value() << endl;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
|
|
||||||
virtual PairingHandler* createPairingHandler(Device* device) = 0;
|
virtual PairingHandler* createPairingHandler(Device* device) = 0;
|
||||||
virtual bool sendPackage(NetworkPackage& np) = 0;
|
virtual bool sendPackage(NetworkPackage& np) = 0;
|
||||||
virtual bool sendPackageEncrypted(QCA::PublicKey& publicKey, NetworkPackage& np) = 0;
|
virtual bool sendPackageEncrypted(NetworkPackage& np) = 0;
|
||||||
|
|
||||||
ConnectionStarted connectionSource() const {
|
ConnectionStarted connectionSource() const {
|
||||||
return mConnectionSource;
|
return mConnectionSource;
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource)
|
LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource)
|
||||||
: DeviceLink(deviceId, parent, connectionSource)
|
: DeviceLink(deviceId, parent, connectionSource)
|
||||||
, mSocketLineReader(new SocketLineReader(socket))
|
, mSocketLineReader(new SocketLineReader(socket))
|
||||||
, onSsl(false)
|
|
||||||
{
|
{
|
||||||
connect(mSocketLineReader, SIGNAL(readyRead()),
|
connect(mSocketLineReader, SIGNAL(readyRead()),
|
||||||
this, SLOT(dataReceived()));
|
this, SLOT(dataReceived()));
|
||||||
|
@ -50,26 +49,17 @@ QString LanDeviceLink::name()
|
||||||
return "LanLink"; // Should be same in both android and kde version
|
return "LanLink"; // Should be same in both android and kde version
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanDeviceLink::setOnSsl(bool value)
|
|
||||||
{
|
|
||||||
onSsl = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
PairingHandler* LanDeviceLink::createPairingHandler(Device* device)
|
PairingHandler* LanDeviceLink::createPairingHandler(Device* device)
|
||||||
{
|
{
|
||||||
return new LanPairingHandler(device->id());
|
return new LanPairingHandler(device->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanDeviceLink::sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& np)
|
bool LanDeviceLink::sendPackageEncrypted(NetworkPackage& np)
|
||||||
{
|
{
|
||||||
if (np.hasPayload()) {
|
if (np.hasPayload()) {
|
||||||
np.setPayloadTransferInfo(sendPayload(np)->transferInfo());
|
np.setPayloadTransferInfo(sendPayload(np)->transferInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!onSsl) {
|
|
||||||
np.encrypt(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
int written = mSocketLineReader->write(np.serialize());
|
int written = mSocketLineReader->write(np.serialize());
|
||||||
|
|
||||||
//TODO: Actually detect if a package is received or not, now we keep TCP
|
//TODO: Actually detect if a package is received or not, now we keep TCP
|
||||||
|
@ -91,10 +81,9 @@ bool LanDeviceLink::sendPackage(NetworkPackage& np)
|
||||||
UploadJob* LanDeviceLink::sendPayload(NetworkPackage& np)
|
UploadJob* LanDeviceLink::sendPayload(NetworkPackage& np)
|
||||||
{
|
{
|
||||||
QVariantMap transferInfo;
|
QVariantMap transferInfo;
|
||||||
if (onSsl) {
|
//FIXME: The next two lines shouldn't be needed! Why are they here?
|
||||||
transferInfo.insert("useSsl", true);
|
transferInfo.insert("useSsl", true);
|
||||||
transferInfo.insert("deviceId", deviceId());
|
transferInfo.insert("deviceId", deviceId());
|
||||||
}
|
|
||||||
UploadJob* job = new UploadJob(np.payload(), deviceId());
|
UploadJob* job = new UploadJob(np.payload(), deviceId());
|
||||||
job->start();
|
job->start();
|
||||||
return job;
|
return job;
|
||||||
|
@ -120,10 +109,9 @@ void LanDeviceLink::dataReceived()
|
||||||
if (unserialized.hasPayloadTransferInfo()) {
|
if (unserialized.hasPayloadTransferInfo()) {
|
||||||
//qCDebug(KDECONNECT_CORE) << "HasPayloadTransferInfo";
|
//qCDebug(KDECONNECT_CORE) << "HasPayloadTransferInfo";
|
||||||
QVariantMap transferInfo = unserialized.payloadTransferInfo();
|
QVariantMap transferInfo = unserialized.payloadTransferInfo();
|
||||||
if (onSsl) {
|
//FIXME: The next two lines shouldn't be needed! Why are they here?
|
||||||
transferInfo.insert("useSsl", true);
|
transferInfo.insert("useSsl", true);
|
||||||
transferInfo.insert("deviceId", deviceId());
|
transferInfo.insert("deviceId", deviceId());
|
||||||
}
|
|
||||||
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), transferInfo);
|
DownloadJob* job = new DownloadJob(mSocketLineReader->peerAddress(), transferInfo);
|
||||||
job->start();
|
job->start();
|
||||||
unserialized.setPayload(job->getPayload(), unserialized.payloadSize());
|
unserialized.setPayload(job->getPayload(), unserialized.payloadSize());
|
||||||
|
|
|
@ -39,11 +39,10 @@ public:
|
||||||
LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource);
|
LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSslSocket* socket, ConnectionStarted connectionSource);
|
||||||
|
|
||||||
virtual QString name() Q_DECL_OVERRIDE;
|
virtual QString name() Q_DECL_OVERRIDE;
|
||||||
void setOnSsl(bool value);
|
|
||||||
virtual PairingHandler* createPairingHandler(Device* device) Q_DECL_OVERRIDE;
|
virtual PairingHandler* createPairingHandler(Device* device) Q_DECL_OVERRIDE;
|
||||||
bool sendPackage(NetworkPackage& np) override;
|
bool sendPackage(NetworkPackage& np) override;
|
||||||
bool sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& np) override;
|
bool sendPackageEncrypted(NetworkPackage& np) override;
|
||||||
UploadJob* sendPayload(NetworkPackage&);
|
UploadJob* sendPayload(NetworkPackage& np);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void dataReceived();
|
void dataReceived();
|
||||||
|
|
|
@ -427,10 +427,6 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo
|
||||||
// Socket disconnection will now be handled by LanDeviceLink
|
// Socket disconnection will now be handled by LanDeviceLink
|
||||||
disconnect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
|
disconnect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
|
||||||
|
|
||||||
if (socket->isEncrypted()) {
|
|
||||||
deviceLink->setOnSsl(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//We kill any possible link from this same device
|
//We kill any possible link from this same device
|
||||||
QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(deviceLink->deviceId());
|
QMap< QString, DeviceLink* >::iterator oldLinkIterator = mLinks.find(deviceLink->deviceId());
|
||||||
if (oldLinkIterator != mLinks.end()) {
|
if (oldLinkIterator != mLinks.end()) {
|
||||||
|
|
|
@ -38,33 +38,9 @@ PairingHandler* LoopbackDeviceLink::createPairingHandler(Device *device)
|
||||||
{
|
{
|
||||||
return new LoopbackPairingHandler(device->id());
|
return new LoopbackPairingHandler(device->id());
|
||||||
}
|
}
|
||||||
bool LoopbackDeviceLink::sendPackageEncrypted(QCA::PublicKey& key, NetworkPackage& input)
|
bool LoopbackDeviceLink::sendPackageEncrypted(NetworkPackage& input)
|
||||||
{
|
{
|
||||||
if (mPrivateKey.isNull() || key.isNull()) {
|
return sendPackage(input);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
input.encrypt(key);
|
|
||||||
|
|
||||||
QByteArray serialized = input.serialize();
|
|
||||||
|
|
||||||
NetworkPackage unserialized(QString::null);
|
|
||||||
NetworkPackage::unserialize(serialized, &unserialized);
|
|
||||||
|
|
||||||
NetworkPackage output(QString::null);
|
|
||||||
unserialized.decrypt(mPrivateKey, &output);
|
|
||||||
|
|
||||||
bool b = true;
|
|
||||||
//LoopbackDeviceLink does not need deviceTransferInfo
|
|
||||||
if (input.hasPayload()) {
|
|
||||||
b = input.payload()->open(QIODevice::ReadOnly);
|
|
||||||
Q_ASSERT(b);
|
|
||||||
output.setPayload(input.payload(), input.payloadSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT receivedPackage(output);
|
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
|
bool LoopbackDeviceLink::sendPackage(NetworkPackage& input)
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
virtual QString name() override;
|
virtual QString name() override;
|
||||||
virtual PairingHandler* createPairingHandler(Device* device) override;
|
virtual PairingHandler* createPairingHandler(Device* device) override;
|
||||||
virtual bool sendPackage(NetworkPackage& np) override;
|
virtual bool sendPackage(NetworkPackage& np) override;
|
||||||
virtual bool sendPackageEncrypted(QCA::PublicKey& publicKey, NetworkPackage& np) override;
|
virtual bool sendPackageEncrypted(NetworkPackage& np) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,22 @@
|
||||||
#include "pairinghandler.h"
|
#include "pairinghandler.h"
|
||||||
|
|
||||||
PairingHandler::PairingHandler()
|
PairingHandler::PairingHandler()
|
||||||
: m_pairStatus(NotPaired)
|
: m_deviceLink(nullptr)
|
||||||
, m_deviceLink(nullptr)
|
, m_pairStatus(NotPaired)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PairingHandler::setLink(DeviceLink *dl)
|
void PairingHandler::setDeviceLink(DeviceLink *dl)
|
||||||
{
|
{
|
||||||
m_deviceLink = dl;
|
m_deviceLink = dl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceLink* PairingHandler::deviceLink() const
|
||||||
|
{
|
||||||
|
return m_deviceLink;
|
||||||
|
}
|
||||||
|
|
||||||
void PairingHandler::linkDestroyed(QObject* o)
|
void PairingHandler::linkDestroyed(QObject* o)
|
||||||
{
|
{
|
||||||
DeviceLink* dl = static_cast<DeviceLink*>(o);
|
DeviceLink* dl = static_cast<DeviceLink*>(o);
|
||||||
|
@ -49,3 +54,9 @@ void PairingHandler::setPairStatus(PairingHandler::PairStatus status)
|
||||||
Q_EMIT pairStatusChanged(status, oldStatus);
|
Q_EMIT pairStatusChanged(status, oldStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PairingHandler::PairStatus PairingHandler::pairStatus() const
|
||||||
|
{
|
||||||
|
return m_pairStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
PairingHandler();
|
PairingHandler();
|
||||||
virtual ~PairingHandler() { }
|
virtual ~PairingHandler() { }
|
||||||
|
|
||||||
void setLink(DeviceLink* dl);
|
void setDeviceLink(DeviceLink* dl);
|
||||||
bool isPaired() const { return m_pairStatus == PairStatus::Paired; }
|
bool isPaired() const { return m_pairStatus == PairStatus::Paired; }
|
||||||
bool isPairRequested() const { return m_pairStatus == PairStatus::Requested; }
|
bool isPairRequested() const { return m_pairStatus == PairStatus::Requested; }
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <qstringbuilder.h>
|
||||||
|
|
||||||
#include "core_debug.h"
|
#include "core_debug.h"
|
||||||
#include "kdeconnectplugin.h"
|
#include "kdeconnectplugin.h"
|
||||||
|
@ -288,7 +289,7 @@ void Device::addLink(const NetworkPackage& identityPackage, DeviceLink* link)
|
||||||
connect(m_pairingHandlers[link->name()], SIGNAL(pairStatusChanged(PairStatus, PairStatus)), this, SLOT(pairStatusChanged(PairStatus, PairStatus)));
|
connect(m_pairingHandlers[link->name()], SIGNAL(pairStatusChanged(PairStatus, PairStatus)), this, SLOT(pairStatusChanged(PairStatus, PairStatus)));
|
||||||
connect(m_pairingHandlers[link->name()], SIGNAL(pairingFailed(const QString&)), this, SIGNAL(pairingFailed(const QString&)));
|
connect(m_pairingHandlers[link->name()], SIGNAL(pairingFailed(const QString&)), this, SIGNAL(pairingFailed(const QString&)));
|
||||||
}
|
}
|
||||||
m_pairingHandlers[link->name()]->setLink(link);
|
m_pairingHandlers[link->name()]->setDeviceLink(link);
|
||||||
connect(link, SIGNAL(destroyed(QObject*)), m_pairingHandlers[link->name()], SLOT(linkDestroyed(QObject*)));
|
connect(link, SIGNAL(destroyed(QObject*)), m_pairingHandlers[link->name()], SLOT(linkDestroyed(QObject*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ bool Device::sendPackage(NetworkPackage& np)
|
||||||
{
|
{
|
||||||
if (np.type() != PACKAGE_TYPE_PAIR && isPaired()) {
|
if (np.type() != PACKAGE_TYPE_PAIR && isPaired()) {
|
||||||
Q_FOREACH(DeviceLink* dl, m_deviceLinks) {
|
Q_FOREACH(DeviceLink* dl, m_deviceLinks) {
|
||||||
if (dl->sendPackageEncrypted(m_publicKey, np)) return true;
|
if (dl->sendPackageEncrypted(np)) return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Maybe we could block here any package that is not an identity or a pairing package to prevent sending non encrypted data
|
//Maybe we could block here any package that is not an identity or a pairing package to prevent sending non encrypted data
|
||||||
|
@ -366,8 +367,6 @@ void Device::rejectPairing()
|
||||||
{
|
{
|
||||||
qCDebug(KDECONNECT_CORE) << "Rejected pairing";
|
qCDebug(KDECONNECT_CORE) << "Rejected pairing";
|
||||||
|
|
||||||
m_pairStatus = PairingHandler::NotPaired;
|
|
||||||
|
|
||||||
Q_FOREACH(PairingHandler* ph, m_pairingHandlers.values()) {
|
Q_FOREACH(PairingHandler* ph, m_pairingHandlers.values()) {
|
||||||
ph->rejectPairing();
|
ph->rejectPairing();
|
||||||
}
|
}
|
||||||
|
@ -387,7 +386,8 @@ void Device::acceptPairing()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::isPaired() {
|
bool Device::isPaired() const
|
||||||
|
{
|
||||||
Q_FOREACH(PairingHandler* ph, m_pairingHandlers) {
|
Q_FOREACH(PairingHandler* ph, m_pairingHandlers) {
|
||||||
if (ph->isPaired()) return true;
|
if (ph->isPaired()) return true;
|
||||||
}
|
}
|
||||||
|
@ -466,9 +466,9 @@ void Device::setName(const QString &name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::PairStatus Device::pairStatus() const
|
PairingHandler::PairStatus Device::pairStatus() const
|
||||||
{
|
{
|
||||||
return m_pairStatus;
|
return isPaired()? PairingHandler::Paired : PairingHandler::NotPaired;
|
||||||
}
|
}
|
||||||
|
|
||||||
KdeConnectPlugin* Device::plugin(const QString& pluginName) const
|
KdeConnectPlugin* Device::plugin(const QString& pluginName) const
|
||||||
|
@ -499,17 +499,17 @@ QString Device::encryptionInfo() const
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
QByteArray myCertificate = KdeConnectConfig::instance()->certificate().toDer();
|
QString myCertificate = QString::fromLatin1(KdeConnectConfig::instance()->certificate().toDer());
|
||||||
for (int i=2 ; i<myCertificate.size() ; i+=3) {
|
for (int i=2 ; i<myCertificate.size() ; i+=3) {
|
||||||
myCertificate.insert(i, ':'); // Improve readability
|
myCertificate.insert(i, ':'); // Improve readability
|
||||||
}
|
}
|
||||||
result += i18n("SHA1 fingerprint of your device certificate is : ") + myCertificate + endl;
|
result += i18n("SHA1 fingerprint of your device certificate is: ") + myCertificate + "\n";
|
||||||
|
|
||||||
QString remoteCertificate = KdeConnectConfig::instance()->getDeviceProperty(id(), "certificate");
|
QString remoteCertificate = KdeConnectConfig::instance()->getDeviceProperty(id(), "certificate");
|
||||||
for (int i=2 ; i<remoteCertificate.size() ; i+=3) {
|
for (int i=2 ; i<remoteCertificate.size() ; i+=3) {
|
||||||
remoteCertificate.insert(i, ':'); // Improve readability
|
remoteCertificate.insert(i, ':'); // Improve readability
|
||||||
}
|
}
|
||||||
result += i18n("SHA1 fingerprint of remote device certificate is : ") << remoteCertificate << endl;
|
result += i18n("SHA1 fingerprint of remote device certificate is: ") + remoteCertificate + "\n";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
QString iconName() const;
|
QString iconName() const;
|
||||||
QString statusIconName() const;
|
QString statusIconName() const;
|
||||||
QStringList unsupportedPlugins() const { return m_unsupportedPlugins; }
|
QStringList unsupportedPlugins() const { return m_unsupportedPlugins; }
|
||||||
QString encryptionInfo() const;
|
Q_SCRIPTABLE QString encryptionInfo() const;
|
||||||
|
|
||||||
//Add and remove links
|
//Add and remove links
|
||||||
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
|
void addLink(const NetworkPackage& identityPackage, DeviceLink*);
|
||||||
|
|
|
@ -286,7 +286,7 @@ void KdeConnectKcm::pairingChanged(bool paired)
|
||||||
|
|
||||||
kcmUi->pair_button->setVisible(!paired);
|
kcmUi->pair_button->setVisible(!paired);
|
||||||
kcmUi->unpair_button->setVisible(paired);
|
kcmUi->unpair_button->setVisible(paired);
|
||||||
kcmUi->progressBar->setVisible(senderDevice->pairRequested());
|
kcmUi->progressBar->setVisible(senderDevice->isPairRequested());
|
||||||
kcmUi->ping_button->setVisible(paired);
|
kcmUi->ping_button->setVisible(paired);
|
||||||
kcmUi->status_label->setText(paired ? i18n("(paired)") : i18n("(unpaired)"));
|
kcmUi->status_label->setText(paired ? i18n("(paired)") : i18n("(unpaired)"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "../core/device.h"
|
||||||
#include "../core/backends/lan/lanlinkprovider.h"
|
#include "../core/backends/lan/lanlinkprovider.h"
|
||||||
#include "../core/kdeconnectconfig.h"
|
#include "../core/kdeconnectconfig.h"
|
||||||
|
|
||||||
|
@ -68,15 +69,8 @@ void DeviceTest::testPairedDevice()
|
||||||
QCOMPARE(device.name(), deviceName);
|
QCOMPARE(device.name(), deviceName);
|
||||||
QCOMPARE(device.type(), deviceType);
|
QCOMPARE(device.type(), deviceType);
|
||||||
|
|
||||||
QVERIFY2(!device.publicKey().isNull(), "Public key for device is null");
|
|
||||||
QCOMPARE(device.publicKey(), kcc->publicKey());
|
|
||||||
|
|
||||||
QVERIFY2(device.certificate().isNull(), "Certificate should be null before initialisation");
|
|
||||||
|
|
||||||
// TODO : Set certificate via identity package
|
|
||||||
|
|
||||||
QCOMPARE(device.isPaired(), true);
|
QCOMPARE(device.isPaired(), true);
|
||||||
QCOMPARE(device.pairRequested(), false);
|
QCOMPARE(device.isPairRequested(), false);
|
||||||
|
|
||||||
QCOMPARE(device.isReachable(), false);
|
QCOMPARE(device.isReachable(), false);
|
||||||
|
|
||||||
|
@ -112,11 +106,8 @@ void DeviceTest::testUnpairedDevice()
|
||||||
QCOMPARE(device.name(), deviceName);
|
QCOMPARE(device.name(), deviceName);
|
||||||
QCOMPARE(device.type(), deviceType);
|
QCOMPARE(device.type(), deviceType);
|
||||||
|
|
||||||
QVERIFY2(device.publicKey().isNull(), "Public key for unpaired device should be null");
|
|
||||||
QVERIFY2(device.certificate().isNull(), "Certificate for unpaired device should be null");
|
|
||||||
|
|
||||||
QCOMPARE(device.isPaired(), false);
|
QCOMPARE(device.isPaired(), false);
|
||||||
QCOMPARE(device.pairRequested(), false);
|
QCOMPARE(device.isPairRequested(), false);
|
||||||
|
|
||||||
QCOMPARE(device.isReachable(), true);
|
QCOMPARE(device.isReachable(), true);
|
||||||
QCOMPARE(device.availableLinks().contains(linkProvider.name()), true);
|
QCOMPARE(device.availableLinks().contains(linkProvider.name()), true);
|
||||||
|
|
|
@ -34,9 +34,9 @@ Q_OBJECT
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void addTrustedDevice();
|
void addTrustedDevice();
|
||||||
|
/*
|
||||||
void remoteCertificateTest();
|
void remoteCertificateTest();
|
||||||
|
*/
|
||||||
void removeTrustedDevice();
|
void removeTrustedDevice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -46,13 +46,6 @@ private:
|
||||||
void KdeConnectConfigTest::initTestCase()
|
void KdeConnectConfigTest::initTestCase()
|
||||||
{
|
{
|
||||||
kcc = KdeConnectConfig::instance();
|
kcc = KdeConnectConfig::instance();
|
||||||
|
|
||||||
QVERIFY2(!kcc->publicKey().isNull(), "Public key not generated, is null");
|
|
||||||
QVERIFY2(!kcc->privateKey().isNull(), "Private key not generated, is null");
|
|
||||||
QVERIFY2(!kcc->certificate().isNull(), "Certificate not generated, is null");
|
|
||||||
QVERIFY2(QFile::exists(kcc->privateKeyPath()), "Private key file does not exists, private key not saved properly");
|
|
||||||
QVERIFY2(QFile::exists(kcc->certificatePath()), "Certificate file does not exists, certificate not saved properly");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KdeConnectConfigTest::addTrustedDevice()
|
void KdeConnectConfigTest::addTrustedDevice()
|
||||||
|
@ -63,6 +56,7 @@ void KdeConnectConfigTest::addTrustedDevice()
|
||||||
QCOMPARE(devInfo.deviceType, QString("phone"));
|
QCOMPARE(devInfo.deviceType, QString("phone"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// This checks whether certificate is generated correctly and stored correctly or not
|
// This checks whether certificate is generated correctly and stored correctly or not
|
||||||
void KdeConnectConfigTest::remoteCertificateTest()
|
void KdeConnectConfigTest::remoteCertificateTest()
|
||||||
{
|
{
|
||||||
|
@ -84,6 +78,7 @@ void KdeConnectConfigTest::remoteCertificateTest()
|
||||||
QCOMPARE(devCertificate.subjectInfo(QSslCertificate::OrganizationalUnitName).first(), QString("Kde connect"));
|
QCOMPARE(devCertificate.subjectInfo(QSslCertificate::OrganizationalUnitName).first(), QString("Kde connect"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void KdeConnectConfigTest::removeTrustedDevice()
|
void KdeConnectConfigTest::removeTrustedDevice()
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <QAbstractSocket>
|
#include <QAbstractSocket>
|
||||||
#include <QSslSocket>
|
#include <QSslSocket>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
#include <QSslKey>
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -322,11 +323,10 @@ QSslCertificate LanLinkProviderTest::generateCertificate(QString& commonName, QC
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanLinkProviderTest::setSocketAttributes(QSslSocket *socket) {
|
void LanLinkProviderTest::setSocketAttributes(QSslSocket *socket)
|
||||||
|
{
|
||||||
socket->setPrivateKey(QSslKey(privateKey.toPEM().toLatin1(), QSsl::Rsa));
|
socket->setPrivateKey(QSslKey(privateKey.toPEM().toLatin1(), QSsl::Rsa));
|
||||||
socket->setLocalCertificate(certificate);
|
socket->setLocalCertificate(certificate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LanLinkProviderTest::addTrustedDevice()
|
void LanLinkProviderTest::addTrustedDevice()
|
||||||
|
|
Loading…
Reference in a new issue