diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-20 10:52:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-20 10:52:30 +0200 |
commit | 160f3153cffb110f5b52e244485ccbc2c15b002c (patch) | |
tree | 5159a2f7dc3ee04d34998d383357eddeb76da0ea | |
parent | cb21b7d053ab35f61e8316853f57ec1ce121e484 (diff) | |
download | sink-160f3153cffb110f5b52e244485ccbc2c15b002c.tar.gz sink-160f3153cffb110f5b52e244485ccbc2c15b002c.zip |
Fixed tests with secretstore
-rw-r--r-- | common/genericresource.cpp | 5 | ||||
-rw-r--r-- | common/genericresource.h | 1 | ||||
-rw-r--r-- | common/inspector.cpp | 13 | ||||
-rw-r--r-- | common/inspector.h | 6 | ||||
-rw-r--r-- | common/secretstore.cpp | 6 | ||||
-rw-r--r-- | common/secretstore.h | 3 | ||||
-rw-r--r-- | examples/imapresource/imapresource.cpp | 9 | ||||
-rw-r--r-- | examples/imapresource/tests/imapmailsynctest.cpp | 5 | ||||
-rw-r--r-- | examples/imapresource/tests/imapmailtest.cpp | 3 | ||||
-rw-r--r-- | examples/mailtransportresource/tests/mailtransporttest.cpp | 3 |
10 files changed, 41 insertions, 13 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index b6a8f62..00d7d0c 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "pipeline.h" | 22 | #include "pipeline.h" |
23 | #include "synchronizer.h" | 23 | #include "synchronizer.h" |
24 | #include "inspector.h" | ||
24 | #include "commandprocessor.h" | 25 | #include "commandprocessor.h" |
25 | #include "definitions.h" | 26 | #include "definitions.h" |
26 | #include "storage.h" | 27 | #include "storage.h" |
@@ -50,6 +51,9 @@ void GenericResource::setSecret(const QString &s) | |||
50 | if (mSynchronizer) { | 51 | if (mSynchronizer) { |
51 | mSynchronizer->setSecret(s); | 52 | mSynchronizer->setSecret(s); |
52 | } | 53 | } |
54 | if (mInspector) { | ||
55 | mInspector->setSecret(s); | ||
56 | } | ||
53 | } | 57 | } |
54 | 58 | ||
55 | void GenericResource::setupPreprocessors(const QByteArray &type, const QVector<Sink::Preprocessor *> &preprocessors) | 59 | void GenericResource::setupPreprocessors(const QByteArray &type, const QVector<Sink::Preprocessor *> &preprocessors) |
@@ -68,6 +72,7 @@ void GenericResource::setupSynchronizer(const QSharedPointer<Synchronizer> &sync | |||
68 | 72 | ||
69 | void GenericResource::setupInspector(const QSharedPointer<Inspector> &inspector) | 73 | void GenericResource::setupInspector(const QSharedPointer<Inspector> &inspector) |
70 | { | 74 | { |
75 | mInspector = inspector; | ||
71 | mProcessor->setInspector(inspector); | 76 | mProcessor->setInspector(inspector); |
72 | } | 77 | } |
73 | 78 | ||
diff --git a/common/genericresource.h b/common/genericresource.h index 4e86b75..edcd7d2 100644 --- a/common/genericresource.h +++ b/common/genericresource.h | |||
@@ -70,6 +70,7 @@ private: | |||
70 | QSharedPointer<Pipeline> mPipeline; | 70 | QSharedPointer<Pipeline> mPipeline; |
71 | QSharedPointer<CommandProcessor> mProcessor; | 71 | QSharedPointer<CommandProcessor> mProcessor; |
72 | QSharedPointer<Synchronizer> mSynchronizer; | 72 | QSharedPointer<Synchronizer> mSynchronizer; |
73 | QSharedPointer<Inspector> mInspector; | ||
73 | int mError; | 74 | int mError; |
74 | qint64 mClientLowerBoundRevision; | 75 | qint64 mClientLowerBoundRevision; |
75 | }; | 76 | }; |
diff --git a/common/inspector.cpp b/common/inspector.cpp index 78053a2..0e7a61f 100644 --- a/common/inspector.cpp +++ b/common/inspector.cpp | |||
@@ -30,10 +30,7 @@ using namespace Sink; | |||
30 | Inspector::Inspector(const ResourceContext &context) | 30 | Inspector::Inspector(const ResourceContext &context) |
31 | : QObject(), | 31 | : QObject(), |
32 | mResourceContext(context) | 32 | mResourceContext(context) |
33 | // mEntityStore(Storage::EntityStore::Ptr::create(mResourceContext)), | ||
34 | // mSyncStorage(Sink::storageLocation(), mResourceContext.instanceId() + ".synchronization", Sink::Storage::DataStore::DataStore::ReadWrite) | ||
35 | { | 33 | { |
36 | // SinkTrace() << "Starting synchronizer: " << mResourceContext.resourceType << mResourceContext.instanceId(); | ||
37 | } | 34 | } |
38 | 35 | ||
39 | Inspector::~Inspector() | 36 | Inspector::~Inspector() |
@@ -41,6 +38,16 @@ Inspector::~Inspector() | |||
41 | 38 | ||
42 | } | 39 | } |
43 | 40 | ||
41 | void Inspector::setSecret(const QString &s) | ||
42 | { | ||
43 | mSecret = s; | ||
44 | } | ||
45 | |||
46 | QString Inspector::secret() const | ||
47 | { | ||
48 | return mSecret; | ||
49 | } | ||
50 | |||
44 | KAsync::Job<void> Inspector::processCommand(void const *command, size_t size) | 51 | KAsync::Job<void> Inspector::processCommand(void const *command, size_t size) |
45 | { | 52 | { |
46 | flatbuffers::Verifier verifier((const uint8_t *)command, size); | 53 | flatbuffers::Verifier verifier((const uint8_t *)command, size); |
diff --git a/common/inspector.h b/common/inspector.h index 5ee995e..a1f7c53 100644 --- a/common/inspector.h +++ b/common/inspector.h | |||
@@ -41,13 +41,19 @@ public: | |||
41 | 41 | ||
42 | KAsync::Job<void> processCommand(void const *command, size_t size); | 42 | KAsync::Job<void> processCommand(void const *command, size_t size); |
43 | 43 | ||
44 | void setSecret(const QString &s); | ||
45 | |||
44 | signals: | 46 | signals: |
45 | void notify(Notification); | 47 | void notify(Notification); |
46 | 48 | ||
47 | protected: | 49 | protected: |
50 | QString secret() const; | ||
48 | virtual KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); | 51 | virtual KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); |
49 | 52 | ||
50 | Sink::ResourceContext mResourceContext; | 53 | Sink::ResourceContext mResourceContext; |
54 | |||
55 | private: | ||
56 | QString mSecret; | ||
51 | }; | 57 | }; |
52 | 58 | ||
53 | } | 59 | } |
diff --git a/common/secretstore.cpp b/common/secretstore.cpp index 39d5206..27704fa 100644 --- a/common/secretstore.cpp +++ b/common/secretstore.cpp | |||
@@ -29,6 +29,12 @@ using namespace Sink; | |||
29 | 29 | ||
30 | QMutex SecretStore::sMutex; | 30 | QMutex SecretStore::sMutex; |
31 | 31 | ||
32 | SecretStore::SecretStore() | ||
33 | : QObject() | ||
34 | { | ||
35 | |||
36 | } | ||
37 | |||
32 | SecretStore &SecretStore::instance() | 38 | SecretStore &SecretStore::instance() |
33 | { | 39 | { |
34 | static SecretStore s; | 40 | static SecretStore s; |
diff --git a/common/secretstore.h b/common/secretstore.h index 04fdaba..119003a 100644 --- a/common/secretstore.h +++ b/common/secretstore.h | |||
@@ -42,6 +42,9 @@ Q_SIGNALS: | |||
42 | void secretAvailable(const QByteArray &resourceId); | 42 | void secretAvailable(const QByteArray &resourceId); |
43 | 43 | ||
44 | private: | 44 | private: |
45 | Q_DISABLE_COPY(SecretStore); | ||
46 | SecretStore(); | ||
47 | |||
45 | QMap<QByteArray, QString> mCache; | 48 | QMap<QByteArray, QString> mCache; |
46 | static QMutex sMutex; | 49 | static QMutex sMutex; |
47 | }; | 50 | }; |
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 2aba6b0..b8a741b 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -841,7 +841,7 @@ protected: | |||
841 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | 841 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); |
842 | SinkTrace() << "Connecting to:" << mServer << mPort; | 842 | SinkTrace() << "Connecting to:" << mServer << mPort; |
843 | SinkTrace() << "as:" << mUser; | 843 | SinkTrace() << "as:" << mUser; |
844 | auto inspectionJob = imap->login(mUser, mPassword) | 844 | auto inspectionJob = imap->login(mUser, secret()) |
845 | .then(imap->select(folderRemoteId)) | 845 | .then(imap->select(folderRemoteId)) |
846 | .then([](Imap::SelectResult){}) | 846 | .then([](Imap::SelectResult){}) |
847 | .then(imap->fetch(set, scope, [imap, messageByUid](const Imap::Message &message) { | 847 | .then(imap->fetch(set, scope, [imap, messageByUid](const Imap::Message &message) { |
@@ -907,7 +907,7 @@ protected: | |||
907 | scope.mode = KIMAP2::FetchJob::FetchScope::Headers; | 907 | scope.mode = KIMAP2::FetchJob::FetchScope::Headers; |
908 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 908 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); |
909 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | 909 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); |
910 | return imap->login(mUser, mPassword) | 910 | return imap->login(mUser, secret()) |
911 | .then(imap->select(remoteId)) | 911 | .then(imap->select(remoteId)) |
912 | .then(imap->fetch(set, scope, [=](const Imap::Message message) { | 912 | .then(imap->fetch(set, scope, [=](const Imap::Message message) { |
913 | messageByUid->insert(message.uid, message); | 913 | messageByUid->insert(message.uid, message); |
@@ -924,7 +924,7 @@ protected: | |||
924 | auto folderByName = QSharedPointer<QSet<QString>>::create(); | 924 | auto folderByName = QSharedPointer<QSet<QString>>::create(); |
925 | 925 | ||
926 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | 926 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); |
927 | auto inspectionJob = imap->login(mUser, mPassword) | 927 | auto inspectionJob = imap->login(mUser, secret()) |
928 | .then(imap->fetchFolders([=](const Imap::Folder &f) { | 928 | .then(imap->fetchFolders([=](const Imap::Folder &f) { |
929 | *folderByPath << f.path(); | 929 | *folderByPath << f.path(); |
930 | *folderByName << f.name(); | 930 | *folderByName << f.name(); |
@@ -949,7 +949,6 @@ public: | |||
949 | QString mServer; | 949 | QString mServer; |
950 | int mPort; | 950 | int mPort; |
951 | QString mUser; | 951 | QString mUser; |
952 | QString mPassword; | ||
953 | }; | 952 | }; |
954 | 953 | ||
955 | 954 | ||
@@ -981,8 +980,6 @@ ImapResource::ImapResource(const ResourceContext &resourceContext) | |||
981 | inspector->mServer = server; | 980 | inspector->mServer = server; |
982 | inspector->mPort = port; | 981 | inspector->mPort = port; |
983 | inspector->mUser = user; | 982 | inspector->mUser = user; |
984 | //TODO | ||
985 | // inspector->mPassword = password; | ||
986 | setupInspector(inspector); | 983 | setupInspector(inspector); |
987 | 984 | ||
988 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor << new MailPropertyExtractor); | 985 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor << new MailPropertyExtractor); |
diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp index 7cdb103..f20a77e 100644 --- a/examples/imapresource/tests/imapmailsynctest.cpp +++ b/examples/imapresource/tests/imapmailsynctest.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "common/test.h" | 26 | #include "common/test.h" |
27 | #include "common/domain/applicationdomaintype.h" | 27 | #include "common/domain/applicationdomaintype.h" |
28 | #include "common/secretstore.h" | ||
28 | 29 | ||
29 | using namespace Sink; | 30 | using namespace Sink; |
30 | using namespace Sink::ApplicationDomain; | 31 | using namespace Sink::ApplicationDomain; |
@@ -57,7 +58,7 @@ protected: | |||
57 | resource.setProperty("server", "localhost"); | 58 | resource.setProperty("server", "localhost"); |
58 | resource.setProperty("port", 993); | 59 | resource.setProperty("port", 993); |
59 | resource.setProperty("username", "doe"); | 60 | resource.setProperty("username", "doe"); |
60 | resource.setProperty("password", "doe"); | 61 | Sink::SecretStore::instance().insert(resource.identifier(), "doe"); |
61 | return resource; | 62 | return resource; |
62 | } | 63 | } |
63 | 64 | ||
@@ -68,7 +69,7 @@ protected: | |||
68 | resource.setProperty("server", "111.111.1.1"); | 69 | resource.setProperty("server", "111.111.1.1"); |
69 | resource.setProperty("port", 993); | 70 | resource.setProperty("port", 993); |
70 | resource.setProperty("username", "doe"); | 71 | resource.setProperty("username", "doe"); |
71 | resource.setProperty("password", "doe"); | 72 | Sink::SecretStore::instance().insert(resource.identifier(), "doe"); |
72 | return resource; | 73 | return resource; |
73 | } | 74 | } |
74 | 75 | ||
diff --git a/examples/imapresource/tests/imapmailtest.cpp b/examples/imapresource/tests/imapmailtest.cpp index e6f41f4..60ec1bf 100644 --- a/examples/imapresource/tests/imapmailtest.cpp +++ b/examples/imapresource/tests/imapmailtest.cpp | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | #include "common/test.h" | 6 | #include "common/test.h" |
7 | #include "common/domain/applicationdomaintype.h" | 7 | #include "common/domain/applicationdomaintype.h" |
8 | #include "common/secretstore.h" | ||
8 | 9 | ||
9 | using namespace Sink; | 10 | using namespace Sink; |
10 | using namespace Sink::ApplicationDomain; | 11 | using namespace Sink::ApplicationDomain; |
@@ -37,7 +38,7 @@ protected: | |||
37 | resource.setProperty("server", "localhost"); | 38 | resource.setProperty("server", "localhost"); |
38 | resource.setProperty("port", 993); | 39 | resource.setProperty("port", 993); |
39 | resource.setProperty("username", "doe"); | 40 | resource.setProperty("username", "doe"); |
40 | resource.setProperty("password", "doe"); | 41 | Sink::SecretStore::instance().insert(resource.identifier(), "doe"); |
41 | return resource; | 42 | return resource; |
42 | } | 43 | } |
43 | }; | 44 | }; |
diff --git a/examples/mailtransportresource/tests/mailtransporttest.cpp b/examples/mailtransportresource/tests/mailtransporttest.cpp index 2a831ed..8669024 100644 --- a/examples/mailtransportresource/tests/mailtransporttest.cpp +++ b/examples/mailtransportresource/tests/mailtransporttest.cpp | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "common/resourcecontrol.h" | 8 | #include "common/resourcecontrol.h" |
9 | #include "common/domain/applicationdomaintype.h" | 9 | #include "common/domain/applicationdomaintype.h" |
10 | #include "common/log.h" | 10 | #include "common/log.h" |
11 | #include "common/secretstore.h" | ||
11 | 12 | ||
12 | using namespace Sink; | 13 | using namespace Sink; |
13 | using namespace Sink::ApplicationDomain; | 14 | using namespace Sink::ApplicationDomain; |
@@ -22,7 +23,7 @@ class MailtransportTest : public QObject | |||
22 | resource.setProperty("server", "localhost"); | 23 | resource.setProperty("server", "localhost"); |
23 | // resource.setProperty("port", 993); | 24 | // resource.setProperty("port", 993); |
24 | resource.setProperty("user", "doe"); | 25 | resource.setProperty("user", "doe"); |
25 | resource.setProperty("password", "doe"); | 26 | Sink::SecretStore::instance().insert(resource.identifier(), "doe"); |
26 | resource.setProperty("testmode", true); | 27 | resource.setProperty("testmode", true); |
27 | return resource; | 28 | return resource; |
28 | } | 29 | } |