diff options
author | Jędrzej Nowacki <jedrzej.nowacki@digia.com> | 2014-04-29 19:05:19 +0000 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@digia.com> | 2014-08-08 11:01:15 +0200 |
commit | e7c189f13d0fc0d72cbcaf1770055da252e0fb3f (patch) | |
tree | cc944bc0a884b66534567994985df7f85d259bd8 /tests | |
parent | 18d4153168e5787b1c1a49bb68207f7f5d6042af (diff) | |
download | qtenginio-e7c189f13d0fc0d72cbcaf1770055da252e0fb3f.tar.gz |
Automatically refresh EnginioModel if identity was changed
The server automatically filter data based on ACL. It means that for
example after a succesfull login, a query result may be different.
[ChangeLog][Enginio] Automatically refresh EnginioModel contents
when identity changes.
Change-Id: Ied814d00b8cfb872fcd2ab2e6e7f51692e894890
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/enginiomodel/tst_enginiomodel.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/enginiomodel/tst_enginiomodel.cpp b/tests/auto/enginiomodel/tst_enginiomodel.cpp index 744ce12..47ad81b 100644 --- a/tests/auto/enginiomodel/tst_enginiomodel.cpp +++ b/tests/auto/enginiomodel/tst_enginiomodel.cpp @@ -50,6 +50,7 @@ #include <Enginio/enginioreply.h> #include <Enginio/enginiomodel.h> #include <Enginio/enginioidentity.h> +#include <Enginio/enginiooauth2authentication.h> #include "../common/common.h" @@ -99,6 +100,7 @@ private slots: void updatingRoles(); void setData(); void reload(); + void identityChange(); private: template<class T> @@ -1687,5 +1689,38 @@ void tst_EnginioModel::reload() QCOMPARE(model.rowCount(), 0); } +void tst_EnginioModel::identityChange() +{ + EnginioClient client; + QObject::connect(&client, SIGNAL(error(EnginioReply *)), this, SLOT(error(EnginioReply *))); + client.setBackendId("5376019e698b3c6ad500095a"); + + QJsonObject query; + query["objectType"] = "objects.EnginioModelIdentityChange"; + + EnginioModel model; + model.setQuery(query); + model.setClient(&client); + + EnginioOAuth2Authentication identity1; + identity1.setUser("test1"); + identity1.setPassword("test1"); + + EnginioOAuth2Authentication identity2; + identity2.setUser("test2"); + identity2.setPassword("test2"); + + QTRY_COMPARE(model.rowCount(), 1); // There is only one publicly visible element + + client.setIdentity(&identity1); + QTRY_COMPARE(model.rowCount(), 2); // Test1 sees one additional element + + client.setIdentity(&identity2); + QTRY_COMPARE(model.rowCount(), 3); // Test2 sees two additional elements + + client.setIdentity(0); + QTRY_COMPARE(model.rowCount(), 1); +} + QTEST_MAIN(tst_EnginioModel) #include "tst_enginiomodel.moc" |