Skip to content
Permalink
Browse files

Add a test case for unwriteable folders in file downloader

Attempt to verify bug 17410 Identify tool->download in a not authorised folder block qgis

The test passes, so let's push it in, I'll continue
to investigate if there is an issue in the GUI logic.
  • Loading branch information
elpaso committed Nov 8, 2017
1 parent e781ad2 commit f06ea878b869f4f2baf2818ac1b4700eceaf3567
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/src/gui/testqgsfiledownloader.cpp
@@ -17,6 +17,7 @@
#include "qgstest.h"
#include <QObject>
#include <QTemporaryFile>
#include <QTemporaryDir>
#include <QUrl>
#include <QEventLoop>
#include <QTimer>
@@ -73,6 +74,7 @@ class TestQgsFileDownloader: public QObject
void testCanceledDownload();
void testInvalidUrl();
void testBlankUrl();
void testLacksWritePermissionsError();
#ifndef QT_NO_SSL
void testSslError_data();
void testSslError();
@@ -236,6 +238,22 @@ void TestQgsFileDownloader::testSslError()
QVERIFY( !mCanceled );
}

void TestQgsFileDownloader::testLacksWritePermissionsError()
{
QTemporaryDir dir;
QFile tmpDir( dir.path( ) );
tmpDir.setPermissions( tmpDir.permissions() & !( QFile::Permission::WriteGroup | QFile::Permission::WriteUser | QFile::Permission::WriteOther | QFile::Permission::WriteOwner ) );
QVERIFY( ! tmpDir.isWritable() );
QString fileName( dir.path() + '/' + QStringLiteral( "tmp.bin" ) );
makeCall( QUrl( QStringLiteral( "http://www.qgis.org" ) ), fileName );
QVERIFY( mExited );
QVERIFY( !mCompleted );
QVERIFY( mError );
QVERIFY( !mCanceled );
QVERIFY( ! QFileInfo( fileName ).exists( ) );
}


#endif


0 comments on commit f06ea87

Please sign in to comment.
You can’t perform that action at this time.