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
1=== modified file 'libubuntuoneauth/tests/test_token.cpp'
2--- libubuntuoneauth/tests/test_token.cpp 2015-12-07 21:17:00 +0000
3+++ libubuntuoneauth/tests/test_token.cpp 2016-04-27 08:15:22 +0000
4@@ -46,6 +46,13 @@
5 delete token;
6 }
7
8+void TestToken::testTokenEmptyStrings()
9+{
10+ Token *token = new Token(QString(), QString(), QString(), QString());
11+ QVERIFY(!token->isValid());
12+ delete token;
13+}
14+
15 void TestToken::testTokenArgs()
16 {
17 Token *token = new Token("a", "b", "c", "d");
18
19=== modified file 'libubuntuoneauth/tests/test_token.h'
20--- libubuntuoneauth/tests/test_token.h 2015-12-07 21:17:00 +0000
21+++ libubuntuoneauth/tests/test_token.h 2016-04-27 08:15:22 +0000
22@@ -39,6 +39,7 @@
23 void cleanupTestCase();
24
25 void testEmptyToken();
26+ void testTokenEmptyStrings();
27 void testTokenArgs();
28 void testTokenCopy();
29
30
31=== modified file 'libubuntuoneauth/token.cpp'
32--- libubuntuoneauth/token.cpp 2015-12-07 21:17:00 +0000
33+++ libubuntuoneauth/token.cpp 2016-04-27 08:15:22 +0000
34@@ -46,21 +46,25 @@
35 QString consumer_key, QString consumer_secret)
36 {
37 _tokenHash[TOKEN_NAME_KEY] = buildTokenName();
38- _tokenHash[TOKEN_TOKEN_KEY] = token_key;
39- _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;
40- _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;
41- _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;
42+ if (!token_key.isEmpty()) {
43+ _tokenHash[TOKEN_TOKEN_KEY] = token_key;
44+ }
45+ if (!token_secret.isEmpty()) {
46+ _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;
47+ }
48+ if (!consumer_key.isEmpty()) {
49+ _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;
50+ }
51+ if (!consumer_secret.isEmpty()) {
52+ _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;
53+ }
54 }
55
56 Token::Token(QString token_key, QString token_secret,
57 QString consumer_key, QString consumer_secret,
58- QString created_date, QString updated_date)
59+ QString created_date, QString updated_date):
60+ Token(token_key, token_secret, consumer_key, consumer_secret)
61 {
62- _tokenHash[TOKEN_NAME_KEY] = buildTokenName();
63- _tokenHash[TOKEN_TOKEN_KEY] = token_key;
64- _tokenHash[TOKEN_TOKEN_SEC_KEY] = token_secret;
65- _tokenHash[TOKEN_CONSUMER_KEY] = consumer_key;
66- _tokenHash[TOKEN_CONSUMER_SEC_KEY] = consumer_secret;
67 _tokenHash[TOKEN_CREATED_KEY] = dateStringToISO(created_date);
68 _tokenHash[TOKEN_UPDATED_KEY] = dateStringToISO(updated_date);
69 }

Subscribers

People subscribed via source and target branches