File indexing completed on 2024-09-15 11:59:39
0001 /* 0002 SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "ksambasharetest.h" 0008 0009 #include <KSambaShare> 0010 #include <KSambaShareData> 0011 0012 #include <QTest> 0013 0014 QTEST_MAIN(KSambaShareTest) 0015 0016 Q_DECLARE_METATYPE(KSambaShareData::UserShareError) 0017 0018 void KSambaShareTest::initTestCase() 0019 { 0020 qRegisterMetaType<KSambaShareData::UserShareError>(); 0021 } 0022 0023 void KSambaShareTest::testAcl() 0024 { 0025 QFETCH(QString, acl); 0026 QFETCH(KSambaShareData::UserShareError, result); 0027 0028 KSambaShareData data; 0029 0030 QCOMPARE(data.setAcl(acl), result); 0031 } 0032 0033 void KSambaShareTest::testAcl_data() 0034 { 0035 QTest::addColumn<QString>("acl"); 0036 QTest::addColumn<KSambaShareData::UserShareError>("result"); 0037 0038 QTest::newRow("one entry") << QStringLiteral("Everyone:r") << KSambaShareData::UserShareAclOk; 0039 QTest::newRow("one entry, trailing comma") << QStringLiteral("Everyone:r,") << KSambaShareData::UserShareAclOk; 0040 0041 QTest::newRow("one entry with hostname") << QStringLiteral("Host\\Someone:r") << KSambaShareData::UserShareAclOk; 0042 0043 QTest::newRow("space in hostname") << QStringLiteral("Everyone:r,Unix User\\Someone:f,") << KSambaShareData::UserShareAclOk; 0044 0045 QTest::newRow("garbage") << QStringLiteral("Garbage") << KSambaShareData::UserShareAclInvalid; 0046 } 0047 0048 void KSambaShareTest::testOwnAcl() 0049 { 0050 const auto shares = KSambaShare::instance()->shareNames(); 0051 0052 for (const QString &share : shares) { 0053 KSambaShareData shareData = KSambaShare::instance()->getShareByName(share); 0054 0055 // KSambaShare reads acl from net usershare info's "usershare_acl" field with no validation 0056 QCOMPARE(shareData.setAcl(shareData.acl()), KSambaShareData::UserShareAclOk); 0057 } 0058 } 0059 0060 #include "moc_ksambasharetest.cpp"