Merge lp:~mardy/ubuntuone-credentials/default-token-name into lp:ubuntuone-credentials

Proposed by Alberto Mardegan
Status: Rejected
Rejected by: Alberto Mardegan
Proposed branch: lp:~mardy/ubuntuone-credentials/default-token-name
Merge into: lp:ubuntuone-credentials
Prerequisite: lp:~mardy/ubuntuone-credentials/signon-plugin-part1
Diff against target: 47 lines (+5/-5)
3 files modified
signon-plugin/tests/test_plugin.cpp (+2/-2)
signon-plugin/ubuntuone-plugin.cpp (+2/-2)
signon-plugin/ubuntuone-plugin.h (+1/-1)
To merge this branch: bzr merge lp:~mardy/ubuntuone-credentials/default-token-name
Reviewer Review Type Date Requested Status
dobey (community) Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+293234@code.launchpad.net

Commit message

If no token name is given, use a default one

Description of the change

If no token name is given, use a default one

If we don't do something like this, then we need to accept this:
https://code.launchpad.net/~mardy/unity-scope-click/signon-plugin/+merge/288758
(which would be my recommendation, actually).

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

After looking at this and the plugin-part1 branch again, I think the better solution here would be to get rid of the ValidateInput method completely here, and we should call buildTokenName() in the createToken() method where we assemble the JSON to POST to the server, instead of using m_data.TokenName() there. This value should also be set on the token and stored, rather than setting the value on the Token object after it had been stored. Then we should just read the value from the stored Token when one already exists.

It seems to me that would simplify the code a bit, and be aligned with the current behavior, which this change (and the current plugin-part1 code) is not.

review: Needs Fixing
Revision history for this message
Alberto Mardegan (mardy) wrote :

> After looking at this and the plugin-part1 branch again, I think the better
> solution here would be to get rid of the ValidateInput method completely here,
> and we should call buildTokenName() in the createToken() method where we
> assemble the JSON to POST to the server, instead of using m_data.TokenName()
> there. This value should also be set on the token and stored, rather than
> setting the value on the Token object after it had been stored. Then we should
> just read the value from the stored Token when one already exists.

But then we lose the possibility for applications to specify their own token name: every app running on the device will be using the same token name. Given that the server allows for different apps to specify a token name, I think we should preserve this possibility.

> It seems to me that would simplify the code a bit, and be aligned with the
> current behavior, which this change (and the current plugin-part1 code) is
> not.

I think that this change maintains the behaviour which we currently have, and it allows for a third party app to use a different token name.

In case it's not clear, the code in part1 causes the plugin to store the tokens as a dictionary:

  token-name-1: { token data 1 },
  token-name-2: { token data 2 },
  ...

241. By Launchpad Translations on behalf of ubuntuone-control-tower

Launchpad automatic translations update.

Revision history for this message
dobey (dobey) wrote :

On Fri, 2016-05-06 at 09:32 +0000, Alberto Mardegan wrote:
> But then we lose the possibility for applications to specify their
> own token name: every app running on the device will be using the
> same token name. Given that the server allows for different apps to
> specify a token name, I think we should preserve this possibility.

This is fine for now. The goal here is to maintain feature parity with
the current implementation, while moving to the new signon back-end;
not to add more features that can cause problems, on top of that.

> I think that this change maintains the behaviour which we currently
> have, and it allows for a third party app to use a different token
> name.

It doesn't maintain the behavior, but extends it to allow alternate
token names.

> In case it's not clear, the code in part1 causes the plugin to store
> the tokens as a dictionary:
>
>   token-name-1: { token data 1 },
>   token-name-2: { token data 2 },
>   ...

There is much that isn't clear about this, which is why I think if we
do want such a feature, we should put it off until later. For instance,
how does the user know what the differences are? How are these
differences exposed in the UI? How are these managed separately from
the main account? There are many questions that need to be answered.

For simplicity sake, I think it's better to not do this now, and to
always force the same token name, as we have been doing for the past
2.5 years already.

242. By dobey

Remove the superfluous validateInput method.
Use the same taken name always.
Store the token name as part of the token data.

Revision history for this message
dobey (dobey) wrote :

I've also just proposed https://code.launchpad.net/~dobey/ubuntuone-credentials/default-token-name/+merge/295628 which implements the token name usage as I suggested. Please have a look at it.

Revision history for this message
Alberto Mardegan (mardy) wrote :

Indeed, let's go with that one then.

Unmerged revisions

243. By Alberto Mardegan

Fix stored token response

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'signon-plugin/tests/test_plugin.cpp'
2--- signon-plugin/tests/test_plugin.cpp 2016-04-28 10:10:42 +0000
3+++ signon-plugin/tests/test_plugin.cpp 2016-04-28 10:10:42 +0000
4@@ -232,8 +232,8 @@
5
6 QTest::newRow("empty") <<
7 sessionData.toMap() <<
8- int(Error::MissingData) <<
9- false << QVariantMap() << QVariantMap();
10+ -1 <<
11+ true << QVariantMap() << QVariantMap();
12
13 sessionData.setTokenName("helloworld");
14 sessionData.setSecret("consumer_key=aAa&consumer_secret=bBb&name=helloworld&token=cCc&token_secret=dDd");
15
16=== modified file 'signon-plugin/ubuntuone-plugin.cpp'
17--- signon-plugin/ubuntuone-plugin.cpp 2016-04-28 10:10:42 +0000
18+++ signon-plugin/ubuntuone-plugin.cpp 2016-04-28 10:10:42 +0000
19@@ -69,13 +69,13 @@
20 {
21 }
22
23- bool SignOnPlugin::validateInput(const PluginData &data,
24+ bool SignOnPlugin::validateInput(PluginData &data,
25 const QString &mechanism)
26 {
27 Q_UNUSED(mechanism);
28
29 if (data.TokenName().isEmpty()) {
30- return false;
31+ data.setTokenName(Token::buildTokenName());
32 }
33
34 return true;
35
36=== modified file 'signon-plugin/ubuntuone-plugin.h'
37--- signon-plugin/ubuntuone-plugin.h 2016-04-28 10:10:42 +0000
38+++ signon-plugin/ubuntuone-plugin.h 2016-04-28 10:10:42 +0000
39@@ -54,7 +54,7 @@
40 void userActionFinished(const SignOn::UiSessionData &data) Q_DECL_OVERRIDE;
41
42 private:
43- bool validateInput(const PluginData &data, const QString &mechanism);
44+ bool validateInput(PluginData &data, const QString &mechanism);
45 bool respondWithStoredData();
46 void emitErrorFromReply(QNetworkReply *reply);
47 void createNewToken();

Subscribers

People subscribed via source and target branches