Merge lp:~ken-vandine/ubuntu-system-settings/rtm-check-hash into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/rtm-check-hash
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 224 lines (+77/-5)
7 files modified
plugins/system-update/PageComponent.qml (+1/-0)
plugins/system-update/download_tracker.cpp (+3/-4)
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)
tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py (+60/-0)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm-check-hash
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+247489@code.launchpad.net

Commit message

[system-update] Add support for checksum validation.

Description of the change

This branch uses the download manager checksum support. Rather than checking for the checksum in the system settings application this is relayed to the download manager which will check the file against the given signature. If the signature passes everything continues as expected else, udm will emit an error signal and the download will be considered a failure.

Instructions to test this can be found in the test plan https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-system-settings

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 :

Ken, do you have hints on how to test those changes?

Small stylistic comments
- why do you reorder an include in non alphabetic order?
- the extra new line after includes don't look necessary

review: Needs Information
974. By Ken VanDine

reorder includes to be alphabetical and removed a blank line

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

thanks

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

seems like we are not doing more rtm landing, so cleaning the list a bit, that one is rather going to be including with the vivid rebase

Unmerged revisions

974. By Ken VanDine

reorder includes to be alphabetical and removed a blank line

973. By Ken VanDine

[system-update] Add support for checksum validation.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/PageComponent.qml'
2--- plugins/system-update/PageComponent.qml 2015-01-30 18:36:21 +0000
3+++ plugins/system-update/PageComponent.qml 2015-02-26 19:00:45 +0000
4@@ -538,6 +538,7 @@
5 packageName: modelData.packageName
6 clickToken: modelData.clickToken
7 download: modelData.downloadUrl
8+ downloadSha512: modelData.downloadSha512
9
10 onFinished: {
11 progress.visible = false;
12
13=== modified file 'plugins/system-update/download_tracker.cpp'
14--- plugins/system-update/download_tracker.cpp 2015-01-15 11:08:33 +0000
15+++ plugins/system-update/download_tracker.cpp 2015-02-26 19:00:45 +0000
16@@ -1,5 +1,5 @@
17 /*
18- * Copyright (C) 2014 - Canonical Ltd.
19+ * Copyright (C) 2014-2015 - Canonical Ltd.
20 *
21 * This program is free software: you can redistribute it and/or modify it
22 * under the terms of the GNU Lesser General Public License, as
23@@ -18,9 +18,7 @@
24 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
25 */
26
27-#include <QDebug>
28 #include <QProcessEnvironment>
29-
30 #include <ubuntu/download_manager/download_struct.h>
31 #include <ubuntu/download_manager/error.h>
32
33@@ -31,6 +29,7 @@
34 const QString DOWNLOAD_COMMAND = "post-download-command";
35 const QString APP_ID = "app_id";
36 const QString PKCON_COMMAND = "pkcon";
37+ const QString DOWNLOAD_MANAGER_SHA512 = "sha512";
38 }
39
40 namespace UpdatePlugin {
41@@ -88,7 +87,7 @@
42 vmap[APP_ID] = m_packageName;
43 StringMap map;
44 map[X_CLICK_TOKEN] = m_clickToken;
45- DownloadStruct dstruct = DownloadStruct(m_downloadUrl, vmap, map);
46+ DownloadStruct dstruct(m_downloadUrl, m_download_sha512, DOWNLOAD_MANAGER_SHA512, vmap, map);
47 m_manager->createDownload(dstruct);
48 }
49 }
50
51=== modified file 'plugins/system-update/download_tracker.h'
52--- plugins/system-update/download_tracker.h 2015-01-14 11:23:42 +0000
53+++ plugins/system-update/download_tracker.h 2015-02-26 19:00:45 +0000
54@@ -42,6 +42,7 @@
55 Q_PROPERTY(QString clickToken READ clickToken WRITE setClickToken)
56 Q_PROPERTY(QString download READ download WRITE setDownload)
57 Q_PROPERTY(QString packageName READ packageName WRITE setPackageName)
58+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 WRITE setDownloadSha512)
59 Q_PROPERTY(int progress READ progress NOTIFY progressChanged)
60
61 public:
62@@ -54,10 +55,12 @@
63 QString download() { return m_downloadUrl; }
64 QString clickToken() { return m_clickToken; }
65 QString packageName() { return m_packageName; }
66+ QString downloadSha512() { return m_download_sha512; }
67+ int progress() { return m_progress; }
68 void setDownload(const QString& url);
69 void setClickToken(const QString& token);
70 void setPackageName(const QString& package);
71- int progress() { return m_progress; }
72+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; }
73
74 public Q_SLOTS:
75 void bindDownload(Download* download);
76@@ -84,6 +87,7 @@
77 Download* m_download = nullptr;
78 Manager* m_manager = nullptr;
79 int m_progress = 0;
80+ QString m_download_sha512 = QString::null;
81
82 void startService();
83 QString getPkconCommand();
84
85=== modified file 'plugins/system-update/network/network.cpp'
86--- plugins/system-update/network/network.cpp 2014-09-18 13:50:15 +0000
87+++ plugins/system-update/network/network.cpp 2015-02-26 19:00:45 +0000
88@@ -107,6 +107,7 @@
89 QString version = object.value("version").toString();
90 QString icon_url = object.value("icon_url").toString();
91 QString url = object.value("download_url").toString();
92+ QString download_sha512 = object.value("download_sha512").toString();
93 int size = object.value("binary_filesize").toVariant().toInt();
94 if (m_apps.contains(name)) {
95 m_apps[name]->setRemoteVersion(version);
96@@ -114,6 +115,7 @@
97 m_apps[name]->setIconUrl(icon_url);
98 m_apps[name]->setDownloadUrl(url);
99 m_apps[name]->setBinaryFilesize(size);
100+ m_apps[name]->setDownloadSha512(download_sha512);
101 updates = true;
102 }
103 }
104
105=== modified file 'plugins/system-update/update.cpp'
106--- plugins/system-update/update.cpp 2015-01-14 11:23:42 +0000
107+++ plugins/system-update/update.cpp 2015-02-26 19:00:45 +0000
108@@ -32,6 +32,7 @@
109 QObject(parent),
110 m_binary_filesize(0),
111 m_click_url(""),
112+ m_clickToken(""),
113 m_downloadUrl(""),
114 m_download_progress(0),
115 m_error(""),
116
117=== modified file 'plugins/system-update/update.h'
118--- plugins/system-update/update.h 2014-09-12 19:12:36 +0000
119+++ plugins/system-update/update.h 2015-02-26 19:00:45 +0000
120@@ -57,6 +57,7 @@
121 NOTIFY downloadProgressChanged)
122 Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY downloadUrlChanged)
123 Q_PROPERTY(QString clickToken READ clickToken NOTIFY clickTokenChanged)
124+ Q_PROPERTY(QString downloadSha512 READ downloadSha512 NOTIFY downloadSha512Changed)
125
126 Q_SIGNALS:
127 void systemUpdateChanged();
128@@ -75,6 +76,7 @@
129 void downloadUrlChanged();
130 void clickTokenChanged();
131 void packageNameChanged();
132+ void downloadSha512Changed();
133
134 public:
135 explicit Update(QObject *parent = 0);
136@@ -97,6 +99,7 @@
137 const QString& getClickUrl() const { return m_click_url; }
138 QString downloadUrl() { return m_downloadUrl; }
139 QString clickToken() { return m_clickToken; }
140+ QString downloadSha512() { return m_download_sha512; }
141
142 void setSystemUpdate(bool isSystem);
143 void initializeApplication(QString packagename, QString title,
144@@ -115,6 +118,7 @@
145 void setClickUrl(const QString &url) { m_click_url = url; }
146 void setDownloadUrl(const QString &url);
147 void setClickToken(const QString &token) { m_clickToken = token; Q_EMIT clickTokenChanged(); }
148+ void setDownloadSha512(const QString &sha512) { m_download_sha512 = sha512; Q_EMIT downloadSha512Changed(); }
149
150 private:
151 int m_binary_filesize;
152@@ -134,6 +138,7 @@
153 bool m_update;
154 bool m_update_ready;
155 bool m_update_state;
156+ QString m_download_sha512;
157
158 bool getIgnoreUpdates();
159 };
160
161=== added file 'tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py'
162--- tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 1970-01-01 00:00:00 +0000
163+++ tests/autopilot/ubuntu_system_settings/utils/mock_update_click_server.py 2015-02-26 19:00:45 +0000
164@@ -0,0 +1,60 @@
165+import json
166+import threading
167+from http.server import BaseHTTPRequestHandler, HTTPServer
168+
169+
170+KEEP_ALIVE = True
171+
172+
173+class MyHandler(BaseHTTPRequestHandler):
174+
175+ def do_HEAD(self):
176+ self.send_response(200)
177+ self.send_header("X-Click-Token", "X-Click-Token")
178+ self.end_headers()
179+
180+ def response_item_info(self):
181+ response = [{
182+ "name": "com.ubuntu.calculator",
183+ "version": "9.0",
184+ "icon_url": ("https://raw.githubusercontent.com/ninja-ide/"
185+ "ninja-ide/master/ninja_ide/img/ninja_icon.png"),
186+ "download_url": ("https://public.apps.ubuntu.com/download/com."
187+ "ubuntu/calculator/com.ubuntu.calculator_1"
188+ ".3.329_all.click"),
189+ "binary_filesize": 3423,
190+ "download_sha512": "343244fsdfdsffs"
191+ }]
192+ self.send_response(200)
193+ self.send_header("Content-type", "application/json")
194+ self.end_headers()
195+ self.wfile.write(bytes(json.dumps(response), 'UTF-8'))
196+
197+ def do_POST(self):
198+ """Respond to a POST request."""
199+ self.do_GET()
200+
201+ def do_GET(self):
202+ """Respond to a GET request."""
203+ if self.path.find("iteminfo/") != -1:
204+ self.response_item_info()
205+ elif self.path.find("shutdown") != -1:
206+ global KEEP_ALIVE
207+ KEEP_ALIVE = False
208+
209+
210+def run_click_server():
211+ server_address = ('', 8000)
212+ httpd = HTTPServer(server_address, MyHandler)
213+ global KEEP_ALIVE
214+ print('start')
215+ while KEEP_ALIVE:
216+ httpd.handle_request()
217+
218+
219+def run_mocked_settings():
220+ t = threading.Thread(target=run_click_server)
221+ t.start()
222+
223+
224+run_mocked_settings()

Subscribers

People subscribed via source and target branches