Merge lp:~mardy/ubuntuone-credentials/token-valid-1572943 into lp:ubuntuone-credentials

Proposed by Alberto Mardegan
Status: Merged
Approved by: dobey
Approved revision: 239
Merged at revision: 238
Proposed branch: lp:~mardy/ubuntuone-credentials/token-valid-1572943
Merge into: lp:ubuntuone-credentials
Prerequisite: lp:~mardy/ubuntuone-credentials/library-symbols
Diff against target: 69 lines (+22/-10)
3 files modified
libubuntuoneauth/tests/test_token.cpp (+7/-0)
libubuntuoneauth/tests/test_token.h (+1/-0)
libubuntuoneauth/token.cpp (+14/-10)
To merge this branch: bzr merge lp:~mardy/ubuntuone-credentials/token-valid-1572943
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+293059@code.launchpad.net

Commit message

Make Token::isValid() return false on tokens created out of empty strings.

Description of the change

Make Token::isValid() return false on tokens created out of empty strings.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libubuntuoneauth/tests/test_token.cpp'
--- libubuntuoneauth/tests/test_token.cpp 2015-12-07 21:17:00 +0000
+++ libubuntuoneauth/tests/test_token.cpp 2016-04-27 08:15:22 +0000
@@ -46,6 +46,13 @@
46 delete token;46 delete token;
47}47}
4848
49void TestToken::testTokenEmptyStrings()
50{
51 Token *token = new Token(QString(), QString(), QString(), QString());
52 QVERIFY(!token->isValid());
53 delete token;
54}
55
49void TestToken::testTokenArgs()56void TestToken::testTokenArgs()
50{57{
51 Token *token = new Token("a", "b", "c", "d");58 Token *token = new Token("a", "b", "c", "d");
5259
=== modified file 'libubuntuoneauth/tests/test_token.h'
--- libubuntuoneauth/tests/test_token.h 2015-12-07 21:17:00 +0000
+++ libubuntuoneauth/tests/test_token.h 2016-04-27 08:15:22 +0000
@@ -39,6 +39,7 @@
39 void cleanupTestCase();39 void cleanupTestCase();
4040
41 void testEmptyToken();41 void testEmptyToken();
42 void testTokenEmptyStrings();
42 void testTokenArgs();43 void testTokenArgs();
43 void testTokenCopy();44 void testTokenCopy();
4445
4546
=== modified file 'libubuntuoneauth/token.cpp'
--- libubuntuoneauth/token.cpp 2015-12-07 21:17:00 +0000
+++ libubuntuoneauth/token.cpp 2016-04-27 08:15:22 +0000
@@ -46,21 +46,25 @@
46 QString consumer_key, QString consumer_secret)46 QString consumer_key, QString consumer_secret)
47 {47 {
48 _tokenHash[TOKEN_NAME_KEY] = buildTokenName();48 _tokenHash[TOKEN_NAME_KEY] = buildTokenName();
49 _tokenHash[TOKEN_TOKEN_KEY] = token_key;49 if (!token_key.isEmpty()) {
50 _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;50 _tokenHash[TOKEN_TOKEN_KEY] = token_key;
51 _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;51 }
52 _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;52 if (!token_secret.isEmpty()) {
53 _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;
54 }
55 if (!consumer_key.isEmpty()) {
56 _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;
57 }
58 if (!consumer_secret.isEmpty()) {
59 _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;
60 }
53 }61 }
5462
55 Token::Token(QString token_key, QString token_secret,63 Token::Token(QString token_key, QString token_secret,
56 QString consumer_key, QString consumer_secret,64 QString consumer_key, QString consumer_secret,
57 QString created_date, QString updated_date)65 QString created_date, QString updated_date):
66 Token(token_key, token_secret, consumer_key, consumer_secret)
58 {67 {
59 _tokenHash[TOKEN_NAME_KEY] = buildTokenName();
60 _tokenHash[TOKEN_TOKEN_KEY] = token_key;
61 _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;
62 _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;
63 _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;
64 _tokenHash[TOKEN_CREATED_KEY] = dateStringToISO(created_date);68 _tokenHash[TOKEN_CREATED_KEY] = dateStringToISO(created_date);
65 _tokenHash[TOKEN_UPDATED_KEY] = dateStringToISO(updated_date);69 _tokenHash[TOKEN_UPDATED_KEY] = dateStringToISO(updated_date);
66 }70 }

Subscribers

People subscribed via source and target branches