Merge lp:~diegosarmentero/ubuntu-system-settings/check-hash into lp:ubuntu-system-settings

Proposed by Diego Sarmentero
Status: Merged
Merged at revision: 1268
Proposed branch: lp:~diegosarmentero/ubuntu-system-settings/check-hash
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~diegosarmentero/ubuntu-system-settings/account-detected
Diff against target: 243 lines (+82/-8)
8 files modified
plugins/system-update/PageComponent.qml (+7/-5)
plugins/system-update/download_tracker.cpp (+2/-1)
plugins/system-update/download_tracker.h (+5/-1)
plugins/system-update/network/network.cpp (+2/-0)
plugins/system-update/update.cpp (+1/-0)
plugins/system-update/update.h (+5/-0)
plugins/system-update/update_manager.cpp (+0/-1)
tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py (+60/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-system-settings/check-hash
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sebastien Bacher (community) Needs Information
Review via email: mp+236554@code.launchpad.net

Commit message

- Check click hash

Description of the change

To test this branch in the device you can set the environment variable URL_APPS to http://localhost:8000/iteminfo/ (best to do it in /etc/environments and restart). Then execute the python script added in this branch, and open System Updates to see an update on the calculator, which should fail because of the invalid hash

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
Sebastien Bacher (seb128) wrote :

Thanks, that looks fine to me but do you have any hint on how to test the change?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1055. By Diego Sarmentero

fixing click update sign flow

1056. By Diego Sarmentero

remove unnecesary use of secondary urls

1057. By Diego Sarmentero

[ jonas-drange ]
* [wifi/phone] dynamically chooses what SIM to use when there's only
  one present. (LP: #1375832)
[ Iain Lane ]
* [storage/about] Use a QSharedPointer to manage freeing of the
  counter which we use to display all of the collected sizes at once.
  If the measuring process was cancelled, we were freeing it multiple
  times - once for each outstanding size measurement. This led to a
  crash. (LP: #1375988)
* [security-privacy] Link with gobject, uses symbols from this
  library. Prevents "[…]libUbuntuSecurityPrivacyPanel.so contains an
  unresolvable reference to symbol
  g_signal_handlers_disconnect_matched: it's probably a plugin"
  warnings.
[ jonas-drange ]
* [cellular] react to application.state changes and update potential
  out-of-date default SIM settings (LP: #1364103)
* [wifi] let removed networks update the previous network model so
  that we can reuse the model (and not pop the pagestack twice,
  causing this ux issue) (LP: #1370389)
[ Sebastien Bacher ]
* [location] use a flickable so the list can be scrolled (LP:
  #1374017)
* [security] get localized application names from the trust-store (LP:
  #1374018)
[ Ken VanDine ]
* Fixed handling of the Downloading/Installing label based on actual
  state. . Forward updateProgress signals for system updates. Layout
  fixes (LP: #1312587)
* Use new splash screen (LP: #1376242)
* Improved tracking download states
* Use new target_build_number from system-image-dbus to determine
  visibility of the update notification (LP: #1355803)
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [storage] use libclick rather than calling the command line (LP:
  #1368967)
* [storage] tweaks to the disk informations, limit the free space to
  the user available one (excluding the system partitions), don't list
  the external mounts, that's described in the design and is going to
  require work on the categories computation to give correct values
  (LP: #1284247)
* [about] display the free space value next to the storage label (LP:
  #1335144)
[ Albert Astals ]
* Add i18n.tr
[ jonas-drange ]
* [wifi] connect to hidden network is now a dialog (LP: #1366005)
[ Ken VanDine ]
* Provide more keywords to make search useful (LP: #1370219) (LP:
  #1370219)
* [background] set sourceSize in the image preview to work around an
  issue loading large images (LP: #1373462)
[ CI bot ]
* Resync trunk
[ Mathieu Trudel-Lapierre ]
* [bluetooth] Properly handle device types for connection and
  disconnection. (LP: #1369964)
[ Michael Terry ]
* Add a translator comment for what HERE means. (LP: #1368838) (LP:
  #1368838)
* Prevent a crash in unity8 when the wizard also crashes or stops
  early. (LP: #1355892) (LP: #1355892)
[ Michael Terry ]
* Prevent the buttons of the wizard's password page from overlapping
  its content when the OSK appears. (LP: #1368346) (LP: #1368346)
[ Ken VanDine ]
* Set the version information in the SystemUpdate constructor (LP:
  #1371810) (LP: #1371810)
* [reset] Don't bail out on an isValid() check on the SystemImage
  QDBusInterface, the docs say isValid() may not be reliable for
  remote interfaces (LP: #1370815) (LP: #1370815)
* Fixed reference error for count on the various device models (LP:
  #1362517) (LP: #1362517)
* [background] Use the ContentPeerPicker to select sources for
  backgrounds (LP: #1356542) (LP: #1356542)
[ Iain Lane ]
* Don't check if the timedated interface is valid before calling
  SetTime on it, it might have timed out and we should reactivate it
  in that case.
* [about] Fix developerMode property to be QMLish - read & write
  instead of separate "read" and "toggle" properties.
* [about] Don't display a frame for icons that can't be found,
  improving the visual appearance. Also return the correct path for
  click packages which use the icon theme.
[ Sebastien Bacher ]
* [storage] handle the scope click .ini and get the correct icons (LP:
  #1368920)
[ Albert Astals ]
* make pot
[ Oliver Grawert ]
* fix LP: #1365903, add a watch to Developer Mode page so the page
  gets refreshed when going back through the page stack, also fix the
  page id and bounds (LP: #1365903)
* Some packaging fixes
  - > is not a valid relationship. It should be >>
  - Don't recommend suru-icon-theme since we also depend on it
  - Bump S-V to 3.9.6 which for example allows the images we ship in
    /usr/lib/
  - Override binary-no-manpage lintian warnings. We're not going to get man
    pages for u-s-s any time soon
[ Ken VanDine ]
* Make UpdateManager a singleton and refresh the availableUpdates
  count when the model updates (LP: #1325629) (LP: #1325629)
[ Ken VanDine ]
* Include an icon instead of using the themed icon (LP: #1365408) (LP:
  #1365408)
[ Mathieu Trudel-Lapierre ]
* [bluetooth] don't try to enable Discoverable if the device isn't
  powered yet. (LP: #1355904)
[ Ken VanDine ]
* When activated by a url request for a specific panel, clear the
  pageStack to maintain the natural navigation instead of pushing a
  new page on top of a page from a the previous panel (LP: #1362025)
  (LP: #1362025, #1359953)
[ Lars Uebernickel ]
* Use Icon instead of StatusIcon
[ CI bot ]
* Resync trunk
[ John R. Lenton ]
* Take the system settings push helper closer to implementing the spec
  at https://wiki.ubuntu.com/SoftwareUpdates#Prompting (LP: #1363972)

1058. By Diego Sarmentero

improve resume for tracker

Revision history for this message
Charles Kerr (charlesk) wrote :

The code looks good for getting the checksum and making it available to QML, but unless I'm misreading, it doesn't take the final step of showing it to the user?

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> The code looks good for getting the checksum and making it available to QML,
> but unless I'm misreading, it doesn't take the final step of showing it to the
> user?

Yes, the Download Manager will check the checksum after the download is complete, and if that fails it will emit an Error signal with the text that is going to be displayed in the Update item in the UI.

Revision history for this message
Sebastien Bacher (seb128) wrote :

not sure why CI didn't do a build of the current revision, I gave it a retry...
the code looks fine other

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

running the testcase is not working, the test server displays those error

  File "/tmp/mock_update_click_server.py", line 31, in response_item_info
    self.wfile.write(bytes(json.dumps(response), 'UTF-8'))
  File "/usr/lib/python3.4/socket.py", line 391, in write
    return self._sock.send(b)
BrokenPipeError: [Errno 32] Broken pipe

The UI displays a bar going to 100% but no error

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/system-update/PageComponent.qml'
--- plugins/system-update/PageComponent.qml 2014-10-08 15:51:44 +0000
+++ plugins/system-update/PageComponent.qml 2014-10-17 11:45:42 +0000
@@ -420,17 +420,18 @@
420420
421 function resume () {421 function resume () {
422 console.warn("RESUME: " + modelData.packageName);422 console.warn("RESUME: " + modelData.packageName);
423 if (modelData.systemUpdate)423 UpdateManager.startDownload(modelData.packageName);
424 return UpdateManager.startDownload(modelData.packageName);
425 modelData.updateState = true;
426 tracker.resume();
427 }424 }
428425
429 function start () {426 function start () {
430 console.warn("START: " + modelData.packageName);427 console.warn("START: " + modelData.packageName);
428 if (!modelData.selected || modelData.systemUpdate) {
429 UpdateManager.startDownload(modelData.packageName);
430 } else {
431 tracker.resume();
432 }
431 modelData.selected = true;433 modelData.selected = true;
432 modelData.updateState = true;434 modelData.updateState = true;
433 UpdateManager.startDownload(modelData.packageName);
434 }435 }
435 Column {436 Column {
436 id: textArea437 id: textArea
@@ -561,6 +562,7 @@
561 packageName: modelData.packageName562 packageName: modelData.packageName
562 clickToken: modelData.clickToken563 clickToken: modelData.clickToken
563 download: modelData.downloadUrl564 download: modelData.downloadUrl
565 downloadSha512: modelData.downloadSha512
564566
565 onFinished: {567 onFinished: {
566 progress.visible = false;568 progress.visible = false;
567569
=== modified file 'plugins/system-update/download_tracker.cpp'
--- plugins/system-update/download_tracker.cpp 2014-09-30 02:05:36 +0000
+++ plugins/system-update/download_tracker.cpp 2014-10-17 11:45:42 +0000
@@ -27,6 +27,7 @@
27#define DOWNLOAD_COMMAND "post-download-command"27#define DOWNLOAD_COMMAND "post-download-command"
28#define APP_ID "app_id"28#define APP_ID "app_id"
29#define PKCON_COMMAND "pkcon"29#define PKCON_COMMAND "pkcon"
30#define DOWNLOAD_MANAGER_SHA512 "sha512"
3031
31namespace UpdatePlugin {32namespace UpdatePlugin {
3233
@@ -81,7 +82,7 @@
81 vmap[APP_ID] = m_packageName;82 vmap[APP_ID] = m_packageName;
82 StringMap map;83 StringMap map;
83 map[X_CLICK_TOKEN] = m_clickToken;84 map[X_CLICK_TOKEN] = m_clickToken;
84 DownloadStruct dstruct = DownloadStruct(m_downloadUrl, vmap, map);85 DownloadStruct dstruct = DownloadStruct(m_downloadUrl, m_download_sha512, DOWNLOAD_MANAGER_SHA512, vmap, map);
85 m_manager->createDownload(dstruct);86 m_manager->createDownload(dstruct);
86 }87 }
87}88}
8889
=== modified file 'plugins/system-update/download_tracker.h'
--- plugins/system-update/download_tracker.h 2014-09-30 02:05:36 +0000
+++ plugins/system-update/download_tracker.h 2014-10-17 11:45:42 +0000
@@ -42,6 +42,7 @@
42 Q_PROPERTY(QString clickToken READ clickToken WRITE setClickToken)42 Q_PROPERTY(QString clickToken READ clickToken WRITE setClickToken)
43 Q_PROPERTY(QString download READ download WRITE setDownload)43 Q_PROPERTY(QString download READ download WRITE setDownload)
44 Q_PROPERTY(QString packageName READ packageName WRITE setPackageName)44 Q_PROPERTY(QString packageName READ packageName WRITE setPackageName)
45 Q_PROPERTY(QString downloadSha512 READ downloadSha512 WRITE setDownloadSha512)
45 Q_PROPERTY(int progress READ progress NOTIFY progressChanged)46 Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
4647
47public:48public:
@@ -54,10 +55,12 @@
54 QString download() { return m_downloadUrl; }55 QString download() { return m_downloadUrl; }
55 QString clickToken() { return m_clickToken; }56 QString clickToken() { return m_clickToken; }
56 QString packageName() { return m_packageName; }57 QString packageName() { return m_packageName; }
58 QString downloadSha512() { return m_download_sha512; }
59 int progress() { return m_progress; }
57 void setDownload(const QString& url);60 void setDownload(const QString& url);
58 void setClickToken(const QString& token);61 void setClickToken(const QString& token);
59 void setPackageName(const QString& package);62 void setPackageName(const QString& package);
60 int progress() { return m_progress; }63 void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; }
6164
62public Q_SLOTS:65public Q_SLOTS:
63 void bindDownload(Download* download);66 void bindDownload(Download* download);
@@ -82,6 +85,7 @@
82 Download* m_download;85 Download* m_download;
83 Manager* m_manager;86 Manager* m_manager;
84 int m_progress;87 int m_progress;
88 QString m_download_sha512;
8589
86 void startService();90 void startService();
87 QString getPkconCommand();91 QString getPkconCommand();
8892
=== modified file 'plugins/system-update/network/network.cpp'
--- plugins/system-update/network/network.cpp 2014-09-18 13:50:15 +0000
+++ plugins/system-update/network/network.cpp 2014-10-17 11:45:42 +0000
@@ -107,6 +107,7 @@
107 QString version = object.value("version").toString();107 QString version = object.value("version").toString();
108 QString icon_url = object.value("icon_url").toString();108 QString icon_url = object.value("icon_url").toString();
109 QString url = object.value("download_url").toString();109 QString url = object.value("download_url").toString();
110 QString download_sha512 = object.value("download_sha512").toString();
110 int size = object.value("binary_filesize").toVariant().toInt();111 int size = object.value("binary_filesize").toVariant().toInt();
111 if (m_apps.contains(name)) {112 if (m_apps.contains(name)) {
112 m_apps[name]->setRemoteVersion(version);113 m_apps[name]->setRemoteVersion(version);
@@ -114,6 +115,7 @@
114 m_apps[name]->setIconUrl(icon_url);115 m_apps[name]->setIconUrl(icon_url);
115 m_apps[name]->setDownloadUrl(url);116 m_apps[name]->setDownloadUrl(url);
116 m_apps[name]->setBinaryFilesize(size);117 m_apps[name]->setBinaryFilesize(size);
118 m_apps[name]->setDownloadSha512(download_sha512);
117 updates = true;119 updates = true;
118 }120 }
119 }121 }
120122
=== modified file 'plugins/system-update/update.cpp'
--- plugins/system-update/update.cpp 2014-09-12 23:47:39 +0000
+++ plugins/system-update/update.cpp 2014-10-17 11:45:42 +0000
@@ -29,6 +29,7 @@
29 QObject(parent),29 QObject(parent),
30 m_binary_filesize(0),30 m_binary_filesize(0),
31 m_click_url(""),31 m_click_url(""),
32 m_clickToken(""),
32 m_downloadUrl(""),33 m_downloadUrl(""),
33 m_download_progress(0),34 m_download_progress(0),
34 m_error(""),35 m_error(""),
3536
=== modified file 'plugins/system-update/update.h'
--- plugins/system-update/update.h 2014-09-12 19:12:36 +0000
+++ plugins/system-update/update.h 2014-10-17 11:45:42 +0000
@@ -57,6 +57,7 @@
57 NOTIFY downloadProgressChanged)57 NOTIFY downloadProgressChanged)
58 Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY downloadUrlChanged)58 Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY downloadUrlChanged)
59 Q_PROPERTY(QString clickToken READ clickToken NOTIFY clickTokenChanged)59 Q_PROPERTY(QString clickToken READ clickToken NOTIFY clickTokenChanged)
60 Q_PROPERTY(QString downloadSha512 READ downloadSha512 NOTIFY downloadSha512Changed)
6061
61Q_SIGNALS:62Q_SIGNALS:
62 void systemUpdateChanged();63 void systemUpdateChanged();
@@ -75,6 +76,7 @@
75 void downloadUrlChanged();76 void downloadUrlChanged();
76 void clickTokenChanged();77 void clickTokenChanged();
77 void packageNameChanged();78 void packageNameChanged();
79 void downloadSha512Changed();
7880
79public:81public:
80 explicit Update(QObject *parent = 0);82 explicit Update(QObject *parent = 0);
@@ -97,6 +99,7 @@
97 const QString& getClickUrl() const { return m_click_url; }99 const QString& getClickUrl() const { return m_click_url; }
98 QString downloadUrl() { return m_downloadUrl; }100 QString downloadUrl() { return m_downloadUrl; }
99 QString clickToken() { return m_clickToken; }101 QString clickToken() { return m_clickToken; }
102 QString downloadSha512() { return m_download_sha512; }
100103
101 void setSystemUpdate(bool isSystem);104 void setSystemUpdate(bool isSystem);
102 void initializeApplication(QString packagename, QString title,105 void initializeApplication(QString packagename, QString title,
@@ -115,6 +118,7 @@
115 void setClickUrl(const QString &url) { m_click_url = url; }118 void setClickUrl(const QString &url) { m_click_url = url; }
116 void setDownloadUrl(const QString &url);119 void setDownloadUrl(const QString &url);
117 void setClickToken(const QString &token) { m_clickToken = token; Q_EMIT clickTokenChanged(); }120 void setClickToken(const QString &token) { m_clickToken = token; Q_EMIT clickTokenChanged(); }
121 void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; Q_EMIT downloadSha512Changed(); }
118122
119private:123private:
120 int m_binary_filesize;124 int m_binary_filesize;
@@ -134,6 +138,7 @@
134 bool m_update;138 bool m_update;
135 bool m_update_ready;139 bool m_update_ready;
136 bool m_update_state;140 bool m_update_state;
141 QString m_download_sha512;
137142
138 bool getIgnoreUpdates();143 bool getIgnoreUpdates();
139};144};
140145
=== modified file 'plugins/system-update/update_manager.cpp'
--- plugins/system-update/update_manager.cpp 2014-10-08 15:51:44 +0000
+++ plugins/system-update/update_manager.cpp 2014-10-17 11:45:42 +0000
@@ -321,7 +321,6 @@
321{321{
322 app->setError("");322 app->setError("");
323 app->setClickToken(clickToken);323 app->setClickToken(clickToken);
324 app->setDownloadUrl(app->getClickUrl());
325}324}
326325
327void UpdateManager::updateClickScope()326void UpdateManager::updateClickScope()
328327
=== added file 'tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py'
--- tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 2014-10-17 11:45:42 +0000
@@ -0,0 +1,60 @@
1import json
2import threading
3from http.server import BaseHTTPRequestHandler, HTTPServer
4
5
6KEEP_ALIVE = True
7
8
9class MyHandler(BaseHTTPRequestHandler):
10
11 def do_HEAD(self):
12 self.send_response(200)
13 self.send_header("X-Click-Token", "X-Click-Token")
14 self.end_headers()
15
16 def response_item_info(self):
17 response = [{
18 "name": "com.ubuntu.calculator",
19 "version": "9.0",
20 "icon_url": ("https://raw.githubusercontent.com/ninja-ide/"
21 "ninja-ide/master/ninja_ide/img/ninja_icon.png"),
22 "download_url": ("https://public.apps.ubuntu.com/download/com."
23 "ubuntu/calculator/com.ubuntu.calculator_1"
24 ".3.329_all.click"),
25 "binary_filesize": 3423,
26 "download_sha512": "343244fsdfdsffs"
27 }]
28 self.send_response(200)
29 self.send_header("Content-type", "application/json")
30 self.end_headers()
31 self.wfile.write(bytes(json.dumps(response), 'UTF-8'))
32
33 def do_POST(self):
34 """Respond to a POST request."""
35 self.do_GET()
36
37 def do_GET(self):
38 """Respond to a GET request."""
39 if self.path.find("iteminfo/") != -1:
40 self.response_item_info()
41 elif self.path.find("shutdown") != -1:
42 global KEEP_ALIVE
43 KEEP_ALIVE = False
44
45
46def run_click_server():
47 server_address = ('', 8000)
48 httpd = HTTPServer(server_address, MyHandler)
49 global KEEP_ALIVE
50 print('start')
51 while KEEP_ALIVE:
52 httpd.handle_request()
53
54
55def run_mocked_settings():
56 t = threading.Thread(target=run_click_server)
57 t.start()
58
59
60run_mocked_settings()

Subscribers

People subscribed via source and target branches