Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[oauth] Fix build error in tests
  • Loading branch information
elpaso committed Jul 20, 2018
1 parent 2293065 commit d8ffdaa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 45 deletions.
47 changes: 16 additions & 31 deletions src/auth/oauth2/qgsauthoauth2edit.cpp
Expand Up @@ -128,7 +128,7 @@ QString QgsAuthOAuth2Edit::parentConfigId() const
return cie->configId();
}

// slot

void QgsAuthOAuth2Edit::setupConnections()
{
// Action and interaction connections
Expand Down Expand Up @@ -186,7 +186,7 @@ void QgsAuthOAuth2Edit::setupConnections()
}
}

// slot

void QgsAuthOAuth2Edit::configValidityChanged()
{
validateConfig();
Expand Down Expand Up @@ -471,14 +471,14 @@ void QgsAuthOAuth2Edit::updateTokenCacheFile( bool curpersist ) const
}
}

// slot

void QgsAuthOAuth2Edit::tabIndexChanged( int indx )
{
mCurTab = indx;
validateConfig();
}

// slot

void QgsAuthOAuth2Edit::populateGrantFlows()
{
cmbbxGrantFlow->addItem( QgsAuthOAuth2Config::grantFlowString( QgsAuthOAuth2Config::AuthCode ),
Expand All @@ -489,7 +489,7 @@ void QgsAuthOAuth2Edit::populateGrantFlows()
static_cast<int>( QgsAuthOAuth2Config::ResourceOwner ) );
}

// slot

void QgsAuthOAuth2Edit::definedCustomDirChanged( const QString &path )
{
QFileInfo pinfo( path );
Expand Down Expand Up @@ -518,7 +518,6 @@ void QgsAuthOAuth2Edit::softwareStatementJwtPathChanged( const QString &path )
}


// slot
void QgsAuthOAuth2Edit::setCurrentDefinedConfig( const QString &id )
{
mDefinedId = id;
Expand All @@ -539,7 +538,7 @@ void QgsAuthOAuth2Edit::currentDefinedItemChanged( QListWidgetItem *cur, QListWi
}
}

// slot

void QgsAuthOAuth2Edit::selectCurrentDefinedConfig()
{
if ( mDefinedId.isEmpty() )
Expand All @@ -566,7 +565,6 @@ void QgsAuthOAuth2Edit::selectCurrentDefinedConfig()
}
}

// slot
void QgsAuthOAuth2Edit::getDefinedCustomDir()
{
QString extradir = QFileDialog::getExistingDirectory( this, tr( "Select extra directory to parse" ),
Expand Down Expand Up @@ -640,15 +638,13 @@ void QgsAuthOAuth2Edit::removeTokenCacheFile()
btnTokenClear->setEnabled( hasTokenCacheFile() );
}

// slot
void QgsAuthOAuth2Edit::updateDefinedConfigsCache()
{
QString extradir = leDefinedDirPath->text();
mDefinedConfigsCache.clear();
mDefinedConfigsCache = QgsAuthOAuth2Config::mappedOAuth2ConfigsCache( this, extradir );
}

// slot
void QgsAuthOAuth2Edit::loadDefinedConfigs()
{
lstwdgDefinedConfigs->blockSignals( true );
Expand Down Expand Up @@ -716,7 +712,6 @@ bool QgsAuthOAuth2Edit::onStatementTab() const
return mCurTab == statementTab();
}

// slot
void QgsAuthOAuth2Edit::updateGrantFlow( int indx )
{
if ( cmbbxGrantFlow->currentIndex() != indx )
Expand Down Expand Up @@ -761,7 +756,7 @@ void QgsAuthOAuth2Edit::updateGrantFlow( int indx )
lePassword->setText( QString() );
}

// slot

void QgsAuthOAuth2Edit::exportOAuthConfig()
{
if ( !onCustomTab() || !mValid )
Expand Down Expand Up @@ -802,7 +797,7 @@ void QgsAuthOAuth2Edit::exportOAuthConfig()
mOAuthConfigCustom->setName( QString::null );
}

// slot

void QgsAuthOAuth2Edit::importOAuthConfig()
{
if ( !onCustomTab() )
Expand Down Expand Up @@ -847,13 +842,13 @@ void QgsAuthOAuth2Edit::importOAuthConfig()
loadConfig( configmap );
}

// slot

void QgsAuthOAuth2Edit::descriptionChanged()
{
mOAuthConfigCustom->setDescription( pteDescription->toPlainText() );
}

// slot

void QgsAuthOAuth2Edit::populateAccessMethods()
{
cmbbxAccessMethod->addItem( QgsAuthOAuth2Config::accessMethodString( QgsAuthOAuth2Config::Header ),
Expand All @@ -864,7 +859,7 @@ void QgsAuthOAuth2Edit::populateAccessMethods()
static_cast<int>( QgsAuthOAuth2Config::Query ) );
}

// slot

void QgsAuthOAuth2Edit::updateConfigAccessMethod( int indx )
{
mOAuthConfigCustom->setAccessMethod( static_cast<QgsAuthOAuth2Config::AccessMethod>( indx ) );
Expand All @@ -887,7 +882,7 @@ void QgsAuthOAuth2Edit::addQueryPairRow( const QString &key, const QString &val
tblwdgQueryPairs->setItem( rowCnt, 1, valItm );
}

// slot

void QgsAuthOAuth2Edit::populateQueryPairs( const QVariantMap &querypairs, bool append )
{
if ( !append )
Expand All @@ -903,7 +898,7 @@ void QgsAuthOAuth2Edit::populateQueryPairs( const QVariantMap &querypairs, bool
}
}

// slot

void QgsAuthOAuth2Edit::queryTableSelectionChanged()
{
bool hassel = tblwdgQueryPairs->selectedItems().count() > 0;
Expand All @@ -930,7 +925,7 @@ QVariantMap QgsAuthOAuth2Edit::queryPairs() const
return querypairs;
}

// slot

void QgsAuthOAuth2Edit::addQueryPair()
{
addQueryPairRow( QString(), QString() );
Expand All @@ -939,13 +934,13 @@ void QgsAuthOAuth2Edit::addQueryPair()
tblwdgQueryPairs->edit( tblwdgQueryPairs->currentIndex() );
}

// slot

void QgsAuthOAuth2Edit::removeQueryPair()
{
tblwdgQueryPairs->removeRow( tblwdgQueryPairs->currentRow() );
}

// slot

void QgsAuthOAuth2Edit::clearQueryPairs()
{
for ( int i = tblwdgQueryPairs->rowCount(); i > 0 ; --i )
Expand Down Expand Up @@ -1149,13 +1144,3 @@ void QgsAuthOAuth2Edit::getSoftwareStatementConfig()
}
}

QString QgsAuthOAuth2Edit::registrationEndpoint() const
{
return mRegistrationEndpoint;
}

void QgsAuthOAuth2Edit::setRegistrationEndpoint( const QString &registrationEndpoint )
{
mRegistrationEndpoint = registrationEndpoint;
}

6 changes: 0 additions & 6 deletions src/auth/oauth2/qgsauthoauth2edit.h
Expand Up @@ -126,12 +126,6 @@ class QgsAuthOAuth2Edit : public QgsAuthMethodEdit, private Ui::QgsAuthOAuth2Edi

void networkError( QNetworkReply::NetworkError error );

//! For testability
QString registrationEndpoint() const;

//! For testability
void setRegistrationEndpoint( const QString &registrationEndpoint );

private:

void initGui();
Expand Down
16 changes: 8 additions & 8 deletions tests/src/auth/testqgsauthoauth2method.cpp
Expand Up @@ -415,8 +415,8 @@ void TestQgsAuthOAuth2Method::testDynamicRegistrationNoEndpoint()
config->setClientId( QString( ) );
config->setClientSecret( QString( ) );
QVariantMap configMap( config->mappedProperties() );
QCOMPARE( configMap["clientId"], QString() );
QCOMPARE( configMap["clientSecret"], QString() );
QCOMPARE( configMap["clientId"].toString(), QString() );
QCOMPARE( configMap["clientSecret"].toString(), QString() );
QgsAuthOAuth2Edit dlg;
QgsStringMap stringMap;
for ( const auto &k : configMap.keys( ) )
Expand All @@ -439,8 +439,8 @@ void TestQgsAuthOAuth2Method::testDynamicRegistration()
config->setClientId( QString( ) );
config->setClientSecret( QString( ) );
QVariantMap configMap( config->mappedProperties() );
QCOMPARE( configMap["clientId"], QString() );
QCOMPARE( configMap["clientSecret"], QString() );
QCOMPARE( configMap["clientId"].toString(), QString() );
QCOMPARE( configMap["clientSecret"].toString(), QString() );
QgsAuthOAuth2Edit dlg;
QgsStringMap stringMap;
for ( const auto &k : configMap.keys( ) )
Expand All @@ -459,7 +459,7 @@ void TestQgsAuthOAuth2Method::testDynamicRegistration()
dlg.leSoftwareStatementConfigUrl->setText( QUrl::fromLocalFile( QStringLiteral( "%1/auth_code_grant_display_code_get_config.json" ).arg( sTestDataDir ) ).toString( ) );
QVERIFY( dlg.btnRegister->isEnabled() );
// Change it to something local
dlg.setRegistrationEndpoint( QUrl::fromLocalFile( QStringLiteral( "%1/client_information_registration_response.json" ).arg( sTestDataDir ) ).toString() );
dlg.mRegistrationEndpoint = QUrl::fromLocalFile( QStringLiteral( "%1/client_information_registration_response.json" ).arg( sTestDataDir ) ).toString();
QTest::mouseClick( dlg.btnRegister, Qt::MouseButton::LeftButton );
while ( dlg.mDownloading )
{
Expand All @@ -476,8 +476,8 @@ void TestQgsAuthOAuth2Method::testDynamicRegistrationJwt()
config->setClientId( QString( ) );
config->setClientSecret( QString( ) );
QVariantMap configMap( config->mappedProperties() );
QCOMPARE( configMap["clientId"], QString() );
QCOMPARE( configMap["clientSecret"], QString() );
QCOMPARE( configMap["clientId"].toString(), QString() );
QCOMPARE( configMap["clientSecret"].toString(), QString() );
QgsAuthOAuth2Edit dlg;
QgsStringMap stringMap;
for ( const auto &k : configMap.keys( ) )
Expand All @@ -493,7 +493,7 @@ void TestQgsAuthOAuth2Method::testDynamicRegistrationJwt()
QCOMPARE( dlg.leSoftwareStatementConfigUrl->text(), QStringLiteral( "http://www.qgis.org/oauth2/registration" ) );
QVERIFY( dlg.btnRegister->isEnabled() );
// Change it to something local
dlg.setRegistrationEndpoint( QUrl::fromLocalFile( QStringLiteral( "%1/client_information_registration_response.json" ).arg( sTestDataDir ) ).toString() );
dlg.mRegistrationEndpoint = QUrl::fromLocalFile( QStringLiteral( "%1/client_information_registration_response.json" ).arg( sTestDataDir ) ).toString();
QTest::mouseClick( dlg.btnRegister, Qt::MouseButton::LeftButton );
while ( dlg.mDownloading )
{
Expand Down

0 comments on commit d8ffdaa

Please sign in to comment.