diff --git a/.gitignore b/.gitignore index ba8bc11..ecf3682 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ tmp commit-message.txt moc_* *.o -tests/ut_qoauth/ut_qoauth -tests/ft_qoauth/ft_qoauth +tests/ut_interface/ut_interface +tests/ft_interface/ft_interface +doc/html diff --git a/CHANGELOG b/CHANGELOG index 6e46ba4..7f62124 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,11 @@ -v 0.1.0 (23/06/2009): +v1.0 (07/08/2009): +* Added support for RSA-SHA1 signing algorithm, also working with + passphrase-protected private RSA keys. +* Added initial support for PLAINTEXT authorization. +* inlineParameters() extended by the parameter specifying parsing method, +* Introduced the QOAuth namespace, with QOAuth::Interface class holding the core + functionality. +v0.1.0 (23/06/2009): * Initial release of the QOAuth library, implementation of the OAuth authorization flow with support for encrypting QOAuth requests using HMAC-SHA1 algorithm. \ No newline at end of file diff --git a/README b/README index f407219..2a72169 100644 --- a/README +++ b/README @@ -9,10 +9,10 @@ developer no more than 4 methods, namely: * inlineParemeters() - to construct a query string basing on given parameters (provided only for convenience). -First two methods serve application authorization purposes, whilst the third one -is used for accessing Protected Resources. The complete documentation is +First two methods serve application authorization purposes, whilst the other two +are used for accessing Protected Resources. The complete documentation is available locally as well as online: - http://files.ayoy.net/qoauth/doc + http://files.ayoy.net/qoauth/1.0/doc QOAuth internally makes use of QCA (Qt Cryptographic Architecture). Here is the complete list of its dependencies: diff --git a/doc/examples/requestToken.cpp b/doc/examples/requestToken.cpp index 1806aed..3458c87 100644 --- a/doc/examples/requestToken.cpp +++ b/doc/examples/requestToken.cpp @@ -1,7 +1,7 @@ QByteArray token; QByteArray tokenSecret; -QOAuth::QOAuth qoauth = new QOAuth::QOAuth; +QOAuth::Interface qoauth = new QOAuth::Interface; // set the consumer key and secret qoauth->setConsumerKey( "75b3d557c9268c49cfdf041a" ); qoauth->setConsumerSecret( "fd12803fbf0760d34cd2ceb9955199ce" ); diff --git a/include/QtOAuth b/include/QtOAuth index 4606529..f9c711d 100644 --- a/include/QtOAuth +++ b/include/QtOAuth @@ -1 +1 @@ -#include "qoauth.h" +#include "interface.h" diff --git a/include/interface.h b/include/interface.h new file mode 100644 index 0000000..2a540a8 --- /dev/null +++ b/include/interface.h @@ -0,0 +1 @@ +#include "../src/interface.h" diff --git a/qoauth.pro b/qoauth.pro index 5508d22..10ac97d 100644 --- a/qoauth.pro +++ b/qoauth.pro @@ -9,7 +9,7 @@ check.target = check # and depends also on an external server. When using in an automatic # build environment, it's recommended not to run the functional test. -isEmpty(FUNC_TEST): check.commands = cd tests/ut_qoauth && ./ut_qoauth -else: check.commands = ( cd tests/ut_qoauth && ./ut_qoauth ) && ( cd tests/ft_qoauth && ./ft_qoauth ) +isEmpty(FUNC_TEST): check.commands = cd tests/ut_interface && ./ut_interface +else: check.commands = ( cd tests/ut_interface && ./ut_interface ) && ( cd tests/ft_interface && ./ft_interface ) check.depends = sub-tests QMAKE_EXTRA_TARGETS += check diff --git a/src/qoauth.cpp b/src/interface.cpp similarity index 84% rename from src/qoauth.cpp rename to src/interface.cpp index db616d1..0ebe4b3 100644 --- a/src/qoauth.cpp +++ b/src/interface.cpp @@ -18,8 +18,8 @@ ***************************************************************************/ -#include "qoauth.h" -#include "qoauth_p.h" +#include "interface.h" +#include "interface_p.h" #include @@ -39,7 +39,7 @@ \section sec_what What is the purpose of QOAuth? The main motivation to create this library was to provide an interface to OAuth - protocoll for (Qt-based) C++ applications in an easy way. This is very early version + protocol for (Qt-based) C++ applications in an easy way. This is very early version of the library, and it lacks some functionality, but in the same time it is capable of sending OAuth authorization requests as well as preparing requests for accessing User's Protected Resources. @@ -90,6 +90,8 @@ \verbatim #include \endverbatim + \b Note: This follows the Qt scheme, i.e. QT += xml ==> #include , etc. + \section sec_bugs Bugs and issues Please file all the bug reports to the QOAuth bug tracking system at @@ -101,11 +103,11 @@ */ /*! - \class QOAuth::QOAuth qoauth.h + \class QOAuth::Interface interface.h \brief This class provides means for interaction with network services supporting OAuth authorization scheme. - The QOAuth class is meant to enable OAuth support in applications in as simple way + The QOAuth::Interface class is meant to enable OAuth support in applications in as simple way as possible. It provides 4 basic methods, two of which serve for authorization purposes: \li \ref requestToken(), \li \ref accessToken(), @@ -155,8 +157,8 @@ In order to access Protected Resources, the application has to send a request containing arguments including Customer Key and Access Token, and encrypt them with Customer Secret and Token Secret. The process of constructing such a request can be reduced to another - one-line call with QOAuth. The example code for inlining all request parameters (both - User-specific and OAuth-related): + one-line call with QOAuth::Interface. The example code for inlining all request parameters + (both User-specific and OAuth-related): \include getResources.cpp @@ -175,42 +177,42 @@ QByteArray QOAuth::supportedOAuthVersion() { - return QOAuthPrivate::OAuthVersion; + return InterfacePrivate::OAuthVersion; } QByteArray QOAuth::tokenParameterName() { - return QOAuthPrivate::ParamToken; + return InterfacePrivate::ParamToken; } QByteArray QOAuth::tokenSecretParameterName() { - return QOAuthPrivate::ParamTokenSecret; + return InterfacePrivate::ParamTokenSecret; } //! \brief The supported OAuth scheme version. -const QByteArray QOAuth::QOAuthPrivate::OAuthVersion = "1.0"; +const QByteArray QOAuth::InterfacePrivate::OAuthVersion = "1.0"; //! \brief The token request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamToken = "oauth_token"; +const QByteArray QOAuth::InterfacePrivate::ParamToken = "oauth_token"; //! \brief The token secret request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamTokenSecret = "oauth_token_secret"; +const QByteArray QOAuth::InterfacePrivate::ParamTokenSecret = "oauth_token_secret"; //! \brief The consumer key request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamConsumerKey = "oauth_consumer_key"; +const QByteArray QOAuth::InterfacePrivate::ParamConsumerKey = "oauth_consumer_key"; //! \brief The nonce request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamNonce = "oauth_nonce"; +const QByteArray QOAuth::InterfacePrivate::ParamNonce = "oauth_nonce"; //! \brief The signature request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamSignature = "oauth_signature"; +const QByteArray QOAuth::InterfacePrivate::ParamSignature = "oauth_signature"; //! \brief The signature method request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamSignatureMethod = "oauth_signature_method"; +const QByteArray QOAuth::InterfacePrivate::ParamSignatureMethod = "oauth_signature_method"; //! \brief The timestamp request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamTimestamp = "oauth_timestamp"; +const QByteArray QOAuth::InterfacePrivate::ParamTimestamp = "oauth_timestamp"; //! \brief The version request parameter string -const QByteArray QOAuth::QOAuthPrivate::ParamVersion = "oauth_version"; +const QByteArray QOAuth::InterfacePrivate::ParamVersion = "oauth_version"; -QOAuth::QOAuthPrivate::QOAuthPrivate( QObject *parent ) : +QOAuth::InterfacePrivate::InterfacePrivate( QObject *parent ) : QObject( parent ), privateKeySet( false ), consumerKey( QByteArray() ), @@ -228,7 +230,7 @@ QOAuth::QOAuthPrivate::QOAuthPrivate( QObject *parent ) : } -QByteArray QOAuth::QOAuthPrivate::httpMethodToString( HttpMethod method ) +QByteArray QOAuth::InterfacePrivate::httpMethodToString( HttpMethod method ) { switch ( method ) { case GET: @@ -247,7 +249,7 @@ QByteArray QOAuth::QOAuthPrivate::httpMethodToString( HttpMethod method ) } } -QByteArray QOAuth::QOAuthPrivate::signatureMethodToString( SignatureMethod method ) +QByteArray QOAuth::InterfacePrivate::signatureMethodToString( SignatureMethod method ) { switch ( method ) { case HMAC_SHA1: @@ -262,7 +264,7 @@ QByteArray QOAuth::QOAuthPrivate::signatureMethodToString( SignatureMethod metho } } -QOAuth::ParamMap QOAuth::QOAuthPrivate::replyToMap( const QByteArray &data ) +QOAuth::ParamMap QOAuth::InterfacePrivate::replyToMap( const QByteArray &data ) { // split reply to name=value strings QList replyParams = data.split( '&' ); @@ -286,17 +288,17 @@ QOAuth::ParamMap QOAuth::QOAuthPrivate::replyToMap( const QByteArray &data ) return parameters; } -void QOAuth::QOAuthPrivate::parseReply( QNetworkReply *reply ) +void QOAuth::InterfacePrivate::parseReply( QNetworkReply *reply ) { int returnCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt(); switch ( returnCode ) { case NoError: replyParams = replyToMap( reply->readAll() ); - if ( !replyParams.contains( QOAuthPrivate::ParamToken ) ) { + if ( !replyParams.contains( InterfacePrivate::ParamToken ) ) { qWarning() << __FUNCTION__ << "- oauth_token not present in reply!"; } - if ( !replyParams.contains( QOAuthPrivate::ParamTokenSecret ) ) { + if ( !replyParams.contains( InterfacePrivate::ParamTokenSecret ) ) { qWarning() << __FUNCTION__ << "- oauth_token_secret not present in reply!"; } @@ -312,7 +314,7 @@ void QOAuth::QOAuthPrivate::parseReply( QNetworkReply *reply ) reply->close(); } -QByteArray QOAuth::QOAuthPrivate::paramsToString( const ParamMap ¶meters, ParsingMode mode ) +QByteArray QOAuth::InterfacePrivate::paramsToString( const ParamMap ¶meters, ParsingMode mode ) { QByteArray middleString; QByteArray endString; @@ -364,29 +366,29 @@ QByteArray QOAuth::QOAuthPrivate::paramsToString( const ParamMap ¶meters, Pa /*! - \brief Creates a new QOAuth class instance with the given \a parent + \brief Creates a new QOAuth::Interface class instance with the given \a parent */ -QOAuth::QOAuth::QOAuth( QObject *parent ) : +QOAuth::Interface::Interface( QObject *parent ) : QObject( parent ), - d_ptr( new QOAuthPrivate( this ) ) + d_ptr( new InterfacePrivate( this ) ) { - Q_D(QOAuth); + Q_D(Interface); d->q_ptr = this; } /*! - \brief Destroys the QOAuth object + \brief Destroys the QOAuth::Interface object */ -QOAuth::QOAuth::~QOAuth() +QOAuth::Interface::~Interface() { delete d_ptr; } /*! - \property QOAuth::QOAuth::consumerKey + \property QOAuth::Interface::consumerKey \brief This property holds the consumer key The consumer key is used by the application to identify itself to the Service Provider. @@ -396,22 +398,22 @@ QOAuth::QOAuth::~QOAuth() \li void setConsumerKey( const QByteArray &consumerKey ) */ -QByteArray QOAuth::QOAuth::consumerKey() const +QByteArray QOAuth::Interface::consumerKey() const { - Q_D(const QOAuth); + Q_D(const Interface); return d->consumerKey; } -void QOAuth::QOAuth::setConsumerKey( const QByteArray &consumerKey ) +void QOAuth::Interface::setConsumerKey( const QByteArray &consumerKey ) { - Q_D(QOAuth); + Q_D(Interface); d->consumerKey = consumerKey; } /*! - \property QOAuth::QOAuth::consumerSecret + \property QOAuth::Interface::consumerSecret \brief This property holds the consumer secret The consumerSecret is used by the application for signing outgoing requests. @@ -421,25 +423,25 @@ void QOAuth::QOAuth::setConsumerKey( const QByteArray &consumerKey ) \li void setConsumerSecret( const QByteArray &consumerSecret ) */ -QByteArray QOAuth::QOAuth::consumerSecret() const +QByteArray QOAuth::Interface::consumerSecret() const { - Q_D(const QOAuth); + Q_D(const Interface); return d->consumerSecret; } -void QOAuth::QOAuth::setConsumerSecret( const QByteArray &consumerSecret ) +void QOAuth::Interface::setConsumerSecret( const QByteArray &consumerSecret ) { - Q_D(QOAuth); + Q_D(Interface); d->consumerSecret = consumerSecret; } /*! - \property QOAuth::QOAuth::requestTimeout + \property QOAuth::Interface::requestTimeout \brief This property holds the timeout value in milliseconds for issued network requests. - The QOAuth class can send network requests when asked to do so by calling either + The QOAuth::Interface class can send network requests when asked to do so by calling either requestToken() or accessToken() method. By defining the \a requestTimeout, requests can have the time constraint applied, after which they fail, setting \ref error to \ref Timeout. The \a requestTimeout value is initially set to \c 0, which in this @@ -450,23 +452,23 @@ void QOAuth::QOAuth::setConsumerSecret( const QByteArray &consumerSecret ) \li void setRequestTimeout( uint requestTimeout ) */ -uint QOAuth::QOAuth::requestTimeout() const +uint QOAuth::Interface::requestTimeout() const { - Q_D(const QOAuth); + Q_D(const Interface); return d->requestTimeout; } -void QOAuth::QOAuth::setRequestTimeout( uint msec ) +void QOAuth::Interface::setRequestTimeout( uint msec ) { - Q_D(QOAuth); + Q_D(Interface); d->requestTimeout = msec; } /*! - \property QOAuth::QOAuth::error + \property QOAuth::Interface::error \brief This property holds the error code The error code is initially set to \ref NoError, and its value is updated with every @@ -478,9 +480,9 @@ void QOAuth::QOAuth::setRequestTimeout( uint msec ) \sa ErrorCode */ -int QOAuth::QOAuth::error() const +int QOAuth::Interface::error() const { - Q_D(const QOAuth); + Q_D(const Interface); return d->error; } @@ -499,11 +501,11 @@ int QOAuth::QOAuth::error() const \sa setRSAPrivateKeyFromFile() */ -bool QOAuth::QOAuth::setRSAPrivateKey( const QString &key, const QCA::SecureArray &passphrase ) +bool QOAuth::Interface::setRSAPrivateKey( const QString &key, const QCA::SecureArray &passphrase ) { - Q_D(QOAuth); + Q_D(Interface); - d->setPrivateKey( key, passphrase, QOAuthPrivate::KeyFromString ); + d->setPrivateKey( key, passphrase, InterfacePrivate::KeyFromString ); return ( d->error == NoError ); } @@ -523,21 +525,21 @@ bool QOAuth::QOAuth::setRSAPrivateKey( const QString &key, const QCA::SecureArra \sa setRSAPrivateKey() */ -bool QOAuth::QOAuth::setRSAPrivateKeyFromFile( const QString &filename, const QCA::SecureArray &passphrase ) +bool QOAuth::Interface::setRSAPrivateKeyFromFile( const QString &filename, const QCA::SecureArray &passphrase ) { - Q_D(QOAuth); + Q_D(Interface); if ( ! QFileInfo( filename ).exists() ) { d->error = RSAKeyFileError; qWarning() << __FUNCTION__ << "- the given file does not exist..."; } else { - d->setPrivateKey( filename, passphrase, QOAuthPrivate::KeyFromFile ); + d->setPrivateKey( filename, passphrase, InterfacePrivate::KeyFromFile ); } return ( d->error == NoError ); } -void QOAuth::QOAuthPrivate::setPrivateKey( const QString &source, +void QOAuth::InterfacePrivate::setPrivateKey( const QString &source, const QCA::SecureArray &passphrase, KeySource from ) { @@ -568,7 +570,7 @@ void QOAuth::QOAuthPrivate::setPrivateKey( const QString &source, readKeyFromLoader( &keyLoader ); } -void QOAuth::QOAuthPrivate::readKeyFromLoader( QCA::KeyLoader *keyLoader ) +void QOAuth::InterfacePrivate::readKeyFromLoader( QCA::KeyLoader *keyLoader ) { QCA::ConvertResult result = keyLoader->convertResult(); if ( result == QCA::ConvertGood ) { @@ -585,7 +587,7 @@ void QOAuth::QOAuthPrivate::readKeyFromLoader( QCA::KeyLoader *keyLoader ) } } -void QOAuth::QOAuthPrivate::setPassphrase( int id, const QCA::Event &event ) +void QOAuth::InterfacePrivate::setPassphrase( int id, const QCA::Event &event ) { if ( event.isNull() ) { return; @@ -594,7 +596,7 @@ void QOAuth::QOAuthPrivate::setPassphrase( int id, const QCA::Event &event ) // we're looking only for the passphrase for the RSA key if ( event.type() == QCA::Event::Password && event.passwordStyle() == QCA::Event::StylePassphrase ) { - // set the passphrase to the one provided with QOAuth::QOAuth::setRSAPrivateKey{,FromFile}() + // set the passphrase to the one provided with QOAuth::Interface::setRSAPrivateKey{,FromFile}() eventHandler.submitPassword( id, passphrase ); } else { eventHandler.reject( id ); @@ -637,10 +639,10 @@ void QOAuth::QOAuthPrivate::setPassphrase( int id, const QCA::Event &event ) \sa accessToken(), error */ -QOAuth::ParamMap QOAuth::QOAuth::requestToken( const QString &requestUrl, HttpMethod httpMethod, +QOAuth::ParamMap QOAuth::Interface::requestToken( const QString &requestUrl, HttpMethod httpMethod, SignatureMethod signatureMethod, const ParamMap ¶ms ) { - Q_D(QOAuth); + Q_D(Interface); return d->sendRequest( requestUrl, httpMethod, signatureMethod, QByteArray(), QByteArray(), params ); @@ -686,11 +688,11 @@ QOAuth::ParamMap QOAuth::QOAuth::requestToken( const QString &requestUrl, HttpMe \sa requestToken(), createParametersString(), error */ -QOAuth::ParamMap QOAuth::QOAuth::accessToken( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token, +QOAuth::ParamMap QOAuth::Interface::accessToken( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token, const QByteArray &tokenSecret, SignatureMethod signatureMethod, const ParamMap ¶ms ) { - Q_D(QOAuth); + Q_D(Interface); return d->sendRequest( requestUrl, httpMethod, signatureMethod, token, tokenSecret, params ); @@ -731,11 +733,11 @@ QOAuth::ParamMap QOAuth::QOAuth::accessToken( const QString &requestUrl, HttpMet \sa inlineParameters() */ -QByteArray QOAuth::QOAuth::createParametersString( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token, +QByteArray QOAuth::Interface::createParametersString( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token, const QByteArray &tokenSecret, SignatureMethod signatureMethod, const ParamMap ¶ms, ParsingMode mode ) { - Q_D(QOAuth); + Q_D(Interface); d->error = NoError; @@ -751,7 +753,7 @@ QByteArray QOAuth::QOAuth::createParametersString( const QString &requestUrl, Ht } // append it to parameters - parameters.insert( QOAuthPrivate::ParamSignature, signature ); + parameters.insert( InterfacePrivate::ParamSignature, signature ); // convert the map to bytearray, according to requested mode QByteArray parametersString = d->paramsToString( parameters, mode ); @@ -776,9 +778,9 @@ QByteArray QOAuth::QOAuth::createParametersString( const QString &requestUrl, Ht \sa createParametersString() */ -QByteArray QOAuth::QOAuth::inlineParameters( const ParamMap ¶ms, ParsingMode mode ) +QByteArray QOAuth::Interface::inlineParameters( const ParamMap ¶ms, ParsingMode mode ) { - Q_D(QOAuth); + Q_D(Interface); QByteArray query; @@ -795,7 +797,7 @@ QByteArray QOAuth::QOAuth::inlineParameters( const ParamMap ¶ms, ParsingMode return query; } -QOAuth::ParamMap QOAuth::QOAuthPrivate::sendRequest( const QString &requestUrl, HttpMethod httpMethod, +QOAuth::ParamMap QOAuth::InterfacePrivate::sendRequest( const QString &requestUrl, HttpMethod httpMethod, SignatureMethod signatureMethod, const QByteArray &token, const QByteArray &tokenSecret, const ParamMap ¶ms ) { @@ -819,7 +821,7 @@ QOAuth::ParamMap QOAuth::QOAuthPrivate::sendRequest( const QString &requestUrl, } // add signature to parameters - parameters.insert( QOAuthPrivate::ParamSignature, signature ); + parameters.insert( InterfacePrivate::ParamSignature, signature ); QByteArray authorizationHeader; QNetworkRequest request; @@ -840,7 +842,7 @@ QOAuth::ParamMap QOAuth::QOAuthPrivate::sendRequest( const QString &requestUrl, if ( requestTimeout > 0 ) { QTimer::singleShot( requestTimeout, loop, SLOT(quit()) ); // if the request finishes on time, the error value is overriden - // if not, it remains equal to QOAuth::QOAuth::Timeout + // if not, it remains equal to QOAuth::Interface::Timeout error = Timeout; } @@ -856,7 +858,7 @@ QOAuth::ParamMap QOAuth::QOAuthPrivate::sendRequest( const QString &requestUrl, // start the event loop and wait for the response loop->exec(); - // if request completed successfully, error is different than QOAuth::QOAuth::Timeout + // if request completed successfully, error is different than QOAuth::Interface::Timeout // if it failed, we have to abort the request if ( error == Timeout ) { reply->abort(); @@ -865,7 +867,7 @@ QOAuth::ParamMap QOAuth::QOAuthPrivate::sendRequest( const QString &requestUrl, return replyParams; } -QByteArray QOAuth::QOAuthPrivate::createSignature( const QString &requestUrl, HttpMethod httpMethod, +QByteArray QOAuth::InterfacePrivate::createSignature( const QString &requestUrl, HttpMethod httpMethod, SignatureMethod signatureMethod, const QByteArray &token, const QByteArray &tokenSecret, ParamMap *params ) { @@ -873,13 +875,13 @@ QByteArray QOAuth::QOAuthPrivate::createSignature( const QString &requestUrl, Ht signatureMethod == RSA_SHA1 ) && consumerKey.isEmpty() ) { qWarning() << __FUNCTION__ << "- consumer key is empty, make sure that you set it" - "with QOAuth::QOAuth::setConsumerKey()"; + "with QOAuth::Interface::setConsumerKey()"; error = ConsumerKeyEmpty; return QByteArray(); } if ( consumerSecret.isEmpty() ) { qWarning() << __FUNCTION__ << "- consumer secret is empty, make sure that you set it" - "with QOAuth::QOAuth::setConsumerSecret()"; + "with QOAuth::Interface::setConsumerSecret()"; error = ConsumerSecretEmpty; return QByteArray(); } @@ -887,7 +889,7 @@ QByteArray QOAuth::QOAuthPrivate::createSignature( const QString &requestUrl, Ht if ( signatureMethod == RSA_SHA1 && privateKey.isNull() ) { qWarning() << __FUNCTION__ << "- RSA private key is empty, make sure that you provide it" - "with QOAuth::QOAuth::setRSAPrivateKey{,FromFile}()"; + "with QOAuth::Interface::setRSAPrivateKey{,FromFile}()"; error = RSAPrivateKeyEmpty; return QByteArray(); } @@ -906,15 +908,15 @@ QByteArray QOAuth::QOAuthPrivate::createSignature( const QString &requestUrl, Ht // 2. prepare percent-encoded request URL QByteArray percentRequestUrl = requestUrl.toAscii().toPercentEncoding(); // 3. prepare percent-encoded parameters string - params->insert( QOAuthPrivate::ParamConsumerKey, consumerKey ); - params->insert( QOAuthPrivate::ParamNonce, nonce ); - params->insert( QOAuthPrivate::ParamSignatureMethod, + params->insert( InterfacePrivate::ParamConsumerKey, consumerKey ); + params->insert( InterfacePrivate::ParamNonce, nonce ); + params->insert( InterfacePrivate::ParamSignatureMethod, signatureMethodToString( signatureMethod ) ); - params->insert( QOAuthPrivate::ParamTimestamp, timestamp ); - params->insert( QOAuthPrivate::ParamVersion, QOAuthPrivate::OAuthVersion ); + params->insert( InterfacePrivate::ParamTimestamp, timestamp ); + params->insert( InterfacePrivate::ParamVersion, InterfacePrivate::OAuthVersion ); // append token only if it is defined (requestToken() doesn't use a token at all) if ( !token.isEmpty() ) { - params->insert( QOAuthPrivate::ParamToken, token ); + params->insert( InterfacePrivate::ParamToken, token ); } QByteArray parametersString = paramsToString( *params, ParseForSignatureBaseString ); @@ -959,11 +961,11 @@ QByteArray QOAuth::QOAuthPrivate::createSignature( const QString &requestUrl, Ht return signature; } -QByteArray QOAuth::QOAuthPrivate::createPlaintextSignature( const QByteArray &tokenSecret ) +QByteArray QOAuth::InterfacePrivate::createPlaintextSignature( const QByteArray &tokenSecret ) { if ( consumerSecret.isEmpty() ) { qWarning() << __FUNCTION__ << "- consumer secret is empty, make sure that you set it" - "with QOAuth::QOAuth::setConsumerSecret()"; + "with QOAuth::Interface::setConsumerSecret()"; error = ConsumerSecretEmpty; return QByteArray(); } diff --git a/include/qoauth.h b/src/interface.h similarity index 90% rename from include/qoauth.h rename to src/interface.h index b137f7a..d5c9c40 100644 --- a/include/qoauth.h +++ b/src/interface.h @@ -19,14 +19,14 @@ /*! - \file qoauth.h + \file interface.h This file is a part of libqoauth. You should not include it directly in your application. Instead please use \#include <QtOAuth>. */ -#ifndef QOAUTH_H -#define QOAUTH_H +#ifndef INTERFACE_H +#define INTERFACE_H #include #include @@ -39,9 +39,9 @@ namespace QOAuth { -class QOAuthPrivate; +class InterfacePrivate; -class QOAUTH_EXPORT QOAuth : public QObject +class QOAUTH_EXPORT Interface : public QObject { Q_OBJECT @@ -51,8 +51,8 @@ class QOAUTH_EXPORT QOAuth : public QObject Q_PROPERTY( int error READ error ) public: - QOAuth( QObject *parent = 0 ); - virtual ~QOAuth(); + Interface( QObject *parent = 0 ); + virtual ~Interface(); QByteArray consumerKey() const; void setConsumerKey( const QByteArray &consumerKey ); @@ -87,17 +87,18 @@ class QOAUTH_EXPORT QOAuth : public QObject protected: - QOAuthPrivate * const d_ptr; + InterfacePrivate * const d_ptr; -private: - Q_DECLARE_PRIVATE(QOAuth) +private: + Q_DISABLE_COPY(Interface) + Q_DECLARE_PRIVATE(Interface) #ifdef UNIT_TEST - friend class Ut_QOAuth; - friend class Ft_QOAuth; + friend class Ut_Interface; + friend class Ft_Interface; #endif }; } // namespace QOAuth -#endif // QOAUTH_H +#endif // INTERFACE_H diff --git a/include/qoauth_p.h b/src/interface_p.h similarity index 94% rename from include/qoauth_p.h rename to src/interface_p.h index db88362..a1940e8 100644 --- a/include/qoauth_p.h +++ b/src/interface_p.h @@ -19,7 +19,7 @@ /*! - \file qoauth_p.h + \file interface_p.h This file is a part of libqoauth and is considered strictly internal. You should not include it in your application. Instead please use \#include <QtOAuth>. @@ -28,7 +28,7 @@ #ifndef QOAUTH_P_H #define QOAUTH_P_H -#include "qoauth.h" +#include "interface.h" #include class QNetworkAccessManager; @@ -37,13 +37,13 @@ class QEventLoop; namespace QOAuth { -class QOAuth; +class Interface; -class QOAuthPrivate : public QObject +class InterfacePrivate : public QObject { Q_OBJECT - Q_DECLARE_PUBLIC(QOAuth) + Q_DECLARE_PUBLIC(Interface) public: enum Operation { @@ -70,7 +70,7 @@ class QOAuthPrivate : public QObject static const QByteArray ParamVersion; - QOAuthPrivate( QObject *parent = 0 ); + InterfacePrivate( QObject *parent = 0 ); QByteArray httpMethodToString( HttpMethod method ); QByteArray signatureMethodToString( SignatureMethod method ); ParamMap replyToMap( const QByteArray &data ); @@ -115,9 +115,9 @@ public Q_SLOTS: void setPassphrase( int id, const QCA::Event &event ); protected: - QOAuth *q_ptr; + Interface *q_ptr; }; } // namespace QOAuth -#endif // QOAUTH_P_H +#endif // INTERFACE_P_H diff --git a/include/qoauth_global.h b/src/qoauth_global.h similarity index 100% rename from include/qoauth_global.h rename to src/qoauth_global.h diff --git a/include/qoauth_namespace.h b/src/qoauth_namespace.h similarity index 88% rename from include/qoauth_namespace.h rename to src/qoauth_namespace.h index 040eaae..b41f210 100644 --- a/include/qoauth_namespace.h +++ b/src/qoauth_namespace.h @@ -48,8 +48,9 @@ namespace QOAuth { There are 3 different signature methods defined by the OAuth protocol. This enum is used to specify the method used by a specific request. Hence, one of its values - must be passed as a parameter in any of the \ref QOAuth::QOAuth::requestToken(), - \ref QOAuth::QOAuth::accessToken() or \ref QOAuth::QOAuth::createParametersString() method. + must be passed as a parameter in any of the \ref QOAuth::Interface::requestToken(), + \ref QOAuth::Interface::accessToken() or \ref QOAuth::Interface::createParametersString() + method. \note The current implementation of the library supports only HMAC-SHA1 signature algorithm. */ @@ -67,11 +68,11 @@ namespace QOAuth { The HTTP method has to be specified in QOAuth class for two reasons: \li to know what type of request should be prepared and sent - (\ref QOAuth::QOAuth::requestToken() and \ref QOAuth::QOAuth::accessToken()), + (\ref QOAuth::Interface::requestToken() and \ref QOAuth::Interface::accessToken()), \li to prepare a correct signature, as the Signature Base String contains a parameter - specifying the HTTP method used for request (\ref QOAuth::QOAuth::createParametersString()). + specifying the HTTP method used for request (\ref QOAuth::Interface::createParametersString()). - \note For \ref QOAuth::QOAuth::requestToken() and \ref QOAuth::QOAuth::accessToken() methods + \note For \ref QOAuth::Interface::requestToken() and \ref QOAuth::Interface::accessToken() methods only \ref GET and \ref POST methods are allowed. */ enum HttpMethod { @@ -88,15 +89,15 @@ namespace QOAuth { a parameter string. When creating a parameters string for a custom request using - \ref QOAuth::QOAuth::createParametersString() the parsing mode must be defined in order + \ref QOAuth::Interface::createParametersString() the parsing mode must be defined in order to prepare the string correctly. According to what is stated in OAuth 1.0 Core specification, parameters can be passed in a request to - the Service Provider in 3 different ways. When using \ref QOAuth::QOAuth::createParametersString(), + the Service Provider in 3 different ways. When using \ref QOAuth::Interface::createParametersString(), choose the one that suits you by setting \a ParsingMode appropriatelly. - \sa QOAuth::QOAuth::createParametersString() + \sa QOAuth::Interface::createParametersString() */ enum ParsingMode { ParseForRequestContent, //!< Inline query format (foo=bar&bar=baz&baz=foo ...), suitable for POST requests @@ -109,12 +110,12 @@ namespace QOAuth { /*! \enum ErrorCode \brief This enum type defines error types that are assigned to the - \ref QOAuth::QOAuth::error property + \ref QOAuth::Interface::error property This error codes collection contains both network-related errors and those that can occur when incorrect arguments are provided to any of the class's methods. - \sa QOAuth::QOAuth::error + \sa QOAuth::Interface::error */ enum ErrorCode { NoError = 200, //!< No error occured (so far :-) ) @@ -125,7 +126,7 @@ namespace QOAuth { ConsumerKeyEmpty, //!< Consumer key has not been provided ConsumerSecretEmpty, //!< Consumer secret has not been provided UnsupportedHttpMethod, /*!< The HTTP method is not supported by the request. Note that - \ref QOAuth::QOAuth::requestToken() and \ref QOAuth::QOAuth::accessToken() + \ref QOAuth::Interface::requestToken() and \ref QOAuth::Interface::accessToken() accept only HTTP GET and POST requests. */ RSAPrivateKeyEmpty = 1101, //!< RSA private key has not been provided @@ -145,9 +146,9 @@ namespace QOAuth { /*! \brief Returns the name of the Access Token argument parameter. - Useful when reading Service Provider's reply for \ref QOAuth::QOAuth::accessToken() request, e.g: + Useful when reading Service Provider's reply for \ref QOAuth::Interface::accessToken() request, e.g: \code - QOAuth::QOAuth qoauth; + QOAuth::Interface qoauth; QByteArray requestToken = "token"; QByteArray requestTokenSecret = "secret"; QOAuth::ParamMap reply = qoauth.accessToken( "http://example.com/access_token", QOAuth::POST, diff --git a/src/src.pro b/src/src.pro index 9387606..3f68f46 100644 --- a/src/src.pro +++ b/src/src.pro @@ -18,19 +18,19 @@ OBJECTS_DIR = tmp MOC_DIR = tmp INC_DIR = ../include -INCLUDEPATH += $${INC_DIR} +INCLUDEPATH += . PUBLIC_HEADERS += \ - $${INC_DIR}/qoauth_global.h \ - $${INC_DIR}/qoauth_namespace.h \ - $${INC_DIR}/qoauth.h + qoauth_global.h \ + qoauth_namespace.h \ + interface.h PRIVATE_HEADERS += \ - $${INC_DIR}/qoauth_p.h + interface_p.h HEADERS = \ $$PUBLIC_HEADERS \ $$PRIVATE_HEADERS -SOURCES += qoauth.cpp +SOURCES += interface.cpp DEFINES += QOAUTH diff --git a/tests/ft_qoauth/ft_qoauth.cpp b/tests/ft_interface/ft_interface.cpp similarity index 95% rename from tests/ft_qoauth/ft_qoauth.cpp rename to tests/ft_interface/ft_interface.cpp index f3c6c6c..88dfa05 100644 --- a/tests/ft_qoauth/ft_qoauth.cpp +++ b/tests/ft_interface/ft_interface.cpp @@ -18,7 +18,7 @@ ***************************************************************************/ -#include "ft_qoauth.h" +#include "ft_interface.h" #include #include @@ -26,21 +26,21 @@ #include #include -#include "qoauth.h" -#include "qoauth_p.h" +#include +#include -void QOAuth::Ft_QOAuth::init() +void QOAuth::Ft_Interface::init() { - m = new QOAuth; + m = new Interface; } -void QOAuth::Ft_QOAuth::cleanup() +void QOAuth::Ft_Interface::cleanup() { delete m; } -void QOAuth::Ft_QOAuth::requestToken_data() +void QOAuth::Ft_Interface::requestToken_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -86,7 +86,7 @@ void QOAuth::Ft_QOAuth::requestToken_data() } -void QOAuth::Ft_QOAuth::requestToken() +void QOAuth::Ft_Interface::requestToken() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -112,7 +112,7 @@ void QOAuth::Ft_QOAuth::requestToken() } } -void QOAuth::Ft_QOAuth::requestTokenRSA_data() +void QOAuth::Ft_Interface::requestTokenRSA_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -138,7 +138,7 @@ void QOAuth::Ft_QOAuth::requestTokenRSA_data() << QByteArray( "requestsecret" ); } -void QOAuth::Ft_QOAuth::requestTokenRSA() +void QOAuth::Ft_Interface::requestTokenRSA() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -167,7 +167,7 @@ void QOAuth::Ft_QOAuth::requestTokenRSA() } -void QOAuth::Ft_QOAuth::accessToken_data() +void QOAuth::Ft_Interface::accessToken_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -207,7 +207,7 @@ void QOAuth::Ft_QOAuth::accessToken_data() << QByteArray( "accesssecret" ); } -void QOAuth::Ft_QOAuth::accessToken() +void QOAuth::Ft_Interface::accessToken() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -237,7 +237,7 @@ void QOAuth::Ft_QOAuth::accessToken() } -void QOAuth::Ft_QOAuth::accessTokenRSA_data() +void QOAuth::Ft_Interface::accessTokenRSA_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -268,7 +268,7 @@ void QOAuth::Ft_QOAuth::accessTokenRSA_data() } -void QOAuth::Ft_QOAuth::accessTokenRSA() +void QOAuth::Ft_Interface::accessTokenRSA() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -300,7 +300,7 @@ void QOAuth::Ft_QOAuth::accessTokenRSA() } -void QOAuth::Ft_QOAuth::accessResources_data() +void QOAuth::Ft_Interface::accessResources_data() { QTest::addColumn("key"); QTest::addColumn("secret"); @@ -352,7 +352,7 @@ void QOAuth::Ft_QOAuth::accessResources_data() << (int) NoError; } -void QOAuth::Ft_QOAuth::accessResources() +void QOAuth::Ft_Interface::accessResources() { QFETCH( QByteArray, key ); QFETCH( QByteArray, secret ); @@ -405,7 +405,7 @@ void QOAuth::Ft_QOAuth::accessResources() QVERIFY( m->error() == error ); } -void QOAuth::Ft_QOAuth::accessResourcesRSA_data() +void QOAuth::Ft_Interface::accessResourcesRSA_data() { QTest::addColumn("key"); QTest::addColumn("secret"); @@ -443,7 +443,7 @@ void QOAuth::Ft_QOAuth::accessResourcesRSA_data() << (int) NoError; } -void QOAuth::Ft_QOAuth::accessResourcesRSA() +void QOAuth::Ft_Interface::accessResourcesRSA() { QFETCH( QByteArray, key ); QFETCH( QByteArray, secret ); @@ -499,4 +499,4 @@ void QOAuth::Ft_QOAuth::accessResourcesRSA() } -QTEST_MAIN(QOAuth::Ft_QOAuth) +QTEST_MAIN(QOAuth::Ft_Interface) diff --git a/tests/ft_qoauth/ft_qoauth.h b/tests/ft_interface/ft_interface.h similarity index 93% rename from tests/ft_qoauth/ft_qoauth.h rename to tests/ft_interface/ft_interface.h index 6c0e8c5..0de0ba8 100644 --- a/tests/ft_qoauth/ft_qoauth.h +++ b/tests/ft_interface/ft_interface.h @@ -18,16 +18,16 @@ ***************************************************************************/ -#ifndef FT_QOAUTH_H -#define FT_QOAUTH_H +#ifndef FT_INTERFACE_H +#define FT_INTERFACE_H #include namespace QOAuth { -class QOAuth; +class Interface; -class Ft_QOAuth : public QObject +class Ft_Interface : public QObject { Q_OBJECT @@ -55,9 +55,9 @@ private Q_SLOTS: void accessResourcesRSA(); private: - QOAuth *m; + Interface *m; }; } // namespace QOAuth -#endif // FT_QOAUTH_H +#endif // FT_INTERFACE_H diff --git a/tests/ft_qoauth/ft_qoauth.pro b/tests/ft_interface/ft_interface.pro similarity index 82% rename from tests/ft_qoauth/ft_qoauth.pro rename to tests/ft_interface/ft_interface.pro index 285270a..763e2f1 100644 --- a/tests/ft_qoauth/ft_qoauth.pro +++ b/tests/ft_interface/ft_interface.pro @@ -1,4 +1,4 @@ -TARGET = ft_qoauth +TARGET = ft_interface TEMPLATE = app DEFINES += UNIT_TEST @@ -19,6 +19,6 @@ else:unix { LIBS += -Wl,-rpath,../../lib:lib } -INCLUDEPATH += . -HEADERS += ft_qoauth.h -SOURCES += ft_qoauth.cpp +INCLUDEPATH += . ../../src +HEADERS += ft_interface.h +SOURCES += ft_interface.cpp diff --git a/tests/ft_qoauth/rsa-testkey.pem b/tests/ft_interface/rsa-testkey.pem similarity index 100% rename from tests/ft_qoauth/rsa-testkey.pem rename to tests/ft_interface/rsa-testkey.pem diff --git a/tests/tests.pro b/tests/tests.pro index 86d4411..d582750 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += ut_qoauth ft_qoauth +SUBDIRS += ut_interface ft_interface diff --git a/tests/ut_qoauth/empty.file b/tests/ut_interface/empty.file similarity index 100% rename from tests/ut_qoauth/empty.file rename to tests/ut_interface/empty.file diff --git a/tests/ut_qoauth/rsa-clean.pem b/tests/ut_interface/rsa-clean.pem similarity index 100% rename from tests/ut_qoauth/rsa-clean.pem rename to tests/ut_interface/rsa-clean.pem diff --git a/tests/ut_qoauth/rsa-pass.pem b/tests/ut_interface/rsa-pass.pem similarity index 100% rename from tests/ut_qoauth/rsa-pass.pem rename to tests/ut_interface/rsa-pass.pem diff --git a/tests/ut_qoauth/test.pem b/tests/ut_interface/test.pem similarity index 100% rename from tests/ut_qoauth/test.pem rename to tests/ut_interface/test.pem diff --git a/tests/ut_qoauth/ut_qoauth.cpp b/tests/ut_interface/ut_interface.cpp similarity index 94% rename from tests/ut_qoauth/ut_qoauth.cpp rename to tests/ut_interface/ut_interface.cpp index b58e579..7bb5c7d 100644 --- a/tests/ut_qoauth/ut_qoauth.cpp +++ b/tests/ut_interface/ut_interface.cpp @@ -18,26 +18,26 @@ ***************************************************************************/ -#include "ut_qoauth.h" +#include "ut_interface.h" #include #include -#include "qoauth.h" -#include "qoauth_p.h" +#include +#include -void QOAuth::Ut_QOAuth::init() +void QOAuth::Ut_Interface::init() { - m = new QOAuth; + m = new Interface; } -void QOAuth::Ut_QOAuth::cleanup() +void QOAuth::Ut_Interface::cleanup() { delete m; } -void QOAuth::Ut_QOAuth::constructor() +void QOAuth::Ut_Interface::constructor() { QVERIFY( m ); QVERIFY( m->consumerKey().isEmpty() ); @@ -47,7 +47,7 @@ void QOAuth::Ut_QOAuth::constructor() QVERIFY( m->d_ptr ); } -void QOAuth::Ut_QOAuth::consumerKey() +void QOAuth::Ut_Interface::consumerKey() { QByteArray consumerKey( "6d65216f4272d0d3932cdcf8951997c2" ); @@ -55,7 +55,7 @@ void QOAuth::Ut_QOAuth::consumerKey() QCOMPARE( m->consumerKey(), consumerKey ); } -void QOAuth::Ut_QOAuth::setConsumerKey() +void QOAuth::Ut_Interface::setConsumerKey() { QByteArray consumerKey( "6d65216f4272d0d3932cdcf8951997c2" ); @@ -63,7 +63,7 @@ void QOAuth::Ut_QOAuth::setConsumerKey() QCOMPARE( m->d_ptr->consumerKey, consumerKey ); } -void QOAuth::Ut_QOAuth::consumerSecret() +void QOAuth::Ut_Interface::consumerSecret() { QByteArray consumerSecret( "5af4e09d887c4969211ba40e9dd8f873" ); @@ -71,7 +71,7 @@ void QOAuth::Ut_QOAuth::consumerSecret() QCOMPARE( m->consumerSecret(), consumerSecret ); } -void QOAuth::Ut_QOAuth::setConsumerSecret() +void QOAuth::Ut_Interface::setConsumerSecret() { QByteArray consumerSecret( "5af4e09d887c4969211ba40e9dd8f873" ); @@ -79,7 +79,7 @@ void QOAuth::Ut_QOAuth::setConsumerSecret() QCOMPARE( m->d_ptr->consumerSecret, consumerSecret ); } -void QOAuth::Ut_QOAuth::requestTimeout() +void QOAuth::Ut_Interface::requestTimeout() { uint timeout = 13986754; @@ -87,7 +87,7 @@ void QOAuth::Ut_QOAuth::requestTimeout() QVERIFY( m->requestTimeout() == timeout ); } -void QOAuth::Ut_QOAuth::setRequestTimeout() +void QOAuth::Ut_Interface::setRequestTimeout() { uint timeout = 13986754; @@ -95,13 +95,13 @@ void QOAuth::Ut_QOAuth::setRequestTimeout() QVERIFY( m->d_ptr->requestTimeout == timeout ); } -void QOAuth::Ut_QOAuth::error() +void QOAuth::Ut_Interface::error() { m->d_ptr->error = Forbidden; QVERIFY( m->error() == Forbidden ); } -void QOAuth::Ut_QOAuth::requestToken_data() +void QOAuth::Ut_Interface::requestToken_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -158,7 +158,7 @@ void QOAuth::Ut_QOAuth::requestToken_data() } -void QOAuth::Ut_QOAuth::requestToken() +void QOAuth::Ut_Interface::requestToken() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -184,7 +184,7 @@ void QOAuth::Ut_QOAuth::requestToken() } } -void QOAuth::Ut_QOAuth::accessToken_data() +void QOAuth::Ut_Interface::accessToken_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -236,7 +236,7 @@ void QOAuth::Ut_QOAuth::accessToken_data() << QByteArray(); } -void QOAuth::Ut_QOAuth::accessToken() +void QOAuth::Ut_Interface::accessToken() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -265,7 +265,7 @@ void QOAuth::Ut_QOAuth::accessToken() } } -void QOAuth::Ut_QOAuth::createParametersString_data() +void QOAuth::Ut_Interface::createParametersString_data() { QTest::addColumn("timeout"); QTest::addColumn("key"); @@ -320,7 +320,7 @@ void QOAuth::Ut_QOAuth::createParametersString_data() << (int) ConsumerSecretEmpty; } -void QOAuth::Ut_QOAuth::createParametersString() +void QOAuth::Ut_Interface::createParametersString() { QFETCH( uint, timeout ); QFETCH( QByteArray, key ); @@ -352,7 +352,7 @@ void QOAuth::Ut_QOAuth::createParametersString() QVERIFY( m->error() == error ); } -void QOAuth::Ut_QOAuth::inlineParameters_data() +void QOAuth::Ut_Interface::inlineParameters_data() { QTest::addColumn("par1"); QTest::addColumn("val1"); @@ -401,7 +401,7 @@ void QOAuth::Ut_QOAuth::inlineParameters_data() } -void QOAuth::Ut_QOAuth::inlineParameters() +void QOAuth::Ut_Interface::inlineParameters() { QFETCH( QByteArray, par1 ); QFETCH( QByteArray, val1 ); @@ -423,7 +423,7 @@ void QOAuth::Ut_QOAuth::inlineParameters() QCOMPARE( query, result ); } -void QOAuth::Ut_QOAuth::setRSAPrivateKey_data() +void QOAuth::Ut_Interface::setRSAPrivateKey_data() { QTest::addColumn("key"); QTest::addColumn("passphrase"); @@ -483,7 +483,7 @@ void QOAuth::Ut_QOAuth::setRSAPrivateKey_data() } -void QOAuth::Ut_QOAuth::setRSAPrivateKey() +void QOAuth::Ut_Interface::setRSAPrivateKey() { QFETCH( QString, key ); QFETCH( QByteArray, passphrase ); @@ -495,7 +495,7 @@ void QOAuth::Ut_QOAuth::setRSAPrivateKey() QCOMPARE( m->error(), error ); } -void QOAuth::Ut_QOAuth::setRSAPrivateKeyFromFile_data() +void QOAuth::Ut_Interface::setRSAPrivateKeyFromFile_data() { QTest::addColumn("file"); QTest::addColumn("passphrase"); @@ -510,7 +510,7 @@ void QOAuth::Ut_QOAuth::setRSAPrivateKeyFromFile_data() } -void QOAuth::Ut_QOAuth::setRSAPrivateKeyFromFile() +void QOAuth::Ut_Interface::setRSAPrivateKeyFromFile() { QFETCH( QString, file ); QFETCH( QByteArray, passphrase ); @@ -522,4 +522,4 @@ void QOAuth::Ut_QOAuth::setRSAPrivateKeyFromFile() QCOMPARE( m->error(), error ); } -QTEST_MAIN(QOAuth::Ut_QOAuth) +QTEST_MAIN(QOAuth::Ut_Interface) diff --git a/tests/ut_qoauth/ut_qoauth.h b/tests/ut_interface/ut_interface.h similarity index 93% rename from tests/ut_qoauth/ut_qoauth.h rename to tests/ut_interface/ut_interface.h index 00e9296..415b554 100644 --- a/tests/ut_qoauth/ut_qoauth.h +++ b/tests/ut_interface/ut_interface.h @@ -18,8 +18,8 @@ ***************************************************************************/ -#ifndef UT_QOAUTH_H -#define UT_QOAUTH_H +#ifndef UT_INTERFACE_H +#define UT_INTERFACE_H #include @@ -27,9 +27,9 @@ namespace QOAuth { -class QOAuth; +class Interface; -class Ut_QOAuth : public QObject +class Ut_Interface : public QObject { Q_OBJECT @@ -68,10 +68,10 @@ private Q_SLOTS: void setRSAPrivateKeyFromFile(); private: - QOAuth *m; + Interface *m; QCA::Initializer initializer; }; } // namespace QOAuth -#endif // UT_QOAUTH_H +#endif // UT_INTERFACE_H diff --git a/tests/ut_qoauth/ut_qoauth.pro b/tests/ut_interface/ut_interface.pro similarity index 81% rename from tests/ut_qoauth/ut_qoauth.pro rename to tests/ut_interface/ut_interface.pro index 0c4f60c..3d800d3 100644 --- a/tests/ut_qoauth/ut_qoauth.pro +++ b/tests/ut_interface/ut_interface.pro @@ -1,4 +1,4 @@ -TARGET = ut_qoauth +TARGET = ut_interface TEMPLATE = app DEFINES += UNIT_TEST @@ -19,6 +19,6 @@ else:unix { LIBS += -Wl,-rpath,../../lib:lib } -INCLUDEPATH += . -HEADERS += ut_qoauth.h -SOURCES += ut_qoauth.cpp +INCLUDEPATH += . ../../src +HEADERS += ut_interface.h +SOURCES += ut_interface.cpp