Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/test is mount root property #6832

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 93 additions & 4 deletions test/testsyncmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

#include <QtTest>

Check failure on line 8 in test/testsyncmove.cpp

View workflow job for this annotation

GitHub Actions / build

test/testsyncmove.cpp:8:10 [clang-diagnostic-error]

'QtTest' file not found
#include "common/result.h"
#include "syncenginetestutils.h"
#include <syncengine.h>
Expand All @@ -18,19 +18,26 @@
int nPUT = 0;
int nMOVE = 0;
int nDELETE = 0;
int nPROPFIND = 0;
int nMKCOL = 0;

void reset() { *this = {}; }

auto functor() {
return [&](QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *) {
if (op == QNetworkAccessManager::GetOperation)
if (op == QNetworkAccessManager::GetOperation) {
++nGET;
if (op == QNetworkAccessManager::PutOperation)
} else if (op == QNetworkAccessManager::PutOperation) {
++nPUT;
if (op == QNetworkAccessManager::DeleteOperation)
} else if (op == QNetworkAccessManager::DeleteOperation) {
++nDELETE;
if (req.attribute(QNetworkRequest::CustomVerbAttribute).toString() == "MOVE")
} else if (req.attribute(QNetworkRequest::CustomVerbAttribute).toString() == "MOVE") {
++nMOVE;
} else if (req.attribute(QNetworkRequest::CustomVerbAttribute).toString() == "PROPFIND") {
++nPROPFIND;
} else if (req.attribute(QNetworkRequest::CustomVerbAttribute).toString() == "MKCOL") {
++nMKCOL;
}
return nullptr;
};
}
Expand Down Expand Up @@ -79,6 +86,13 @@
return false;
}

static void setAllPerm(FileInfo *fi, OCC::RemotePermissions perm)

Check warning on line 89 in test/testsyncmove.cpp

View workflow job for this annotation

GitHub Actions / build

test/testsyncmove.cpp:89:34 [readability-identifier-length]

parameter name 'fi' is too short, expected at least 3 characters
{
fi->permissions = perm;
for (auto &subFi : fi->children)
setAllPerm(&subFi, perm);
}

class TestSyncMove : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -1125,6 +1139,81 @@

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}

void testBlockRenameTopFolderFromGroupFolder()
{
FakeFolder fakeFolder{{}};
fakeFolder.syncEngine().account()->setServerVersion("29.0.2.0");

fakeFolder.remoteModifier().mkdir("FolA");
auto groupFolderRoot = fakeFolder.remoteModifier().find("FolA");
groupFolderRoot->extraDavProperties = "<nc:is-mount-root>true</nc:is-mount-root>";
setAllPerm(groupFolderRoot, RemotePermissions::fromServerString("WDNVCKRM"));
fakeFolder.remoteModifier().mkdir("FolA/FolB");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC/FolD");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC/FolD/FolE");
fakeFolder.remoteModifier().insert("FolA/FileA.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FileB.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FileC.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FolD/FileD.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FolD/FolE/FileE.txt");
QVERIFY(fakeFolder.syncOnce());

OperationCounter counter;
fakeFolder.setServerOverride(counter.functor());

fakeFolder.localModifier().insert("FolA/FileA2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FileB2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FileC2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FolD/FileD2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FolD/FolE/FileE2.txt");
fakeFolder.localModifier().rename("FolA", "FolA_Renamed");
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(counter.nDELETE, 0);
QCOMPARE(counter.nGET, 0);
QCOMPARE(counter.nPUT, 10);
QCOMPARE(counter.nMOVE, 0);
QCOMPARE(counter.nMKCOL, 5);
}

void testAllowRenameChildFolderFromGroupFolder()
{
FakeFolder fakeFolder{{}};
fakeFolder.syncEngine().account()->setServerVersion("29.0.2.0");

fakeFolder.remoteModifier().mkdir("FolA");
auto groupFolderRoot = fakeFolder.remoteModifier().find("FolA");
groupFolderRoot->extraDavProperties = "<nc:is-mount-root>true</nc:is-mount-root>";
setAllPerm(groupFolderRoot, RemotePermissions::fromServerString("WDNVCKRM"));
fakeFolder.remoteModifier().mkdir("FolA/FolB");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC/FolD");
fakeFolder.remoteModifier().mkdir("FolA/FolB/FolC/FolD/FolE");
fakeFolder.remoteModifier().insert("FolA/FileA.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FileB.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FileC.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FolD/FileD.txt");
fakeFolder.remoteModifier().insert("FolA/FolB/FolC/FolD/FolE/FileE.txt");
QVERIFY(fakeFolder.syncOnce());

OperationCounter counter;
fakeFolder.setServerOverride(counter.functor());

fakeFolder.localModifier().insert("FolA/FileA2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FileB2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FileC2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FolD/FileD2.txt");
fakeFolder.localModifier().insert("FolA/FolB/FolC/FolD/FolE/FileE2.txt");
fakeFolder.localModifier().rename("FolA/FolB", "FolA/FolB_Renamed");
fakeFolder.localModifier().rename("FolA/FileA.txt", "FolA/FileA_Renamed.txt");
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(counter.nDELETE, 0);
QCOMPARE(counter.nGET, 0);
QCOMPARE(counter.nPUT, 5);
QCOMPARE(counter.nMOVE, 2);
QCOMPARE(counter.nMKCOL, 0);
}
};

QTEST_GUILESS_MAIN(TestSyncMove)
Expand Down
Loading