Skip to content
Permalink
Browse files

add QgsCredentialsNone to not return any credentials and make it defa…

…ult instead of QgsCredentialsConsole (fixes #14269; reverts f8d2091)
  • Loading branch information
jef-n committed Feb 16, 2016
1 parent 14f9a88 commit 42bc93870078d5098a391a08670af4b97979e764
Showing with 47 additions and 3 deletions.
  1. +25 −1 src/core/qgscredentials.cpp
  2. +22 −0 src/core/qgscredentials.h
  3. +0 −2 tests/src/python/test_provider_postgres.py
@@ -35,7 +35,7 @@ QgsCredentials *QgsCredentials::instance()
if ( smInstance )
return smInstance;

return new QgsCredentialsConsole();
return new QgsCredentialsNone();
}

QgsCredentials::QgsCredentials()
@@ -98,6 +98,30 @@ void QgsCredentials::unlock()
}


////////////////////////////////
// QgsCredentialsNone

QgsCredentialsNone::QgsCredentialsNone()
{
setInstance( this );
}

bool QgsCredentialsNone::request( const QString& realm, QString &username, QString &password, const QString& message )
{
Q_UNUSED( realm );
Q_UNUSED( username );
Q_UNUSED( password );
Q_UNUSED( message );
return false;
}

bool QgsCredentialsNone::requestMasterPassword( QString &password, bool stored )
{
Q_UNUSED( password );
Q_UNUSED( stored );
return false;
}

////////////////////////////////
// QgsCredentialsConsole

@@ -96,6 +96,28 @@ class CORE_EXPORT QgsCredentials
/**
\brief Default implementation of credentials interface
This class doesn't prompt or return credentials
*/
class CORE_EXPORT QgsCredentialsNone : public QObject, public QgsCredentials
{
Q_OBJECT

public:
QgsCredentialsNone();

signals:
//! signals that object will be destroyed and shouldn't be used anymore
void destroyed();

protected:
virtual bool request( const QString& realm, QString &username, QString &password, const QString& message = QString::null ) override;
virtual bool requestMasterPassword( QString &password, bool stored = false ) override;
};


/**
\brief Implementation of credentials interface for the console
This class outputs message to the standard output and retrieves input from
standard input. Therefore it won't be the right choice for apps without
GUI.
@@ -33,8 +33,6 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
os.close(0) # avoid credential requests

cls.dbconn = u'dbname=\'qgis_test\''
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']

0 comments on commit 42bc938

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