Merge lp:~dobey/unity-scope-click/revert-signall into lp:unity-scope-click
- revert-signall
- Merge into trunk
Proposed by
dobey
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | dobey | ||||
Approved revision: | 438 | ||||
Merged at revision: | 437 | ||||
Proposed branch: | lp:~dobey/unity-scope-click/revert-signall | ||||
Merge into: | lp:unity-scope-click | ||||
Diff against target: |
454 lines (+55/-109) 18 files modified
libclickscope/click/download-manager.cpp (+3/-2) libclickscope/click/pay.cpp (+3/-0) libclickscope/click/preview.cpp (+4/-0) libclickscope/click/reviews.cpp (+1/-2) libclickscope/click/ubuntuone_credentials.cpp (+1/-41) libclickscope/click/ubuntuone_credentials.h (+2/-3) libclickscope/click/webclient.cpp (+19/-15) libclickscope/click/webclient.h (+1/-1) libclickscope/tests/mock_ubuntuone_credentials.h (+5/-5) libclickscope/tests/mock_webclient.h (+3/-2) libclickscope/tests/test_download_manager.cpp (+4/-2) libclickscope/tests/test_index.cpp (+1/-13) libclickscope/tests/test_reviews.cpp (+0/-13) libclickscope/tests/test_webclient.cpp (+8/-4) scope/clickapps/apps-scope.cpp (+0/-2) scope/clickapps/apps-scope.h (+0/-1) scope/clickstore/store-scope.cpp (+0/-2) scope/clickstore/store-scope.h (+0/-1) |
||||
To merge this branch: | bzr merge lp:~dobey/unity-scope-click/revert-signall | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Approve | ||
Review via email: mp+290482@code.launchpad.net |
Commit message
Revert the change to sign all requests, as it exposes some consistent crashing.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libclickscope/click/download-manager.cpp' | |||
2 | --- libclickscope/click/download-manager.cpp 2016-03-02 20:30:02 +0000 | |||
3 | +++ libclickscope/click/download-manager.cpp 2016-03-30 14:46:12 +0000 | |||
4 | @@ -154,11 +154,11 @@ | |||
5 | 154 | }); | 154 | }); |
6 | 155 | QObject::connect(response.data(), &click::web::Response::error, | 155 | QObject::connect(response.data(), &click::web::Response::error, |
7 | 156 | [this, callback, package_name](QString error, int error_code) { | 156 | [this, callback, package_name](QString error, int error_code) { |
9 | 157 | qWarning() << QStringLiteral("Network error (%1) fetching click token for:").arg(error_code) << package_name.c_str(); | 157 | qDebug() << QStringLiteral("Network error (%1) fetching click token for:").arg(error_code) << package_name.c_str(); |
10 | 158 | switch(error_code) { | 158 | switch(error_code) { |
11 | 159 | case 401: | 159 | case 401: |
12 | 160 | case 403: | 160 | case 403: |
14 | 161 | client->invalidateCredentials(); | 161 | sso->invalidateCredentials(); |
15 | 162 | callback(error.toUtf8().data(), Error::CredentialsError); | 162 | callback(error.toUtf8().data(), Error::CredentialsError); |
16 | 163 | break; | 163 | break; |
17 | 164 | default: | 164 | default: |
18 | @@ -172,6 +172,7 @@ | |||
19 | 172 | void DownloadManager::setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService) | 172 | void DownloadManager::setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService) |
20 | 173 | { | 173 | { |
21 | 174 | sso = credentialsService; | 174 | sso = credentialsService; |
22 | 175 | client->setCredentialsService(sso); | ||
23 | 175 | } | 176 | } |
24 | 176 | 177 | ||
25 | 177 | } // namespace click | 178 | } // namespace click |
26 | 178 | 179 | ||
27 | === modified file 'libclickscope/click/pay.cpp' | |||
28 | --- libclickscope/click/pay.cpp 2016-03-02 20:30:02 +0000 | |||
29 | +++ libclickscope/click/pay.cpp 2016-03-30 14:46:12 +0000 | |||
30 | @@ -228,6 +228,9 @@ | |||
31 | 228 | 228 | ||
32 | 229 | click::web::Cancellable Package::get_purchases(std::function<void(const PurchaseSet&)> callback) | 229 | click::web::Cancellable Package::get_purchases(std::function<void(const PurchaseSet&)> callback) |
33 | 230 | { | 230 | { |
34 | 231 | QSharedPointer<click::CredentialsService> sso(new click::CredentialsService()); | ||
35 | 232 | client->setCredentialsService(sso); | ||
36 | 233 | |||
37 | 231 | QSharedPointer<click::web::Response> response = client->call | 234 | QSharedPointer<click::web::Response> response = client->call |
38 | 232 | (get_base_url() + pay::API_ROOT + pay::PURCHASES_API_PATH, "GET", true); | 235 | (get_base_url() + pay::API_ROOT + pay::PURCHASES_API_PATH, "GET", true); |
39 | 233 | 236 | ||
40 | 234 | 237 | ||
41 | === modified file 'libclickscope/click/preview.cpp' | |||
42 | --- libclickscope/click/preview.cpp 2016-03-23 21:04:12 +0000 | |||
43 | +++ libclickscope/click/preview.cpp 2016-03-30 14:46:12 +0000 | |||
44 | @@ -734,6 +734,8 @@ | |||
45 | 734 | std::promise<bool> promise; | 734 | std::promise<bool> promise; |
46 | 735 | auto future = promise.get_future(); | 735 | auto future = promise.get_future(); |
47 | 736 | run_under_qt([this, reply, &promise]() { | 736 | run_under_qt([this, reply, &promise]() { |
48 | 737 | QSharedPointer<click::CredentialsService> sso(new click::CredentialsService()); | ||
49 | 738 | dm->setCredentialsService(sso); | ||
50 | 737 | dm->start(download_url, download_sha512, result["name"].get_string(), | 739 | dm->start(download_url, download_sha512, result["name"].get_string(), |
51 | 738 | [this, reply, &promise] (std::string msg, DownloadManager::Error dmerr){ | 740 | [this, reply, &promise] (std::string msg, DownloadManager::Error dmerr){ |
52 | 739 | switch (dmerr) | 741 | switch (dmerr) |
53 | @@ -886,6 +888,8 @@ | |||
54 | 886 | std::promise<bool> submit_promise; | 888 | std::promise<bool> submit_promise; |
55 | 887 | std::future<bool> submit_future = submit_promise.get_future(); | 889 | std::future<bool> submit_future = submit_promise.get_future(); |
56 | 888 | qt::core::world::enter_with_task([this, review, &submit_promise, widget_id]() mutable { | 890 | qt::core::world::enter_with_task([this, review, &submit_promise, widget_id]() mutable { |
57 | 891 | QSharedPointer<click::CredentialsService> sso(new click::CredentialsService()); | ||
58 | 892 | client->setCredentialsService(sso); | ||
59 | 889 | if (widget_id == "rating") { | 893 | if (widget_id == "rating") { |
60 | 890 | submit_operation = reviews->submit_review(review, | 894 | submit_operation = reviews->submit_review(review, |
61 | 891 | [&submit_promise](click::Reviews::Error){ | 895 | [&submit_promise](click::Reviews::Error){ |
62 | 892 | 896 | ||
63 | === modified file 'libclickscope/click/reviews.cpp' | |||
64 | --- libclickscope/click/reviews.cpp 2016-03-25 14:08:14 +0000 | |||
65 | +++ libclickscope/click/reviews.cpp 2016-03-30 14:46:12 +0000 | |||
66 | @@ -131,8 +131,7 @@ | |||
67 | 131 | click::web::CallParams params; | 131 | click::web::CallParams params; |
68 | 132 | params.add(click::REVIEWS_QUERY_ARGNAME, package_name.c_str()); | 132 | params.add(click::REVIEWS_QUERY_ARGNAME, package_name.c_str()); |
69 | 133 | QSharedPointer<click::web::Response> response = client->call | 133 | QSharedPointer<click::web::Response> response = client->call |
72 | 134 | (get_base_url() + click::REVIEWS_API_PATH, "GET", false, | 134 | (get_base_url() + click::REVIEWS_API_PATH, params); |
71 | 135 | std::map<std::string, std::string>{}, "", params); | ||
73 | 136 | 135 | ||
74 | 137 | QObject::connect(response.data(), &click::web::Response::finished, | 136 | QObject::connect(response.data(), &click::web::Response::finished, |
75 | 138 | [=](QString reply) { | 137 | [=](QString reply) { |
76 | 139 | 138 | ||
77 | === modified file 'libclickscope/click/ubuntuone_credentials.cpp' | |||
78 | --- libclickscope/click/ubuntuone_credentials.cpp 2016-03-17 16:10:23 +0000 | |||
79 | +++ libclickscope/click/ubuntuone_credentials.cpp 2016-03-30 14:46:12 +0000 | |||
80 | @@ -1,5 +1,5 @@ | |||
81 | 1 | /* | 1 | /* |
83 | 2 | * Copyright (C) 2014-2016 Canonical Ltd. | 2 | * Copyright (C) 2014 Canonical Ltd. |
84 | 3 | * | 3 | * |
85 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
86 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
87 | @@ -29,9 +29,6 @@ | |||
88 | 29 | 29 | ||
89 | 30 | #include "ubuntuone_credentials.h" | 30 | #include "ubuntuone_credentials.h" |
90 | 31 | 31 | ||
91 | 32 | #include <future> | ||
92 | 33 | #include <QCoreApplication> | ||
93 | 34 | |||
94 | 35 | namespace u1 = UbuntuOne; | 32 | namespace u1 = UbuntuOne; |
95 | 36 | 33 | ||
96 | 37 | click::CredentialsService::CredentialsService() | 34 | click::CredentialsService::CredentialsService() |
97 | @@ -50,43 +47,6 @@ | |||
98 | 50 | { | 47 | { |
99 | 51 | } | 48 | } |
100 | 52 | 49 | ||
101 | 53 | UbuntuOne::Token click::CredentialsService::getToken() | ||
102 | 54 | { | ||
103 | 55 | if (!_token.isValid()) { | ||
104 | 56 | std::promise<UbuntuOne::Token> promise; | ||
105 | 57 | auto future = promise.get_future(); | ||
106 | 58 | |||
107 | 59 | auto success = QObject::connect(ssoService.data(), | ||
108 | 60 | &u1::SSOService::credentialsFound, | ||
109 | 61 | [this, &promise](const u1::Token& token) { | ||
110 | 62 | emit credentialsFound(_token); | ||
111 | 63 | promise.set_value(token); | ||
112 | 64 | }); | ||
113 | 65 | auto notfound = QObject::connect(ssoService.data(), | ||
114 | 66 | &u1::SSOService::credentialsNotFound, | ||
115 | 67 | [this, &promise]() { | ||
116 | 68 | qWarning() << "No Ubuntu One token found."; | ||
117 | 69 | emit credentialsNotFound(); | ||
118 | 70 | promise.set_value(u1::Token()); | ||
119 | 71 | }); | ||
120 | 72 | |||
121 | 73 | getCredentials(); | ||
122 | 74 | |||
123 | 75 | std::future_status status = future.wait_for(std::chrono::milliseconds(0)); | ||
124 | 76 | while (status != std::future_status::ready) { | ||
125 | 77 | QCoreApplication::processEvents(); | ||
126 | 78 | qDebug() << "Processed some events, waiting to process again."; | ||
127 | 79 | status = future.wait_for(std::chrono::milliseconds(100)); | ||
128 | 80 | } | ||
129 | 81 | |||
130 | 82 | _token = future.get(); | ||
131 | 83 | QObject::disconnect(success); | ||
132 | 84 | QObject::disconnect(notfound); | ||
133 | 85 | } | ||
134 | 86 | |||
135 | 87 | return _token; | ||
136 | 88 | } | ||
137 | 89 | |||
138 | 90 | void click::CredentialsService::getCredentials() | 50 | void click::CredentialsService::getCredentials() |
139 | 91 | { | 51 | { |
140 | 92 | ssoService->getCredentials(); | 52 | ssoService->getCredentials(); |
141 | 93 | 53 | ||
142 | === modified file 'libclickscope/click/ubuntuone_credentials.h' | |||
143 | --- libclickscope/click/ubuntuone_credentials.h 2016-03-03 15:52:28 +0000 | |||
144 | +++ libclickscope/click/ubuntuone_credentials.h 2016-03-30 14:46:12 +0000 | |||
145 | @@ -1,5 +1,5 @@ | |||
146 | 1 | /* | 1 | /* |
148 | 2 | * Copyright (C) 2014-2016 Canonical Ltd. | 2 | * Copyright (C) 2014 Canonical Ltd. |
149 | 3 | * | 3 | * |
150 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
151 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
152 | @@ -47,7 +47,6 @@ | |||
153 | 47 | 47 | ||
154 | 48 | CredentialsService& operator=(const CredentialsService&) = delete; | 48 | CredentialsService& operator=(const CredentialsService&) = delete; |
155 | 49 | 49 | ||
156 | 50 | virtual UbuntuOne::Token getToken(); | ||
157 | 51 | virtual void getCredentials(); | 50 | virtual void getCredentials(); |
158 | 52 | virtual void invalidateCredentials(); | 51 | virtual void invalidateCredentials(); |
159 | 53 | 52 | ||
160 | @@ -58,7 +57,7 @@ | |||
161 | 58 | 57 | ||
162 | 59 | private: | 58 | private: |
163 | 60 | QScopedPointer<UbuntuOne::SSOService> ssoService; | 59 | QScopedPointer<UbuntuOne::SSOService> ssoService; |
165 | 61 | UbuntuOne::Token _token; | 60 | |
166 | 62 | }; // CredentialsService | 61 | }; // CredentialsService |
167 | 63 | 62 | ||
168 | 64 | } // namespace click | 63 | } // namespace click |
169 | 65 | 64 | ||
170 | === modified file 'libclickscope/click/webclient.cpp' | |||
171 | --- libclickscope/click/webclient.cpp 2016-03-03 15:52:28 +0000 | |||
172 | +++ libclickscope/click/webclient.cpp 2016-03-30 14:46:12 +0000 | |||
173 | @@ -82,7 +82,7 @@ | |||
174 | 82 | const std::string& iri, | 82 | const std::string& iri, |
175 | 83 | const click::web::CallParams& params) | 83 | const click::web::CallParams& params) |
176 | 84 | { | 84 | { |
178 | 85 | return call(iri, "GET", true, | 85 | return call(iri, "GET", false, |
179 | 86 | std::map<std::string, std::string>(), "", params); | 86 | std::map<std::string, std::string>(), "", params); |
180 | 87 | } | 87 | } |
181 | 88 | 88 | ||
182 | @@ -132,21 +132,25 @@ | |||
183 | 132 | request->setRawHeader(DEVICE_ID_HEADER.c_str(), deviceId.data()); | 132 | request->setRawHeader(DEVICE_ID_HEADER.c_str(), deviceId.data()); |
184 | 133 | 133 | ||
185 | 134 | if (sign && !impl->sso.isNull()) { | 134 | if (sign && !impl->sso.isNull()) { |
197 | 135 | auto token = impl->sso->getToken(); | 135 | click::utils::SmartConnect sc(responsePtr.data()); |
198 | 136 | if (token.isValid()) { | 136 | sc.connect(impl->sso.data(), &click::CredentialsService::credentialsFound, |
199 | 137 | QString auth_header = token.signUrl(url.toString(), | 137 | [=](const UbuntuOne::Token& token) { |
200 | 138 | method.c_str()); | 138 | QString auth_header = token.signUrl(url.toString(), |
201 | 139 | qDebug() << "Signed URL:" << request->url().toString(); | 139 | method.c_str()); |
202 | 140 | request->setRawHeader(AUTHORIZATION_HEADER.c_str(), auth_header.toUtf8()); | 140 | qDebug() << "Signed URL:" << request->url().toString(); |
203 | 141 | } else { | 141 | request->setRawHeader(AUTHORIZATION_HEADER.c_str(), auth_header.toUtf8()); |
204 | 142 | qWarning() << "Signing reuested but returned token is invalid."; | 142 | impl->sso.clear(); |
205 | 143 | } | 143 | doConnect(); |
206 | 144 | 144 | }); | |
207 | 145 | doConnect(); | 145 | sc.connect(impl->sso.data(), &click::CredentialsService::credentialsNotFound, |
208 | 146 | [=]() { | ||
209 | 147 | impl->sso.clear(); | ||
210 | 148 | qWarning() << "Signing reuested but no credentials found. Using unsigned URL."; | ||
211 | 149 | doConnect(); | ||
212 | 150 | }); | ||
213 | 151 | // TODO: Need to handle error signal once in CredentialsService. | ||
214 | 152 | impl->sso->getCredentials(); | ||
215 | 146 | } else { | 153 | } else { |
216 | 147 | if (sign && impl->sso.isNull()) { | ||
217 | 148 | qCritical() << "Unable to sign request without SSO object."; | ||
218 | 149 | } | ||
219 | 150 | doConnect(); | 154 | doConnect(); |
220 | 151 | } | 155 | } |
221 | 152 | 156 | ||
222 | 153 | 157 | ||
223 | === modified file 'libclickscope/click/webclient.h' | |||
224 | --- libclickscope/click/webclient.h 2016-02-29 21:08:09 +0000 | |||
225 | +++ libclickscope/click/webclient.h 2016-03-30 14:46:12 +0000 | |||
226 | @@ -121,7 +121,7 @@ | |||
227 | 121 | virtual QSharedPointer<Response> call( | 121 | virtual QSharedPointer<Response> call( |
228 | 122 | const std::string& iri, | 122 | const std::string& iri, |
229 | 123 | const std::string& method, | 123 | const std::string& method, |
231 | 124 | bool sign = true, | 124 | bool sign = false, |
232 | 125 | const std::map<std::string, std::string>& headers = std::map<std::string, std::string>(), | 125 | const std::map<std::string, std::string>& headers = std::map<std::string, std::string>(), |
233 | 126 | const std::string& data = "", | 126 | const std::string& data = "", |
234 | 127 | const CallParams& params = CallParams()); | 127 | const CallParams& params = CallParams()); |
235 | 128 | 128 | ||
236 | === modified file 'libclickscope/tests/mock_ubuntuone_credentials.h' | |||
237 | --- libclickscope/tests/mock_ubuntuone_credentials.h 2016-03-03 15:52:28 +0000 | |||
238 | +++ libclickscope/tests/mock_ubuntuone_credentials.h 2016-03-30 14:46:12 +0000 | |||
239 | @@ -1,5 +1,5 @@ | |||
240 | 1 | /* | 1 | /* |
242 | 2 | * Copyright (C) 2014-2016 Canonical Ltd. | 2 | * Copyright (C) 2014 Canonical Ltd. |
243 | 3 | * | 3 | * |
244 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
245 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
246 | @@ -27,11 +27,11 @@ | |||
247 | 27 | * files in the program, then also delete it here. | 27 | * files in the program, then also delete it here. |
248 | 28 | */ | 28 | */ |
249 | 29 | 29 | ||
250 | 30 | #include <token.h> | ||
251 | 31 | 30 | ||
252 | 32 | class MockCredentialsService : public click::CredentialsService { | 31 | class MockCredentialsService : public click::CredentialsService { |
253 | 33 | public: | 32 | public: |
257 | 34 | MOCK_METHOD0(getToken, UbuntuOne::Token()); | 33 | MOCK_METHOD0(getCredentials, |
258 | 35 | MOCK_METHOD0(getCredentials, void()); | 34 | void()); |
259 | 36 | MOCK_METHOD0(invalidateCredentials, void()); | 35 | MOCK_METHOD0(invalidateCredentials, |
260 | 36 | void()); | ||
261 | 37 | }; | 37 | }; |
262 | 38 | 38 | ||
263 | === modified file 'libclickscope/tests/mock_webclient.h' | |||
264 | --- libclickscope/tests/mock_webclient.h 2016-03-02 20:30:02 +0000 | |||
265 | +++ libclickscope/tests/mock_webclient.h 2016-03-30 14:46:12 +0000 | |||
266 | @@ -87,13 +87,13 @@ | |||
267 | 87 | QSharedPointer<click::web::Response> call( | 87 | QSharedPointer<click::web::Response> call( |
268 | 88 | const std::string& iri, | 88 | const std::string& iri, |
269 | 89 | const click::web::CallParams& params=click::web::CallParams()) override { | 89 | const click::web::CallParams& params=click::web::CallParams()) override { |
271 | 90 | return callImpl(iri, "GET", true, | 90 | return callImpl(iri, "GET", false, |
272 | 91 | std::map<std::string, std::string>(), "", params); | 91 | std::map<std::string, std::string>(), "", params); |
273 | 92 | } | 92 | } |
274 | 93 | QSharedPointer<click::web::Response> call( | 93 | QSharedPointer<click::web::Response> call( |
275 | 94 | const std::string& iri, | 94 | const std::string& iri, |
276 | 95 | const std::string& method, | 95 | const std::string& method, |
278 | 96 | bool sign = true, | 96 | bool sign = false, |
279 | 97 | const std::map<std::string, std::string>& headers = std::map<std::string, std::string>(), | 97 | const std::map<std::string, std::string>& headers = std::map<std::string, std::string>(), |
280 | 98 | const std::string& data = "", | 98 | const std::string& data = "", |
281 | 99 | const click::web::CallParams& params=click::web::CallParams()) override { | 99 | const click::web::CallParams& params=click::web::CallParams()) override { |
282 | @@ -102,6 +102,7 @@ | |||
283 | 102 | 102 | ||
284 | 103 | MOCK_METHOD1(has_header, bool(const std::string& header)); | 103 | MOCK_METHOD1(has_header, bool(const std::string& header)); |
285 | 104 | MOCK_METHOD1(get_header, std::string(const std::string&header)); | 104 | MOCK_METHOD1(get_header, std::string(const std::string&header)); |
286 | 105 | MOCK_METHOD0(invalidateCredentials, void()); | ||
287 | 105 | }; | 106 | }; |
288 | 106 | 107 | ||
289 | 107 | } | 108 | } |
290 | 108 | 109 | ||
291 | === modified file 'libclickscope/tests/test_download_manager.cpp' | |||
292 | --- libclickscope/tests/test_download_manager.cpp 2016-03-02 20:30:02 +0000 | |||
293 | +++ libclickscope/tests/test_download_manager.cpp 2016-03-30 14:46:12 +0000 | |||
294 | @@ -63,7 +63,6 @@ | |||
295 | 63 | 63 | ||
296 | 64 | virtual void SetUp() | 64 | virtual void SetUp() |
297 | 65 | { | 65 | { |
298 | 66 | ssoPtr.reset(new MockCredentialsService()); | ||
299 | 67 | namPtr.reset(new MockNetworkAccessManager()); | 66 | namPtr.reset(new MockNetworkAccessManager()); |
300 | 68 | clientPtr.reset(new NiceMock<MockClient>(namPtr)); | 67 | clientPtr.reset(new NiceMock<MockClient>(namPtr)); |
301 | 69 | clientPtr->setCredentialsService(ssoPtr); | 68 | clientPtr->setCredentialsService(ssoPtr); |
302 | @@ -161,6 +160,9 @@ | |||
303 | 161 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 160 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
304 | 162 | auto response = responseForReply(reply.asSharedPtr()); | 161 | auto response = responseForReply(reply.asSharedPtr()); |
305 | 163 | 162 | ||
306 | 163 | QSharedPointer<MockCredentialsService> sso(new MockCredentialsService()); | ||
307 | 164 | dmPtr->setCredentialsService(sso); | ||
308 | 165 | |||
309 | 164 | EXPECT_CALL(reply.instance, errorString()) | 166 | EXPECT_CALL(reply.instance, errorString()) |
310 | 165 | .WillOnce(Return(QString("ERROR"))); | 167 | .WillOnce(Return(QString("ERROR"))); |
311 | 166 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(401))); | 168 | EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(401))); |
312 | @@ -170,7 +172,7 @@ | |||
313 | 170 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) | 172 | EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
314 | 171 | .Times(1) | 173 | .Times(1) |
315 | 172 | .WillOnce(Return(response)); | 174 | .WillOnce(Return(response)); |
317 | 173 | EXPECT_CALL(*ssoPtr, invalidateCredentials()); | 175 | EXPECT_CALL(*(sso.data()), invalidateCredentials()); |
318 | 174 | EXPECT_CALL(*this, start_callback("ERROR (201)", | 176 | EXPECT_CALL(*this, start_callback("ERROR (201)", |
319 | 175 | click::DownloadManager::Error::CredentialsError)).Times(1); | 177 | click::DownloadManager::Error::CredentialsError)).Times(1); |
320 | 176 | 178 | ||
321 | 177 | 179 | ||
322 | === modified file 'libclickscope/tests/test_index.cpp' | |||
323 | --- libclickscope/tests/test_index.cpp 2016-03-23 21:04:12 +0000 | |||
324 | +++ libclickscope/tests/test_index.cpp 2016-03-30 14:46:12 +0000 | |||
325 | @@ -1,5 +1,5 @@ | |||
326 | 1 | /* | 1 | /* |
328 | 2 | * Copyright (C) 2014-2016 Canonical Ltd. | 2 | * Copyright (C) 2014 Canonical Ltd. |
329 | 3 | * | 3 | * |
330 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
331 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
332 | @@ -190,18 +190,6 @@ | |||
333 | 190 | indexPtr->departments("departments", [](const click::DepartmentList&, const click::HighlightList&, click::Index::Error, int) {}); | 190 | indexPtr->departments("departments", [](const click::DepartmentList&, const click::HighlightList&, click::Index::Error, int) {}); |
334 | 191 | } | 191 | } |
335 | 192 | 192 | ||
336 | 193 | TEST_F(IndexTest, testDetailsSignsCall) | ||
337 | 194 | { | ||
338 | 195 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
339 | 196 | auto response = responseForReply(reply.asSharedPtr()); | ||
340 | 197 | |||
341 | 198 | EXPECT_CALL(*clientPtr, callImpl(_, _, true, _, _, _)) | ||
342 | 199 | .Times(1) | ||
343 | 200 | .WillOnce(Return(response)); | ||
344 | 201 | |||
345 | 202 | indexPtr->get_details("fake-app", [](const click::PackageDetails, click::Index::Error) {}); | ||
346 | 203 | } | ||
347 | 204 | |||
348 | 205 | TEST_F(IndexTest, testSearchSendsRightPath) | 193 | TEST_F(IndexTest, testSearchSendsRightPath) |
349 | 206 | { | 194 | { |
350 | 207 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 195 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
351 | 208 | 196 | ||
352 | === modified file 'libclickscope/tests/test_reviews.cpp' | |||
353 | --- libclickscope/tests/test_reviews.cpp 2016-03-25 14:08:14 +0000 | |||
354 | +++ libclickscope/tests/test_reviews.cpp 2016-03-30 14:46:12 +0000 | |||
355 | @@ -150,19 +150,6 @@ | |||
356 | 150 | click::Reviews::Error) {}); | 150 | click::Reviews::Error) {}); |
357 | 151 | } | 151 | } |
358 | 152 | 152 | ||
359 | 153 | TEST_F(ReviewsTest, testFetchReviewsDoesNotSignCall) | ||
360 | 154 | { | ||
361 | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | ||
362 | 156 | auto response = responseForReply(reply.asSharedPtr()); | ||
363 | 157 | |||
364 | 158 | EXPECT_CALL(*clientPtr, callImpl(_, _, false, _, _, _)) | ||
365 | 159 | .Times(1) | ||
366 | 160 | .WillOnce(Return(response)); | ||
367 | 161 | |||
368 | 162 | reviewsPtr->fetch_reviews("", [](click::ReviewList, | ||
369 | 163 | click::Reviews::Error) {}); | ||
370 | 164 | } | ||
371 | 165 | |||
372 | 166 | TEST_F(ReviewsTest, testFetchReviewsSendsQueryAsParam) | 153 | TEST_F(ReviewsTest, testFetchReviewsSendsQueryAsParam) |
373 | 167 | { | 154 | { |
374 | 168 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; | 155 | LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
375 | 169 | 156 | ||
376 | === modified file 'libclickscope/tests/test_webclient.cpp' | |||
377 | --- libclickscope/tests/test_webclient.cpp 2016-03-03 15:52:28 +0000 | |||
378 | +++ libclickscope/tests/test_webclient.cpp 2016-03-30 14:46:12 +0000 | |||
379 | @@ -221,9 +221,11 @@ | |||
380 | 221 | click::web::Client wc(namPtr); | 221 | click::web::Client wc(namPtr); |
381 | 222 | wc.setCredentialsService(ssoPtr); | 222 | wc.setCredentialsService(ssoPtr); |
382 | 223 | 223 | ||
386 | 224 | EXPECT_CALL(sso, getToken()) | 224 | EXPECT_CALL(sso, getCredentials()).WillOnce(Invoke([&](){ |
387 | 225 | .WillOnce(Return(UbuntuOne::Token("token_key", "token_secret", | 225 | UbuntuOne::Token token("token_key", "token_secret", |
388 | 226 | "consumer_key", "consumer_secret"))); | 226 | "consumer_key", "consumer_secret"); |
389 | 227 | sso.credentialsFound(token); | ||
390 | 228 | })); | ||
391 | 227 | EXPECT_CALL(nam, sendCustomRequest(IsValidOAuthHeader(true), _, _)) | 229 | EXPECT_CALL(nam, sendCustomRequest(IsValidOAuthHeader(true), _, _)) |
392 | 228 | .Times(1) | 230 | .Times(1) |
393 | 229 | .WillOnce(Return(replyPtr)); | 231 | .WillOnce(Return(replyPtr)); |
394 | @@ -269,7 +271,9 @@ | |||
395 | 269 | click::web::Client wc(namPtr); | 271 | click::web::Client wc(namPtr); |
396 | 270 | wc.setCredentialsService(ssoPtr); | 272 | wc.setCredentialsService(ssoPtr); |
397 | 271 | 273 | ||
399 | 272 | EXPECT_CALL(sso, getToken()).WillOnce(Return(UbuntuOne::Token())); | 274 | EXPECT_CALL(sso, getCredentials()).WillOnce(Invoke([&]() { |
400 | 275 | sso.credentialsNotFound(); | ||
401 | 276 | })); | ||
402 | 273 | EXPECT_CALL(nam, sendCustomRequest(IsValidOAuthHeader(false), _, _)) | 277 | EXPECT_CALL(nam, sendCustomRequest(IsValidOAuthHeader(false), _, _)) |
403 | 274 | .Times(1) | 278 | .Times(1) |
404 | 275 | .WillOnce(Return(replyPtr)); | 279 | .WillOnce(Return(replyPtr)); |
405 | 276 | 280 | ||
406 | === modified file 'scope/clickapps/apps-scope.cpp' | |||
407 | --- scope/clickapps/apps-scope.cpp 2016-03-01 16:46:30 +0000 | |||
408 | +++ scope/clickapps/apps-scope.cpp 2016-03-30 14:46:12 +0000 | |||
409 | @@ -81,8 +81,6 @@ | |||
410 | 81 | static const int zero = 0; | 81 | static const int zero = 0; |
411 | 82 | auto emptyCb = [this]() | 82 | auto emptyCb = [this]() |
412 | 83 | { | 83 | { |
413 | 84 | sso.reset(new click::CredentialsService()); | ||
414 | 85 | client->setCredentialsService(sso); | ||
415 | 86 | dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager()); | 84 | dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager()); |
416 | 87 | }; | 85 | }; |
417 | 88 | 86 | ||
418 | 89 | 87 | ||
419 | === modified file 'scope/clickapps/apps-scope.h' | |||
420 | --- scope/clickapps/apps-scope.h 2016-03-01 16:46:30 +0000 | |||
421 | +++ scope/clickapps/apps-scope.h 2016-03-30 14:46:12 +0000 | |||
422 | @@ -71,7 +71,6 @@ | |||
423 | 71 | QSharedPointer<click::Index> index; | 71 | QSharedPointer<click::Index> index; |
424 | 72 | QSharedPointer<pay::Package> pay_package; | 72 | QSharedPointer<pay::Package> pay_package; |
425 | 73 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; | 73 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; |
426 | 74 | QSharedPointer<click::CredentialsService> sso; | ||
427 | 75 | std::shared_ptr<click::DepartmentsDb> depts_db; | 74 | std::shared_ptr<click::DepartmentsDb> depts_db; |
428 | 76 | 75 | ||
429 | 77 | std::string installApplication(unity::scopes::Result const& result); | 76 | std::string installApplication(unity::scopes::Result const& result); |
430 | 78 | 77 | ||
431 | === modified file 'scope/clickstore/store-scope.cpp' | |||
432 | --- scope/clickstore/store-scope.cpp 2016-03-23 21:04:12 +0000 | |||
433 | +++ scope/clickstore/store-scope.cpp 2016-03-30 14:46:12 +0000 | |||
434 | @@ -83,8 +83,6 @@ | |||
435 | 83 | static const int zero = 0; | 83 | static const int zero = 0; |
436 | 84 | auto emptyCb = [this]() | 84 | auto emptyCb = [this]() |
437 | 85 | { | 85 | { |
438 | 86 | sso.reset(new click::CredentialsService()); | ||
439 | 87 | client->setCredentialsService(sso); | ||
440 | 88 | dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager()); | 86 | dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager()); |
441 | 89 | }; | 87 | }; |
442 | 90 | 88 | ||
443 | 91 | 89 | ||
444 | === modified file 'scope/clickstore/store-scope.h' | |||
445 | --- scope/clickstore/store-scope.h 2016-02-29 21:58:00 +0000 | |||
446 | +++ scope/clickstore/store-scope.h 2016-03-30 14:46:12 +0000 | |||
447 | @@ -74,7 +74,6 @@ | |||
448 | 74 | QSharedPointer<click::Index> index; | 74 | QSharedPointer<click::Index> index; |
449 | 75 | QSharedPointer<pay::Package> pay_package; | 75 | QSharedPointer<pay::Package> pay_package; |
450 | 76 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; | 76 | QSharedPointer<Ubuntu::DownloadManager::Manager> dm; |
451 | 77 | QSharedPointer<click::CredentialsService> sso; | ||
452 | 78 | std::shared_ptr<click::DepartmentLookup> depts; | 77 | std::shared_ptr<click::DepartmentLookup> depts; |
453 | 79 | std::shared_ptr<click::HighlightList> highlights; | 78 | std::shared_ptr<click::HighlightList> highlights; |
454 | 80 | std::shared_ptr<click::DepartmentsDb> depts_db; | 79 | std::shared_ptr<click::DepartmentsDb> depts_db; |
Looks ok.