|
18 | 18 | #include <iostream> |
19 | 19 |
|
20 | 20 | using namespace OCC; |
| 21 | +using namespace Qt::StringLiterals; |
21 | 22 |
|
22 | 23 | static void applyPermissionsFromName(FileInfo &info) { |
23 | 24 | static QRegularExpression rx("_PERM_([^_]*)_[^/]*$"); |
@@ -969,7 +970,64 @@ private slots: |
969 | 970 | fakeFolder.remoteModifier().insert("groupFolder/simpleChildFolder/otherFile", 12); |
970 | 971 |
|
971 | 972 | QVERIFY(fakeFolder.syncOnce()); |
972 | | - QCOMPARE(propfindCounter, 8); |
| 973 | + QCOMPARE(propfindCounter, 10); |
| 974 | + } |
| 975 | + |
| 976 | + void testFolderReadonlyWhenRemotePermissionsWithoutEtagChanged_data() |
| 977 | + { |
| 978 | + QTest::addColumn<bool>("isReadOnly"); |
| 979 | + QTest::newRow("G") << true; |
| 980 | + QTest::newRow("GS") << true; |
| 981 | + QTest::newRow("GR") << true; |
| 982 | + QTest::newRow("GRS") << true; |
| 983 | + QTest::newRow("GRM") << true; |
| 984 | + QTest::newRow("GRMS") << true; |
| 985 | + QTest::newRow("GW") << false; |
| 986 | + QTest::newRow("GWS") << false; |
| 987 | + QTest::newRow("GD") << false; |
| 988 | + QTest::newRow("GDS") << false; |
| 989 | + QTest::newRow("GN") << false; |
| 990 | + QTest::newRow("GV") << false; |
| 991 | + QTest::newRow("GC") << false; |
| 992 | + QTest::newRow("GK") << false; |
| 993 | + QTest::newRow("GWD") << false; |
| 994 | + QTest::newRow("GWDS") << false; |
| 995 | + QTest::newRow("GDNCV") << false; |
| 996 | + QTest::newRow("GDNCVS") << false; |
| 997 | + QTest::newRow("GDNVCKR") << false; |
| 998 | + QTest::newRow("GDNVCKRS") << false; |
| 999 | + } |
| 1000 | + |
| 1001 | + void testFolderReadonlyWhenRemotePermissionsWithoutEtagChanged() |
| 1002 | + { |
| 1003 | + const auto remotePerm = QString::fromLocal8Bit(QTest::currentDataTag()); |
| 1004 | + QFETCH(bool, isReadOnly); |
| 1005 | + auto remotePermChange = isReadOnly ? (remotePerm + "W") : u"G"_s; |
| 1006 | + |
| 1007 | + FakeFolder fakeFolder{FileInfo{}}; |
| 1008 | + |
| 1009 | + const auto isFolderReadOnly = [&fakeFolder](const QString &relativePath) -> bool { |
| 1010 | + return FileSystem::isFolderReadOnly(std::filesystem::path{FileSystem::joinPath(fakeFolder.localPath(), relativePath).toStdWString()}); |
| 1011 | + }; |
| 1012 | + |
| 1013 | + fakeFolder.remoteModifier().mkdir("root"); |
| 1014 | + fakeFolder.remoteModifier().mkdir("root/subdir"); |
| 1015 | + fakeFolder.remoteModifier().mkdir("root/subdir/subsubdir"); |
| 1016 | + auto rootFolder = fakeFolder.remoteModifier().find("root"); |
| 1017 | + |
| 1018 | + qInfo() << "initial sync with" << remotePerm; |
| 1019 | + setAllPerm(rootFolder, RemotePermissions::fromServerString(remotePerm)); |
| 1020 | + QVERIFY(fakeFolder.syncOnce()); |
| 1021 | + QCOMPARE_EQ(isFolderReadOnly(u"root"_s), isReadOnly); |
| 1022 | + QCOMPARE_EQ(isFolderReadOnly(u"root/subdir"_s), isReadOnly); |
| 1023 | + QCOMPARE_EQ(isFolderReadOnly(u"root/subdir/subsubdir"_s), isReadOnly); |
| 1024 | + |
| 1025 | + qInfo() << "remote update with" << remotePermChange; |
| 1026 | + setAllPerm(rootFolder, RemotePermissions::fromServerString(remotePermChange)); |
| 1027 | + QVERIFY(fakeFolder.syncOnce()); |
| 1028 | + QCOMPARE_EQ(isFolderReadOnly(u"root"_s), !isReadOnly); |
| 1029 | + QCOMPARE_EQ(isFolderReadOnly(u"root/subdir"_s), !isReadOnly); |
| 1030 | + QCOMPARE_EQ(isFolderReadOnly(u"root/subdir/subsubdir"_s), !isReadOnly); |
973 | 1031 | } |
974 | 1032 | }; |
975 | 1033 |
|
|
0 commit comments