2015-04-14 09:37:06 +03:00
|
|
|
/*
|
|
|
|
* This software is in the public domain, furnished "as is", without technical
|
|
|
|
* support, and with no warranty, express or implied, as to its usefulness for
|
|
|
|
* any purpose.
|
|
|
|
* */
|
|
|
|
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
#include "networkjobs.h"
|
2024-04-30 11:04:32 +03:00
|
|
|
#include "logger.h"
|
2015-04-14 09:37:06 +03:00
|
|
|
|
|
|
|
using namespace OCC;
|
|
|
|
|
|
|
|
class TestXmlParse : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
2023-02-03 20:38:52 +03:00
|
|
|
bool _success = false;
|
2015-04-14 09:37:06 +03:00
|
|
|
QStringList _subdirs;
|
|
|
|
QStringList _items;
|
|
|
|
|
2015-04-14 15:41:48 +03:00
|
|
|
public slots:
|
|
|
|
void slotDirectoryListingSubFolders(const QStringList& list)
|
|
|
|
{
|
|
|
|
qDebug() << "subfolders: " << list;
|
|
|
|
_subdirs.append(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
void slotDirectoryListingIterated(const QString& item, const QMap<QString,QString>& )
|
|
|
|
{
|
|
|
|
qDebug() << " item: " << item;
|
|
|
|
_items.append(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void slotFinishedSuccessfully()
|
|
|
|
{
|
|
|
|
_success = true;
|
|
|
|
}
|
|
|
|
|
2015-04-14 09:37:06 +03:00
|
|
|
private slots:
|
2024-04-30 11:04:32 +03:00
|
|
|
void initTestCase()
|
|
|
|
{
|
|
|
|
OCC::Logger::instance()->setLogFlush(true);
|
|
|
|
OCC::Logger::instance()->setLogDebug(true);
|
|
|
|
|
|
|
|
QStandardPaths::setTestModeEnabled(true);
|
|
|
|
}
|
|
|
|
|
2015-04-14 15:41:48 +03:00
|
|
|
void init() {
|
|
|
|
qDebug() << Q_FUNC_INFO;
|
2015-04-14 09:37:06 +03:00
|
|
|
_success = false;
|
2015-04-14 15:41:48 +03:00
|
|
|
_subdirs.clear();
|
|
|
|
_items.clear();
|
2015-04-14 09:37:06 +03:00
|
|
|
}
|
|
|
|
|
2015-04-14 15:41:48 +03:00
|
|
|
void cleanup() {
|
2015-04-14 09:37:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void testParser1() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/</d:href>"
|
2015-04-14 09:37:06 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/quitte.pdf</d:href>"
|
2015-04-14 09:37:06 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-04-14 09:37:06 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2015-04-14 09:37:06 +03:00
|
|
|
|
|
|
|
QVERIFY(_success);
|
2016-02-25 22:44:18 +03:00
|
|
|
QCOMPARE(sizes.size(), 1 ); // Quota info in the XML
|
2015-04-14 09:37:06 +03:00
|
|
|
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(_items.contains("/oc/remote.php/dav/sharefolder/quitte.pdf"));
|
|
|
|
QVERIFY(_items.contains("/oc/remote.php/dav/sharefolder"));
|
2015-04-14 09:37:06 +03:00
|
|
|
QVERIFY(_items.size() == 2 );
|
|
|
|
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(_subdirs.contains("/oc/remote.php/dav/sharefolder/"));
|
2015-04-14 09:37:06 +03:00
|
|
|
QVERIFY(_subdirs.size() == 1);
|
|
|
|
}
|
2015-04-14 15:41:48 +03:00
|
|
|
|
|
|
|
void testParserBrokenXml() {
|
|
|
|
const QByteArray testXml = "X<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/</d:href>"
|
2015-04-14 15:41:48 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/quitte.pdf</d:href>"
|
2015-04-14 15:41:48 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-04-14 15:41:48 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(false == parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" )); // verify false
|
2015-04-14 15:41:48 +03:00
|
|
|
|
|
|
|
QVERIFY(!_success);
|
|
|
|
QVERIFY(sizes.size() == 0 ); // No quota info in the XML
|
|
|
|
|
|
|
|
QVERIFY(_items.size() == 0 ); // FIXME: We should change the parser to not emit during parsing but at the end
|
|
|
|
|
|
|
|
QVERIFY(_subdirs.size() == 0);
|
2015-04-14 15:56:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void testParserEmptyXmlNoDav() {
|
|
|
|
const QByteArray testXml = "<html><body>I am under construction</body></html>";
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-04-14 15:56:25 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(false == parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" )); // verify false
|
2015-04-14 15:56:25 +03:00
|
|
|
|
|
|
|
QVERIFY(!_success);
|
|
|
|
QVERIFY(sizes.size() == 0 ); // No quota info in the XML
|
|
|
|
|
|
|
|
QVERIFY(_items.size() == 0 ); // FIXME: We should change the parser to not emit during parsing but at the end
|
|
|
|
QVERIFY(_subdirs.size() == 0);
|
2015-04-14 15:41:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void testParserEmptyXml() {
|
|
|
|
const QByteArray testXml = "";
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-04-14 15:41:48 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(false == parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" )); // verify false
|
2015-04-14 15:41:48 +03:00
|
|
|
|
|
|
|
QVERIFY(!_success);
|
|
|
|
QVERIFY(sizes.size() == 0 ); // No quota info in the XML
|
|
|
|
|
|
|
|
QVERIFY(_items.size() == 0 ); // FIXME: We should change the parser to not emit during parsing but at the end
|
|
|
|
QVERIFY(_subdirs.size() == 0);
|
|
|
|
}
|
2015-05-07 18:19:14 +03:00
|
|
|
|
2018-01-22 16:05:08 +03:00
|
|
|
void testParserTruncatedXml() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/</d:href>"
|
2018-01-22 16:05:08 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"; // no proper end here
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2018-01-22 16:05:08 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(!parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2018-01-22 16:05:08 +03:00
|
|
|
QVERIFY(!_success);
|
|
|
|
}
|
|
|
|
|
2015-05-07 18:19:14 +03:00
|
|
|
void testParserBogfusHref1() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>http://127.0.0.1:81/oc/remote.php/dav/sharefolder/</d:href>"
|
2015-05-07 18:19:14 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>http://127.0.0.1:81/oc/remote.php/dav/sharefolder/quitte.pdf</d:href>"
|
2015-05-07 18:19:14 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-05-07 18:19:14 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(false == parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2015-05-07 18:19:14 +03:00
|
|
|
QVERIFY(!_success);
|
|
|
|
}
|
|
|
|
|
|
|
|
void testParserBogfusHref2() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
|
|
|
"<d:href>/sharefolder</d:href>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
|
|
|
"<d:href>/sharefolder/quitte.pdf</d:href>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-05-07 18:19:14 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(false == parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2015-05-07 18:19:14 +03:00
|
|
|
QVERIFY(!_success);
|
|
|
|
}
|
|
|
|
|
2020-05-18 20:22:41 +03:00
|
|
|
void testParserDenormalizedPath() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/</d:href>"
|
2020-05-18 20:22:41 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/../sharefolder/quitte.pdf</d:href>"
|
2020-05-18 20:22:41 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2020-05-18 20:22:41 +03:00
|
|
|
|
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2020-05-18 20:22:41 +03:00
|
|
|
|
|
|
|
QVERIFY(_success);
|
|
|
|
QCOMPARE(sizes.size(), 1 ); // Quota info in the XML
|
|
|
|
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(_items.contains("/oc/remote.php/dav/sharefolder/quitte.pdf"));
|
|
|
|
QVERIFY(_items.contains("/oc/remote.php/dav/sharefolder"));
|
2020-05-18 20:22:41 +03:00
|
|
|
QVERIFY(_items.size() == 2 );
|
|
|
|
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(_subdirs.contains("/oc/remote.php/dav/sharefolder/"));
|
2020-05-18 20:22:41 +03:00
|
|
|
QVERIFY(_subdirs.size() == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void testParserDenormalizedPathOutsideNamespace() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/</d:href>"
|
2020-05-18 20:22:41 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
2021-05-20 15:17:16 +03:00
|
|
|
"<d:href>/oc/remote.php/dav/sharefolder/../quitte.pdf</d:href>"
|
2020-05-18 20:22:41 +03:00
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2020-05-18 20:22:41 +03:00
|
|
|
|
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2021-05-20 15:17:16 +03:00
|
|
|
QVERIFY(!parser.parse( testXml, &sizes, "/oc/remote.php/dav/sharefolder" ));
|
2020-05-18 20:22:41 +03:00
|
|
|
|
|
|
|
QVERIFY(!_success);
|
|
|
|
}
|
|
|
|
|
2015-05-07 18:19:14 +03:00
|
|
|
void testHrefUrlEncoding() {
|
|
|
|
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
|
|
|
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
|
|
|
"<d:response>"
|
|
|
|
"<d:href>/%C3%A4</d:href>" // a-umlaut utf8
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVCK</oc:permissions>"
|
|
|
|
"<oc:size>121780</oc:size>"
|
|
|
|
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
|
|
|
"<d:resourcetype>"
|
|
|
|
"<d:collection/>"
|
|
|
|
"</d:resourcetype>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<d:getcontentlength/>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"<d:response>"
|
|
|
|
"<d:href>/%C3%A4/%C3%A4.pdf</d:href>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
|
|
|
"<oc:permissions>RDNVW</oc:permissions>"
|
|
|
|
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
|
|
|
"<d:resourcetype/>"
|
|
|
|
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
|
|
|
"<d:getcontentlength>121780</d:getcontentlength>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 200 OK</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"<d:propstat>"
|
|
|
|
"<d:prop>"
|
|
|
|
"<oc:downloadURL/>"
|
|
|
|
"<oc:dDC/>"
|
|
|
|
"</d:prop>"
|
|
|
|
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
|
|
|
"</d:propstat>"
|
|
|
|
"</d:response>"
|
|
|
|
"</d:multistatus>";
|
|
|
|
|
|
|
|
LsColXMLParser parser;
|
|
|
|
|
2023-02-17 19:06:35 +03:00
|
|
|
connect( &parser, &LsColXMLParser::directoryListingSubfolders,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingSubFolders );
|
|
|
|
connect( &parser, &LsColXMLParser::directoryListingIterated,
|
|
|
|
this, &TestXmlParse::slotDirectoryListingIterated );
|
|
|
|
connect( &parser, &LsColXMLParser::finishedWithoutError,
|
|
|
|
this, &TestXmlParse::slotFinishedSuccessfully );
|
2015-05-07 18:19:14 +03:00
|
|
|
|
2018-06-22 14:04:32 +03:00
|
|
|
QHash <QString, ExtraFolderInfo> sizes;
|
2015-05-12 23:55:54 +03:00
|
|
|
QVERIFY(parser.parse( testXml, &sizes, QString::fromUtf8("/ä") ));
|
2015-05-07 18:19:14 +03:00
|
|
|
QVERIFY(_success);
|
|
|
|
|
2015-05-12 23:55:54 +03:00
|
|
|
QVERIFY(_items.contains(QString::fromUtf8("/ä/ä.pdf")));
|
|
|
|
QVERIFY(_items.contains(QString::fromUtf8("/ä")));
|
2015-05-07 18:19:14 +03:00
|
|
|
QVERIFY(_items.size() == 2 );
|
|
|
|
|
2015-05-12 23:55:54 +03:00
|
|
|
QVERIFY(_subdirs.contains(QString::fromUtf8("/ä")));
|
2015-05-07 18:19:14 +03:00
|
|
|
QVERIFY(_subdirs.size() == 1);
|
|
|
|
}
|
|
|
|
|
2015-04-14 09:37:06 +03:00
|
|
|
};
|
|
|
|
|
2016-05-11 02:17:16 +03:00
|
|
|
QTEST_GUILESS_MAIN(TestXmlParse)
|
|
|
|
|
2016-03-30 18:58:15 +03:00
|
|
|
#include "testxmlparse.moc"
|