Merge lp:~jdstrand/click-reviewers-tools/lp1346481 into lp:click-reviewers-tools
- lp1346481
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 213 | ||||
Proposed branch: | lp:~jdstrand/click-reviewers-tools/lp1346481 | ||||
Merge into: | lp:click-reviewers-tools | ||||
Diff against target: |
790 lines (+539/-17) 13 files modified
bin/click-check-push-helper (+31/-0) bin/click-run-checks (+4/-0) bin/click-show-files (+13/-0) clickreviews/cr_common.py (+2/-1) clickreviews/cr_desktop.py (+5/-1) clickreviews/cr_lint.py (+15/-5) clickreviews/cr_push_helper.py (+132/-0) clickreviews/cr_security.py (+44/-4) clickreviews/cr_tests.py (+43/-1) clickreviews/tests/test_cr_lint.py (+26/-4) clickreviews/tests/test_cr_push_helper.py (+138/-0) clickreviews/tests/test_cr_security.py (+84/-0) debian/changelog (+2/-1) |
||||
To merge this branch: | bzr merge lp:~jdstrand/click-reviewers-tools/lp1346481 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Martin Albisetti (community) | Approve | ||
Review via email: mp+228187@code.launchpad.net |
Commit message
Description of the change
add push-helper checks:
- add bin/click-
- add clickreviews/
- add clickreviews/
- update bin/click-
- update bin/click-
- update clickreviews/
clickreviews/
- skip missing desktop hook with push-helper
- comment out noisy msg()
clickreviews/
- add push-helper as known hook
- allow multiple apps in click, but not multiple desktop apps
- clarify check_hooks() error
clickreviews/
clickreviews/
- add template tests for push-helper
- add policy_groups tests for push-helper
- clarify check_policy_
clickreviews/
clickreviews/
- 226. By Jamie Strandboge
-
merge with trunk:
[ Daniel Holbach ]
refer to documentation about click in case we encounter .deb packages. - 227. By Jamie Strandboge
-
clickreviews/
cr_common. py: fix pep8 error
John Lenton (chipaca) wrote : | # |
Martin Albisetti (beuno) wrote : | # |
312 + if 'push-helper' not in self.manifest[
313 + # self._add_result(t, n, s)
314 + continue
Why the commenting out?
(the same a few lines lower)
LGTM otherwise.
- 228. By Jamie Strandboge
-
clickreviews/
cr_security. py: remove confusing comment from
check_template_push_helpers( ) - 229. By Jamie Strandboge
-
clickreviews/
cr_security. py: remove confusing comment from
check_policy_ groups_ push_helpers( )
Jamie Strandboge (jdstrand) wrote : | # |
> 312 + if 'push-helper' not in self.manifest[
> 313 + # self._add_result(t, n, s)
> 314 + continue
>
> Why the commenting out?
> (the same a few lines lower)
>
Ah, these should have been omitted from the commit. Fixed. (There is no reason to run this test if the app doesn't specify a push-helper hook).
>
> LGTM otherwise.
Thanks!
John Lenton (chipaca) : | # |
Jamie Strandboge (jdstrand) wrote : | # |
Thanks for the reviews! :)
Preview Diff
1 | === added file 'bin/click-check-push-helper' | |||
2 | --- bin/click-check-push-helper 1970-01-01 00:00:00 +0000 | |||
3 | +++ bin/click-check-push-helper 2014-07-24 21:41:48 +0000 | |||
4 | @@ -0,0 +1,31 @@ | |||
5 | 1 | #!/usr/bin/python3 | ||
6 | 2 | '''click-check-push-helper: perform click push-helper checks''' | ||
7 | 3 | # | ||
8 | 4 | # Copyright (C) 2014 Canonical Ltd. | ||
9 | 5 | # | ||
10 | 6 | # This program is free software: you can redistribute it and/or modify | ||
11 | 7 | # it under the terms of the GNU General Public License as published by | ||
12 | 8 | # the Free Software Foundation; version 3 of the License. | ||
13 | 9 | # | ||
14 | 10 | # This program is distributed in the hope that it will be useful, | ||
15 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | 13 | # GNU General Public License for more details. | ||
18 | 14 | # | ||
19 | 15 | # You should have received a copy of the GNU General Public License | ||
20 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | 17 | |||
22 | 18 | from __future__ import print_function | ||
23 | 19 | import sys | ||
24 | 20 | |||
25 | 21 | import clickreviews.cr_common as cr_common | ||
26 | 22 | import clickreviews.cr_push_helper as cr_push_helper | ||
27 | 23 | |||
28 | 24 | if __name__ == "__main__": | ||
29 | 25 | if len(sys.argv) < 2: | ||
30 | 26 | cr_common.error("Must give path to click package") | ||
31 | 27 | |||
32 | 28 | review = cr_push_helper.ClickReviewPushHelper(sys.argv[1]) | ||
33 | 29 | review.do_checks() | ||
34 | 30 | rc = review.do_report() | ||
35 | 31 | sys.exit(rc) | ||
36 | 0 | 32 | ||
37 | === modified file 'bin/click-run-checks' | |||
38 | --- bin/click-run-checks 2014-07-16 17:56:05 +0000 | |||
39 | +++ bin/click-run-checks 2014-07-24 21:41:48 +0000 | |||
40 | @@ -56,6 +56,10 @@ | |||
41 | 56 | prefer_local click-check-online-accounts "$c" | 56 | prefer_local click-check-online-accounts "$c" |
42 | 57 | 57 | ||
43 | 58 | echo "" | 58 | echo "" |
44 | 59 | echo "= click-check-push-helper =" | ||
45 | 60 | prefer_local click-check-push-helper "$c" | ||
46 | 61 | |||
47 | 62 | echo "" | ||
48 | 59 | echo "= click-check-scope =" | 63 | echo "= click-check-scope =" |
49 | 60 | prefer_local click-check-scope "$c" | 64 | prefer_local click-check-scope "$c" |
50 | 61 | 65 | ||
51 | 62 | 66 | ||
52 | === modified file 'bin/click-show-files' | |||
53 | --- bin/click-show-files 2014-07-18 14:18:06 +0000 | |||
54 | +++ bin/click-show-files 2014-07-24 21:41:48 +0000 | |||
55 | @@ -27,6 +27,7 @@ | |||
56 | 27 | from clickreviews import cr_scope | 27 | from clickreviews import cr_scope |
57 | 28 | from clickreviews import cr_content_hub | 28 | from clickreviews import cr_content_hub |
58 | 29 | from clickreviews import cr_online_accounts | 29 | from clickreviews import cr_online_accounts |
59 | 30 | from clickreviews import cr_push_helper | ||
60 | 30 | 31 | ||
61 | 31 | # This script just dumps important files to stdout | 32 | # This script just dumps important files to stdout |
62 | 32 | 33 | ||
63 | @@ -86,6 +87,18 @@ | |||
64 | 86 | print("") | 87 | print("") |
65 | 87 | cr_common.cleanup_unpack() | 88 | cr_common.cleanup_unpack() |
66 | 88 | 89 | ||
67 | 90 | review_push_helper = cr_push_helper.ClickReviewPushHelper(sys.argv[1]) | ||
68 | 91 | for app in sorted(review_push_helper.push_helper_files): | ||
69 | 92 | f = review_push_helper.push_helper_files[app] | ||
70 | 93 | fh = cr_common.open_file_read(os.path.join( | ||
71 | 94 | review_push_helper.unpack_dir, f)) | ||
72 | 95 | print("== push_helper: %s ==" % os.path.basename(f)) | ||
73 | 96 | for line in fh.readlines(): | ||
74 | 97 | print(line, end="") | ||
75 | 98 | fh.close() | ||
76 | 99 | print("") | ||
77 | 100 | cr_common.cleanup_unpack() | ||
78 | 101 | |||
79 | 89 | review_scope = cr_scope.ClickReviewScope(sys.argv[1]) | 102 | review_scope = cr_scope.ClickReviewScope(sys.argv[1]) |
80 | 90 | for app in sorted(review_scope.scopes): | 103 | for app in sorted(review_scope.scopes): |
81 | 91 | f = review_scope.scopes[app]["ini_file"] | 104 | f = review_scope.scopes[app]["ini_file"] |
82 | 92 | 105 | ||
83 | === modified file 'clickreviews/cr_common.py' | |||
84 | --- clickreviews/cr_common.py 2014-06-24 13:51:19 +0000 | |||
85 | +++ clickreviews/cr_common.py 2014-07-24 21:41:48 +0000 | |||
86 | @@ -62,7 +62,8 @@ | |||
87 | 62 | if not self.click_package.endswith(".click"): | 62 | if not self.click_package.endswith(".click"): |
88 | 63 | if self.click_package.endswith(".deb"): | 63 | if self.click_package.endswith(".deb"): |
89 | 64 | error("filename does not end with '.click', but '.deb' " | 64 | error("filename does not end with '.click', but '.deb' " |
91 | 65 | "instead. See http://askubuntu.com/a/485544/94326 for how click packages are different.") | 65 | "instead. See http://askubuntu.com/a/485544/94326 for " |
92 | 66 | "how click packages are different.") | ||
93 | 66 | error("filename does not end with '.click'") | 67 | error("filename does not end with '.click'") |
94 | 67 | 68 | ||
95 | 68 | self.review_type = review_type | 69 | self.review_type = review_type |
96 | 69 | 70 | ||
97 | === modified file 'clickreviews/cr_desktop.py' | |||
98 | --- clickreviews/cr_desktop.py 2014-05-30 08:33:09 +0000 | |||
99 | +++ clickreviews/cr_desktop.py 2014-07-24 21:41:48 +0000 | |||
100 | @@ -37,7 +37,11 @@ | |||
101 | 37 | for app in self.manifest['hooks']: | 37 | for app in self.manifest['hooks']: |
102 | 38 | if 'desktop' not in self.manifest['hooks'][app]: | 38 | if 'desktop' not in self.manifest['hooks'][app]: |
103 | 39 | if 'scope' in self.manifest['hooks'][app]: | 39 | if 'scope' in self.manifest['hooks'][app]: |
105 | 40 | msg("Skipped missing desktop hook for scope '%s'" % app) | 40 | # msg("Skipped missing desktop hook for scope '%s'" % app) |
106 | 41 | continue | ||
107 | 42 | if 'push-helper' in self.manifest['hooks'][app]: | ||
108 | 43 | # msg("Skipped missing desktop hook for push-helper '%s'" % | ||
109 | 44 | # app) | ||
110 | 41 | continue | 45 | continue |
111 | 42 | else: | 46 | else: |
112 | 43 | error("could not find desktop hook for '%s'" % app) | 47 | error("could not find desktop hook for '%s'" % app) |
113 | 44 | 48 | ||
114 | === modified file 'clickreviews/cr_lint.py' | |||
115 | --- clickreviews/cr_lint.py 2014-07-16 19:07:21 +0000 | |||
116 | +++ clickreviews/cr_lint.py 2014-07-24 21:41:48 +0000 | |||
117 | @@ -69,6 +69,7 @@ | |||
118 | 69 | 'content-hub', | 69 | 'content-hub', |
119 | 70 | 'desktop', | 70 | 'desktop', |
120 | 71 | 'pay-ui', | 71 | 'pay-ui', |
121 | 72 | 'push-helper', | ||
122 | 72 | 'scope', | 73 | 'scope', |
123 | 73 | 'urls'] | 74 | 'urls'] |
124 | 74 | 75 | ||
125 | @@ -281,11 +282,20 @@ | |||
126 | 281 | # Some checks are already handled in | 282 | # Some checks are already handled in |
127 | 282 | # cr_common.py:_verify_manifest_structure() | 283 | # cr_common.py:_verify_manifest_structure() |
128 | 283 | 284 | ||
134 | 284 | # We don't support multiple apps in 13.10 | 285 | # While we support multiple apps in the hooks db, we don't support |
135 | 285 | if len(self.manifest['hooks'].keys()) != 1: | 286 | # multiple apps specifying desktop hooks. Eg, it is ok to specify a |
136 | 286 | self._add_result('error', 'hooks', | 287 | # scope, an app and a push-helper, but it isn't ok to specify two apps |
137 | 287 | "more than one app key specified in hooks") | 288 | t = 'info' |
138 | 288 | return | 289 | n = 'hooks_multiple_apps' |
139 | 290 | s = 'OK' | ||
140 | 291 | count = 0 | ||
141 | 292 | for app in self.manifest['hooks']: | ||
142 | 293 | if "desktop" in self.manifest['hooks'][app]: | ||
143 | 294 | count += 1 | ||
144 | 295 | if count > 1: | ||
145 | 296 | t = 'error' | ||
146 | 297 | s = 'more than one desktop app specified in hooks' | ||
147 | 298 | self._add_result(t, n, s) | ||
148 | 289 | 299 | ||
149 | 290 | # Verify keys are well-formatted | 300 | # Verify keys are well-formatted |
150 | 291 | for app in self.manifest['hooks']: | 301 | for app in self.manifest['hooks']: |
151 | 292 | 302 | ||
152 | === added file 'clickreviews/cr_push_helper.py' | |||
153 | --- clickreviews/cr_push_helper.py 1970-01-01 00:00:00 +0000 | |||
154 | +++ clickreviews/cr_push_helper.py 2014-07-24 21:41:48 +0000 | |||
155 | @@ -0,0 +1,132 @@ | |||
156 | 1 | '''cr_push_helper.py: click push-helper checks''' | ||
157 | 2 | # | ||
158 | 3 | # Copyright (C) 2014 Canonical Ltd. | ||
159 | 4 | # | ||
160 | 5 | # This program is free software: you can redistribute it and/or modify | ||
161 | 6 | # it under the terms of the GNU General Public License as published by | ||
162 | 7 | # the Free Software Foundation; version 3 of the License. | ||
163 | 8 | # | ||
164 | 9 | # This program is distributed in the hope that it will be useful, | ||
165 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
166 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
167 | 12 | # GNU General Public License for more details. | ||
168 | 13 | # | ||
169 | 14 | # You should have received a copy of the GNU General Public License | ||
170 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
171 | 16 | |||
172 | 17 | from __future__ import print_function | ||
173 | 18 | |||
174 | 19 | from clickreviews.cr_common import ClickReview, error, open_file_read, msg | ||
175 | 20 | import json | ||
176 | 21 | import os | ||
177 | 22 | |||
178 | 23 | |||
179 | 24 | class ClickReviewPushHelper(ClickReview): | ||
180 | 25 | '''This class represents click lint reviews''' | ||
181 | 26 | def __init__(self, fn): | ||
182 | 27 | ClickReview.__init__(self, fn, "push_helper") | ||
183 | 28 | |||
184 | 29 | self.required_keys = ['exec'] | ||
185 | 30 | self.optional_keys = ['app_id'] | ||
186 | 31 | |||
187 | 32 | self.push_helper_files = dict() # click-show-files and tests | ||
188 | 33 | self.push_helper = dict() | ||
189 | 34 | for app in self.manifest['hooks']: | ||
190 | 35 | if 'push-helper' not in self.manifest['hooks'][app]: | ||
191 | 36 | # msg("Skipped missing push-helper hook for '%s'" % app) | ||
192 | 37 | continue | ||
193 | 38 | if not isinstance(self.manifest['hooks'][app]['push-helper'], str): | ||
194 | 39 | error("manifest malformed: hooks/%s/urls is not str" % app) | ||
195 | 40 | (full_fn, jd) = self._extract_push_helper(app) | ||
196 | 41 | self.push_helper_files[app] = full_fn | ||
197 | 42 | self.push_helper[app] = jd | ||
198 | 43 | |||
199 | 44 | def _extract_push_helper(self, app): | ||
200 | 45 | '''Get push-helper hook content''' | ||
201 | 46 | c = self.manifest['hooks'][app]['push-helper'] | ||
202 | 47 | fn = os.path.join(self.unpack_dir, c) | ||
203 | 48 | |||
204 | 49 | bn = os.path.basename(fn) | ||
205 | 50 | if not os.path.exists(fn): | ||
206 | 51 | error("Could not find '%s'" % bn) | ||
207 | 52 | |||
208 | 53 | fh = open_file_read(fn) | ||
209 | 54 | contents = "" | ||
210 | 55 | for line in fh.readlines(): | ||
211 | 56 | contents += line | ||
212 | 57 | fh.close() | ||
213 | 58 | |||
214 | 59 | try: | ||
215 | 60 | jd = json.loads(contents) | ||
216 | 61 | except Exception as e: | ||
217 | 62 | error("push-helper json unparseable: %s (%s):\n%s" % (bn, | ||
218 | 63 | str(e), contents)) | ||
219 | 64 | |||
220 | 65 | if not isinstance(jd, dict): | ||
221 | 66 | error("push-helper json is malformed: %s:\n%s" % (bn, contents)) | ||
222 | 67 | |||
223 | 68 | return (fn, jd) | ||
224 | 69 | |||
225 | 70 | def check_valid(self): | ||
226 | 71 | '''Check validity of push-helper entries''' | ||
227 | 72 | for app in sorted(self.push_helper): | ||
228 | 73 | for k in self.push_helper[app].keys(): | ||
229 | 74 | t = "info" | ||
230 | 75 | n = "valid_%s_%s" % (app, k) | ||
231 | 76 | s = "OK" | ||
232 | 77 | |||
233 | 78 | if not isinstance(self.push_helper[app][k], str): | ||
234 | 79 | t = "error" | ||
235 | 80 | s = "'%s' is not a string" % k | ||
236 | 81 | elif self.push_helper[app][k] == "": | ||
237 | 82 | t = "error" | ||
238 | 83 | s = "'%s' is empty" % k | ||
239 | 84 | self._add_result(t, n, s) | ||
240 | 85 | |||
241 | 86 | for k in self.required_keys: | ||
242 | 87 | t = "info" | ||
243 | 88 | n = "valid_%s_required_%s" % (app, k) | ||
244 | 89 | s = "OK" | ||
245 | 90 | if k not in self.push_helper[app]: | ||
246 | 91 | t = "error" | ||
247 | 92 | s = "'%s' is missing" % k | ||
248 | 93 | self._add_result(t, n, s) | ||
249 | 94 | |||
250 | 95 | def check_unknown_keys(self): | ||
251 | 96 | '''Check unknown''' | ||
252 | 97 | for app in sorted(self.push_helper): | ||
253 | 98 | unknown = [] | ||
254 | 99 | t = "info" | ||
255 | 100 | n = "unknown_%s" % app | ||
256 | 101 | s = "OK" | ||
257 | 102 | for key in self.push_helper[app].keys(): | ||
258 | 103 | if key not in self.required_keys and \ | ||
259 | 104 | key not in self.optional_keys: | ||
260 | 105 | unknown.append(key) | ||
261 | 106 | if len(unknown) == 1: | ||
262 | 107 | t = "warn" | ||
263 | 108 | s = "Unknown field '%s'" % unknown[0] | ||
264 | 109 | elif len(unknown) > 1: | ||
265 | 110 | t = "warn" | ||
266 | 111 | s = "Unknown fields '%s'" % ", ".join(unknown) | ||
267 | 112 | self._add_result(t, n, s) | ||
268 | 113 | |||
269 | 114 | def check_hooks(self): | ||
270 | 115 | '''Verify combinations of click hooks with the push-helper hook''' | ||
271 | 116 | for app in sorted(self.manifest['hooks']): | ||
272 | 117 | if app not in self.push_helper: | ||
273 | 118 | continue | ||
274 | 119 | |||
275 | 120 | t = "info" | ||
276 | 121 | n = "other_hooks_%s" % app | ||
277 | 122 | s = "OK" | ||
278 | 123 | |||
279 | 124 | bad = [] | ||
280 | 125 | for hook in self.manifest['hooks'][app]: | ||
281 | 126 | # Only the apparmor hook can be used with the push-helper | ||
282 | 127 | if hook not in ['push-helper', 'apparmor']: | ||
283 | 128 | bad.append(hook) | ||
284 | 129 | if len(bad) > 0: | ||
285 | 130 | t = 'error' | ||
286 | 131 | s = "Found unusual hooks with push-helper: %s" % ", ".join(bad) | ||
287 | 132 | self._add_result(t, n, s) | ||
288 | 0 | 133 | ||
289 | === modified file 'clickreviews/cr_security.py' | |||
290 | --- clickreviews/cr_security.py 2014-07-18 19:47:48 +0000 | |||
291 | +++ clickreviews/cr_security.py 2014-07-24 21:41:48 +0000 | |||
292 | @@ -66,6 +66,8 @@ | |||
293 | 66 | 'video', | 66 | 'video', |
294 | 67 | 'webview'] | 67 | 'webview'] |
295 | 68 | 68 | ||
296 | 69 | self.allowed_push_helper_policy_groups = ['push-notification-client'] | ||
297 | 70 | |||
298 | 69 | self.redflag_templates = ['unconfined'] | 71 | self.redflag_templates = ['unconfined'] |
299 | 70 | self.extraneous_templates = ['ubuntu-sdk', | 72 | self.extraneous_templates = ['ubuntu-sdk', |
300 | 71 | 'default'] | 73 | 'default'] |
301 | @@ -357,6 +359,44 @@ | |||
302 | 357 | 359 | ||
303 | 358 | self._add_result(t, n, s) | 360 | self._add_result(t, n, s) |
304 | 359 | 361 | ||
305 | 362 | def check_template_push_helpers(self): | ||
306 | 363 | '''Check template for push-helpers''' | ||
307 | 364 | for app in sorted(self.manifest['hooks']): | ||
308 | 365 | (f, m) = self._get_security_manifest(app) | ||
309 | 366 | t = 'info' | ||
310 | 367 | n = 'template_push_helper(%s)' % f | ||
311 | 368 | s = "OK" | ||
312 | 369 | if 'push-helper' not in self.manifest['hooks'][app]: | ||
313 | 370 | continue | ||
314 | 371 | if 'template' in m and m['template'] != "ubuntu-sdk": | ||
315 | 372 | t = 'error' | ||
316 | 373 | s = "template is not 'ubuntu-sdk'" | ||
317 | 374 | self._add_result(t, n, s) | ||
318 | 375 | |||
319 | 376 | def check_policy_groups_push_helpers(self): | ||
320 | 377 | '''Check policy_groups for push-helpers''' | ||
321 | 378 | for app in sorted(self.manifest['hooks']): | ||
322 | 379 | (f, m) = self._get_security_manifest(app) | ||
323 | 380 | t = 'info' | ||
324 | 381 | n = 'policy_groups_push_helper(%s)' % f | ||
325 | 382 | s = "OK" | ||
326 | 383 | if 'push-helper' not in self.manifest['hooks'][app]: | ||
327 | 384 | continue | ||
328 | 385 | if 'policy_groups' not in m or \ | ||
329 | 386 | 'push-notification-client' not in m['policy_groups']: | ||
330 | 387 | self._add_result('error', n, | ||
331 | 388 | "required group 'push-notification-client' " | ||
332 | 389 | "not found") | ||
333 | 390 | continue | ||
334 | 391 | bad = [] | ||
335 | 392 | for p in m['policy_groups']: | ||
336 | 393 | if p not in self.allowed_push_helper_policy_groups: | ||
337 | 394 | bad.append(p) | ||
338 | 395 | if len(bad) > 0: | ||
339 | 396 | t = 'error' | ||
340 | 397 | s = "found unusual policy groups: %s" % ", ".join(bad) | ||
341 | 398 | self._add_result(t, n, s) | ||
342 | 399 | |||
343 | 360 | def check_policy_groups_scopes(self): | 400 | def check_policy_groups_scopes(self): |
344 | 361 | '''Check policy_groups for scopes''' | 401 | '''Check policy_groups for scopes''' |
345 | 362 | for app in sorted(self.manifest['hooks']): | 402 | for app in sorted(self.manifest['hooks']): |
346 | @@ -397,7 +437,7 @@ | |||
347 | 397 | (f, m) = self._get_security_manifest(app) | 437 | (f, m) = self._get_security_manifest(app) |
348 | 398 | 438 | ||
349 | 399 | t = 'info' | 439 | t = 'info' |
351 | 400 | n = 'policy_groups_exists (%s)' % f | 440 | n = 'policy_groups_exists_%s (%s)' % (app, f) |
352 | 401 | if 'policy_groups' not in m: | 441 | if 'policy_groups' not in m: |
353 | 402 | # If template not specified, we just use the default | 442 | # If template not specified, we just use the default |
354 | 403 | self._add_result('warn', n, 'no policy groups specified') | 443 | self._add_result('warn', n, 'no policy groups specified') |
355 | @@ -423,7 +463,7 @@ | |||
356 | 423 | 463 | ||
357 | 424 | # Check for duplicates | 464 | # Check for duplicates |
358 | 425 | t = 'info' | 465 | t = 'info' |
360 | 426 | n = 'policy_groups_duplicates (%s)' % f | 466 | n = 'policy_groups_duplicates_%s (%s)' % (app, f) |
361 | 427 | s = 'OK' | 467 | s = 'OK' |
362 | 428 | tmp = [] | 468 | tmp = [] |
363 | 429 | for p in m['policy_groups']: | 469 | for p in m['policy_groups']: |
364 | @@ -438,7 +478,7 @@ | |||
365 | 438 | # If we got here, we can see if valid policy groups were specified | 478 | # If we got here, we can see if valid policy groups were specified |
366 | 439 | for i in m['policy_groups']: | 479 | for i in m['policy_groups']: |
367 | 440 | t = 'info' | 480 | t = 'info' |
369 | 441 | n = 'policy_groups_valid (%s)' % i | 481 | n = 'policy_groups_valid_%s (%s)' % (app, i) |
370 | 442 | s = 'OK' | 482 | s = 'OK' |
371 | 443 | 483 | ||
372 | 444 | # SDK will leave and empty policy group, report but don't | 484 | # SDK will leave and empty policy group, report but don't |
373 | @@ -461,7 +501,7 @@ | |||
374 | 461 | 501 | ||
375 | 462 | if found: | 502 | if found: |
376 | 463 | t = 'info' | 503 | t = 'info' |
378 | 464 | n = 'policy_groups_safe (%s)' % i | 504 | n = 'policy_groups_safe_%s (%s)' % (app, i) |
379 | 465 | s = 'OK' | 505 | s = 'OK' |
380 | 466 | 506 | ||
381 | 467 | aa_type = self._get_policy_group_type(vendor, version, i) | 507 | aa_type = self._get_policy_group_type(vendor, version, i) |
382 | 468 | 508 | ||
383 | === modified file 'clickreviews/cr_tests.py' | |||
384 | --- clickreviews/cr_tests.py 2014-07-16 18:13:22 +0000 | |||
385 | +++ clickreviews/cr_tests.py 2014-07-24 21:41:48 +0000 | |||
386 | @@ -39,6 +39,7 @@ | |||
387 | 39 | TEST_ACCOUNTS_PROVIDER = dict() | 39 | TEST_ACCOUNTS_PROVIDER = dict() |
388 | 40 | TEST_ACCOUNTS_QML_PLUGIN = dict() | 40 | TEST_ACCOUNTS_QML_PLUGIN = dict() |
389 | 41 | TEST_ACCOUNTS_SERVICE = dict() | 41 | TEST_ACCOUNTS_SERVICE = dict() |
390 | 42 | TEST_PUSH_HELPER = dict() | ||
391 | 42 | 43 | ||
392 | 43 | 44 | ||
393 | 44 | # | 45 | # |
394 | @@ -148,6 +149,11 @@ | |||
395 | 148 | return (f, val) | 149 | return (f, val) |
396 | 149 | 150 | ||
397 | 150 | 151 | ||
398 | 152 | def _extract_push_helper(self, app): | ||
399 | 153 | '''Pretend we read the push-helper file''' | ||
400 | 154 | return ("%s.push-helper.json" % app, TEST_PUSH_HELPER[app]) | ||
401 | 155 | |||
402 | 156 | |||
403 | 151 | # http://docs.python.org/3.4/library/unittest.mock-examples.html | 157 | # http://docs.python.org/3.4/library/unittest.mock-examples.html |
404 | 152 | # Mock patching. Don't use decorators but instead patch in setUp() of the | 158 | # Mock patching. Don't use decorators but instead patch in setUp() of the |
405 | 153 | # child. Set up a list of patches, but don't start them. Create the helper | 159 | # child. Set up a list of patches, but don't start them. Create the helper |
406 | @@ -228,6 +234,11 @@ | |||
407 | 228 | 'clickreviews.cr_online_accounts.ClickReviewAccounts._extract_account', | 234 | 'clickreviews.cr_online_accounts.ClickReviewAccounts._extract_account', |
408 | 229 | _extract_account)) | 235 | _extract_account)) |
409 | 230 | 236 | ||
410 | 237 | # push-helper overrides | ||
411 | 238 | patches.append(patch( | ||
412 | 239 | 'clickreviews.cr_push_helper.ClickReviewPushHelper._extract_push_helper', | ||
413 | 240 | _extract_push_helper)) | ||
414 | 241 | |||
415 | 231 | 242 | ||
416 | 232 | def mock_patch(): | 243 | def mock_patch(): |
417 | 233 | '''Call in setup of child''' | 244 | '''Call in setup of child''' |
418 | @@ -295,6 +306,7 @@ | |||
419 | 295 | self.test_accounts_provider = dict() | 306 | self.test_accounts_provider = dict() |
420 | 296 | self.test_accounts_qml_plugin = dict() | 307 | self.test_accounts_qml_plugin = dict() |
421 | 297 | self.test_accounts_service = dict() | 308 | self.test_accounts_service = dict() |
422 | 309 | self.test_push_helper = dict() | ||
423 | 298 | for app in self.test_manifest["hooks"].keys(): | 310 | for app in self.test_manifest["hooks"].keys(): |
424 | 299 | # setup security manifest for each app | 311 | # setup security manifest for each app |
425 | 300 | self.set_test_security_manifest(app, 'policy_groups', | 312 | self.set_test_security_manifest(app, 'policy_groups', |
426 | @@ -330,6 +342,9 @@ | |||
427 | 330 | self.set_test_account(app, "account-qml-plugin", None) | 342 | self.set_test_account(app, "account-qml-plugin", None) |
428 | 331 | self.set_test_account(app, "account-service", None) | 343 | self.set_test_account(app, "account-service", None) |
429 | 332 | 344 | ||
430 | 345 | # Reset to no content-hub entries in manifest | ||
431 | 346 | self.set_test_push_helper(app, None, None) | ||
432 | 347 | |||
433 | 333 | self._update_test_security_manifests() | 348 | self._update_test_security_manifests() |
434 | 334 | self._update_test_desktop_files() | 349 | self._update_test_desktop_files() |
435 | 335 | self._update_test_url_dispatcher() | 350 | self._update_test_url_dispatcher() |
436 | @@ -339,6 +354,7 @@ | |||
437 | 339 | self._update_test_accounts_provider() | 354 | self._update_test_accounts_provider() |
438 | 340 | self._update_test_accounts_qml_plugin() | 355 | self._update_test_accounts_qml_plugin() |
439 | 341 | self._update_test_accounts_service() | 356 | self._update_test_accounts_service() |
440 | 357 | self._update_test_push_helper() | ||
441 | 342 | 358 | ||
442 | 343 | # webapps manifests (leave empty for now) | 359 | # webapps manifests (leave empty for now) |
443 | 344 | self.test_webapp_manifests = dict() | 360 | self.test_webapp_manifests = dict() |
444 | @@ -444,6 +460,15 @@ | |||
445 | 444 | "%s.service" % app | 460 | "%s.service" % app |
446 | 445 | self._update_test_manifest() | 461 | self._update_test_manifest() |
447 | 446 | 462 | ||
448 | 463 | def _update_test_push_helper(self): | ||
449 | 464 | global TEST_PUSH_HELPER | ||
450 | 465 | TEST_PUSH_HELPER = dict() | ||
451 | 466 | for app in self.test_push_helper.keys(): | ||
452 | 467 | TEST_PUSH_HELPER[app] = self.test_push_helper[app] | ||
453 | 468 | self.test_manifest["hooks"][app]["push-helper"] = \ | ||
454 | 469 | "%s.push-helper.json" % app | ||
455 | 470 | self._update_test_manifest() | ||
456 | 471 | |||
457 | 447 | def _update_test_name(self): | 472 | def _update_test_name(self): |
458 | 448 | self.test_name = "%s_%s_%s.click" % (self.test_control['Package'], | 473 | self.test_name = "%s_%s_%s.click" % (self.test_control['Package'], |
459 | 449 | self.test_control['Version'], | 474 | self.test_control['Version'], |
460 | @@ -618,6 +643,21 @@ | |||
461 | 618 | elif account_type == "account-service": | 643 | elif account_type == "account-service": |
462 | 619 | self._update_test_accounts_service() | 644 | self._update_test_accounts_service() |
463 | 620 | 645 | ||
464 | 646 | def set_test_push_helper(self, app, key, value): | ||
465 | 647 | '''Set push-helper entries. If value is None, remove key, if key is | ||
466 | 648 | None, remove content-hub from manifest''' | ||
467 | 649 | if key is None: | ||
468 | 650 | if app in self.test_push_helper: | ||
469 | 651 | self.test_push_helper.pop(app) | ||
470 | 652 | elif value is None: | ||
471 | 653 | if key in self.test_push_helper[app]: | ||
472 | 654 | self.test_push_helper[app].pop(key) | ||
473 | 655 | else: | ||
474 | 656 | if app not in self.test_push_helper: | ||
475 | 657 | self.test_push_helper[app] = dict() | ||
476 | 658 | self.test_push_helper[app][key] = value | ||
477 | 659 | self._update_test_push_helper() | ||
478 | 660 | |||
479 | 621 | def setUp(self): | 661 | def setUp(self): |
480 | 622 | '''Make sure our patches are applied everywhere''' | 662 | '''Make sure our patches are applied everywhere''' |
481 | 623 | global patches | 663 | global patches |
482 | @@ -647,7 +687,9 @@ | |||
483 | 647 | global TEST_ACCOUNTS_QML_PLUGIN | 687 | global TEST_ACCOUNTS_QML_PLUGIN |
484 | 648 | TEST_ACCOUNTS_QML_PLUGIN = dict() | 688 | TEST_ACCOUNTS_QML_PLUGIN = dict() |
485 | 649 | global TEST_ACCOUNTS_SERVICE | 689 | global TEST_ACCOUNTS_SERVICE |
487 | 650 | TEST_ACCOUNTS_APPLICTION = dict() | 690 | TEST_ACCOUNTS_APPLICATION = dict() |
488 | 691 | global TEST_PUSH_HELPER | ||
489 | 692 | TEST_PUSH_HELPER = dict() | ||
490 | 651 | 693 | ||
491 | 652 | self._reset_test_data() | 694 | self._reset_test_data() |
492 | 653 | cr_common.recursive_rm(self.desktop_tmpdir) | 695 | cr_common.recursive_rm(self.desktop_tmpdir) |
493 | 654 | 696 | ||
494 | === modified file 'clickreviews/tests/test_cr_lint.py' | |||
495 | --- clickreviews/tests/test_cr_lint.py 2014-07-16 14:48:39 +0000 | |||
496 | +++ clickreviews/tests/test_cr_lint.py 2014-07-24 21:41:48 +0000 | |||
497 | @@ -644,15 +644,37 @@ | |||
498 | 644 | expected_counts = {'info': None, 'warn': 0, 'error': 0} | 644 | expected_counts = {'info': None, 'warn': 0, 'error': 0} |
499 | 645 | self.check_results(r, expected_counts) | 645 | self.check_results(r, expected_counts) |
500 | 646 | 646 | ||
501 | 647 | def test_check_hooks_multiple_desktop_apps(self): | ||
502 | 648 | '''Test check_hooks() - multiple desktop apps''' | ||
503 | 649 | self.set_test_manifest("framework", "ubuntu-sdk-13.10") | ||
504 | 650 | c = ClickReviewLint(self.test_name) | ||
505 | 651 | tmp = c.manifest['hooks'][self.default_appname] | ||
506 | 652 | c.manifest['hooks']["another-app"] = tmp | ||
507 | 653 | c.check_hooks() | ||
508 | 654 | r = c.click_report | ||
509 | 655 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
510 | 656 | self.check_results(r, expected_counts) | ||
511 | 657 | |||
512 | 647 | def test_check_hooks_multiple_apps(self): | 658 | def test_check_hooks_multiple_apps(self): |
514 | 648 | '''Test check_hooks() - multiple apps''' | 659 | '''Test check_hooks() - multiple non-desktop apps''' |
515 | 649 | self.set_test_manifest("framework", "ubuntu-sdk-13.10") | 660 | self.set_test_manifest("framework", "ubuntu-sdk-13.10") |
516 | 650 | c = ClickReviewLint(self.test_name) | 661 | c = ClickReviewLint(self.test_name) |
519 | 651 | tmp = c.manifest['hooks'][self.default_appname] | 662 | tmp = dict() |
520 | 652 | c.manifest['hooks']["another-app"] = tmp | 663 | for k in c.manifest['hooks'][self.default_appname].keys(): |
521 | 664 | tmp[k] = c.manifest['hooks'][self.default_appname][k] | ||
522 | 665 | tmp.pop('desktop') | ||
523 | 666 | tmp['scope'] = "some-scope-exec" | ||
524 | 667 | c.manifest['hooks']["some-scope"] = tmp | ||
525 | 668 | tmp = dict() | ||
526 | 669 | for k in c.manifest['hooks'][self.default_appname].keys(): | ||
527 | 670 | tmp[k] = c.manifest['hooks'][self.default_appname][k] | ||
528 | 671 | tmp.pop('desktop') | ||
529 | 672 | tmp['push-helper'] = "push.json" | ||
530 | 673 | c.manifest['hooks']["some-push-helper"] = tmp | ||
531 | 674 | |||
532 | 653 | c.check_hooks() | 675 | c.check_hooks() |
533 | 654 | r = c.click_report | 676 | r = c.click_report |
535 | 655 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | 677 | expected_counts = {'info': 7, 'warn': 0, 'error': 0} |
536 | 656 | self.check_results(r, expected_counts) | 678 | self.check_results(r, expected_counts) |
537 | 657 | 679 | ||
538 | 658 | def test_check_hooks_bad_appname(self): | 680 | def test_check_hooks_bad_appname(self): |
539 | 659 | 681 | ||
540 | === added file 'clickreviews/tests/test_cr_push_helper.py' | |||
541 | --- clickreviews/tests/test_cr_push_helper.py 1970-01-01 00:00:00 +0000 | |||
542 | +++ clickreviews/tests/test_cr_push_helper.py 2014-07-24 21:41:48 +0000 | |||
543 | @@ -0,0 +1,138 @@ | |||
544 | 1 | '''test_cr_push_helper.py: tests for the cr_push_helper module''' | ||
545 | 2 | # | ||
546 | 3 | # Copyright (C) 2013 Canonical Ltd. | ||
547 | 4 | # | ||
548 | 5 | # This program is free software: you can redistribute it and/or modify | ||
549 | 6 | # it under the terms of the GNU General Public License as published by | ||
550 | 7 | # the Free Software Foundation; version 3 of the License. | ||
551 | 8 | # | ||
552 | 9 | # This program is distributed in the hope that it will be useful, | ||
553 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
554 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
555 | 12 | # GNU General Public License for more details. | ||
556 | 13 | # | ||
557 | 14 | # You should have received a copy of the GNU General Public License | ||
558 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
559 | 16 | |||
560 | 17 | from clickreviews.cr_push_helper import ClickReviewPushHelper | ||
561 | 18 | import clickreviews.cr_tests as cr_tests | ||
562 | 19 | |||
563 | 20 | |||
564 | 21 | class TestClickReviewPushHelper(cr_tests.TestClickReview): | ||
565 | 22 | """Tests for the lint review tool.""" | ||
566 | 23 | def setUp(self): | ||
567 | 24 | # Monkey patch various file access classes. stop() is handled with | ||
568 | 25 | # addCleanup in super() | ||
569 | 26 | cr_tests.mock_patch() | ||
570 | 27 | super() | ||
571 | 28 | |||
572 | 29 | def test_check_unknown_keys_none(self): | ||
573 | 30 | '''Test check_unknown() - no unknown''' | ||
574 | 31 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
575 | 32 | c = ClickReviewPushHelper(self.test_name) | ||
576 | 33 | c.check_unknown_keys() | ||
577 | 34 | r = c.click_report | ||
578 | 35 | expected_counts = {'info': 1, 'warn': 0, 'error': 0} | ||
579 | 36 | self.check_results(r, expected_counts) | ||
580 | 37 | |||
581 | 38 | def test_check_unknown_keys1(self): | ||
582 | 39 | '''Test check_unknown() - one unknown''' | ||
583 | 40 | self.set_test_push_helper(self.default_appname, "nonexistent", "foo") | ||
584 | 41 | c = ClickReviewPushHelper(self.test_name) | ||
585 | 42 | c.check_unknown_keys() | ||
586 | 43 | r = c.click_report | ||
587 | 44 | expected_counts = {'info': 0, 'warn': 1, 'error': 0} | ||
588 | 45 | self.check_results(r, expected_counts) | ||
589 | 46 | |||
590 | 47 | def test_check_unknown_keys2(self): | ||
591 | 48 | '''Test check_unknown() - good with one unknown''' | ||
592 | 49 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
593 | 50 | self.set_test_push_helper(self.default_appname, "nonexistent", "foo") | ||
594 | 51 | c = ClickReviewPushHelper(self.test_name) | ||
595 | 52 | c.check_unknown_keys() | ||
596 | 53 | r = c.click_report | ||
597 | 54 | expected_counts = {'info': 0, 'warn': 1, 'error': 0} | ||
598 | 55 | self.check_results(r, expected_counts) | ||
599 | 56 | |||
600 | 57 | def test_check_valid_exec(self): | ||
601 | 58 | '''Test check_valid() - exec''' | ||
602 | 59 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
603 | 60 | c = ClickReviewPushHelper(self.test_name) | ||
604 | 61 | c.check_valid() | ||
605 | 62 | r = c.click_report | ||
606 | 63 | expected_counts = {'info': 2, 'warn': 0, 'error': 0} | ||
607 | 64 | self.check_results(r, expected_counts) | ||
608 | 65 | |||
609 | 66 | def test_check_valid_missing_exec(self): | ||
610 | 67 | '''Test check_valid() - missing exec''' | ||
611 | 68 | self.set_test_push_helper(self.default_appname, "app_id", "foo_foo") | ||
612 | 69 | c = ClickReviewPushHelper(self.test_name) | ||
613 | 70 | c.check_valid() | ||
614 | 71 | r = c.click_report | ||
615 | 72 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
616 | 73 | self.check_results(r, expected_counts) | ||
617 | 74 | |||
618 | 75 | def test_check_valid_app_id(self): | ||
619 | 76 | '''Test check_valid() - app_id''' | ||
620 | 77 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
621 | 78 | self.set_test_push_helper(self.default_appname, "app_id", "foo_foo") | ||
622 | 79 | c = ClickReviewPushHelper(self.test_name) | ||
623 | 80 | c.check_valid() | ||
624 | 81 | r = c.click_report | ||
625 | 82 | expected_counts = {'info': 3, 'warn': 0, 'error': 0} | ||
626 | 83 | self.check_results(r, expected_counts) | ||
627 | 84 | |||
628 | 85 | def test_check_valid_bad_value(self): | ||
629 | 86 | '''Test check_valid() - bad value''' | ||
630 | 87 | self.set_test_push_helper(self.default_appname, "exec", []) | ||
631 | 88 | c = ClickReviewPushHelper(self.test_name) | ||
632 | 89 | c.check_valid() | ||
633 | 90 | r = c.click_report | ||
634 | 91 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
635 | 92 | self.check_results(r, expected_counts) | ||
636 | 93 | |||
637 | 94 | def test_check_valid_empty_value(self): | ||
638 | 95 | '''Test check_valid() - empty value''' | ||
639 | 96 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
640 | 97 | self.set_test_push_helper(self.default_appname, "app_id", "") | ||
641 | 98 | c = ClickReviewPushHelper(self.test_name) | ||
642 | 99 | c.check_valid() | ||
643 | 100 | r = c.click_report | ||
644 | 101 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
645 | 102 | self.check_results(r, expected_counts) | ||
646 | 103 | |||
647 | 104 | def test_check_valid_empty_value2(self): | ||
648 | 105 | '''Test check_valid() - empty value''' | ||
649 | 106 | self.set_test_push_helper(self.default_appname, "exec", "") | ||
650 | 107 | self.set_test_push_helper(self.default_appname, "app_id", "foo_foo") | ||
651 | 108 | c = ClickReviewPushHelper(self.test_name) | ||
652 | 109 | c.check_valid() | ||
653 | 110 | r = c.click_report | ||
654 | 111 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
655 | 112 | self.check_results(r, expected_counts) | ||
656 | 113 | |||
657 | 114 | def test_check_hooks(self): | ||
658 | 115 | '''Test check_hooks()''' | ||
659 | 116 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
660 | 117 | c = ClickReviewPushHelper(self.test_name) | ||
661 | 118 | |||
662 | 119 | # remove hooks that are added by the framework | ||
663 | 120 | c.manifest['hooks'][self.default_appname].pop('desktop') | ||
664 | 121 | c.manifest['hooks'][self.default_appname].pop('urls') | ||
665 | 122 | |||
666 | 123 | c.check_hooks() | ||
667 | 124 | r = c.click_report | ||
668 | 125 | expected_counts = {'info': 1, 'warn': 0, 'error': 0} | ||
669 | 126 | self.check_results(r, expected_counts) | ||
670 | 127 | |||
671 | 128 | def test_check_hooks_bad(self): | ||
672 | 129 | '''Test check_hooks() - bad''' | ||
673 | 130 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
674 | 131 | c = ClickReviewPushHelper(self.test_name) | ||
675 | 132 | |||
676 | 133 | # The desktop and urls hooks are specified by default in the framework, | ||
677 | 134 | # so just running this without other setup should generate an error | ||
678 | 135 | c.check_hooks() | ||
679 | 136 | r = c.click_report | ||
680 | 137 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
681 | 138 | self.check_results(r, expected_counts) | ||
682 | 0 | 139 | ||
683 | === modified file 'clickreviews/tests/test_cr_security.py' | |||
684 | --- clickreviews/tests/test_cr_security.py 2014-07-14 16:40:36 +0000 | |||
685 | +++ clickreviews/tests/test_cr_security.py 2014-07-24 21:41:48 +0000 | |||
686 | @@ -600,3 +600,87 @@ | |||
687 | 600 | report = c.click_report | 600 | report = c.click_report |
688 | 601 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | 601 | expected_counts = {'info': None, 'warn': 0, 'error': 1} |
689 | 602 | self.check_results(report, expected_counts) | 602 | self.check_results(report, expected_counts) |
690 | 603 | |||
691 | 604 | def test_check_policy_groups_pushhelper_no_hook(self): | ||
692 | 605 | '''Test check_policy_groups_pushhelper() - no hook''' | ||
693 | 606 | c = ClickReviewSecurity(self.test_name) | ||
694 | 607 | c.check_policy_groups_push_helpers() | ||
695 | 608 | report = c.click_report | ||
696 | 609 | expected_counts = {'info': 0, 'warn': 0, 'error': 0} | ||
697 | 610 | self.check_results(report, expected_counts) | ||
698 | 611 | |||
699 | 612 | def test_check_policy_groups_pushhelper(self): | ||
700 | 613 | '''Test check_policy_groups_pushhelper()''' | ||
701 | 614 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
702 | 615 | self.set_test_security_manifest(self.default_appname, | ||
703 | 616 | "policy_groups", | ||
704 | 617 | ["push-notification-client"]) | ||
705 | 618 | c = ClickReviewSecurity(self.test_name) | ||
706 | 619 | c.check_policy_groups_push_helpers() | ||
707 | 620 | report = c.click_report | ||
708 | 621 | expected_counts = {'info': 1, 'warn': 0, 'error': 0} | ||
709 | 622 | self.check_results(report, expected_counts) | ||
710 | 623 | |||
711 | 624 | def test_check_policy_groups_pushhelper_missing(self): | ||
712 | 625 | '''Test check_policy_groups_pushhelper - missing''' | ||
713 | 626 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
714 | 627 | self.set_test_security_manifest(self.default_appname, | ||
715 | 628 | "policy_groups", | ||
716 | 629 | None) | ||
717 | 630 | c = ClickReviewSecurity(self.test_name) | ||
718 | 631 | c.check_policy_groups_push_helpers() | ||
719 | 632 | report = c.click_report | ||
720 | 633 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
721 | 634 | self.check_results(report, expected_counts) | ||
722 | 635 | |||
723 | 636 | def test_check_policy_groups_pushhelper_bad(self): | ||
724 | 637 | '''Test check_policy_groups_pushhelper - bad''' | ||
725 | 638 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
726 | 639 | self.set_test_security_manifest(self.default_appname, | ||
727 | 640 | "policy_groups", | ||
728 | 641 | ["video_files", | ||
729 | 642 | "networking", | ||
730 | 643 | "push-notification-client"]) | ||
731 | 644 | c = ClickReviewSecurity(self.test_name) | ||
732 | 645 | c.check_policy_groups_push_helpers() | ||
733 | 646 | report = c.click_report | ||
734 | 647 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
735 | 648 | self.check_results(report, expected_counts) | ||
736 | 649 | |||
737 | 650 | def test_check_template_pushhelper(self): | ||
738 | 651 | '''Test check_template_pushhelper''' | ||
739 | 652 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
740 | 653 | self.set_test_security_manifest(self.default_appname, | ||
741 | 654 | "template", "ubuntu-sdk") | ||
742 | 655 | self.set_test_security_manifest(self.default_appname, | ||
743 | 656 | "policy_groups", | ||
744 | 657 | ["push-notification-client"]) | ||
745 | 658 | c = ClickReviewSecurity(self.test_name) | ||
746 | 659 | c.check_template_push_helpers() | ||
747 | 660 | report = c.click_report | ||
748 | 661 | expected_counts = {'info': 1, 'warn': 0, 'error': 0} | ||
749 | 662 | self.check_results(report, expected_counts) | ||
750 | 663 | |||
751 | 664 | def test_check_template_pushhelper_no_hook(self): | ||
752 | 665 | '''Test check_template_pushhelper''' | ||
753 | 666 | self.set_test_security_manifest(self.default_appname, | ||
754 | 667 | "template", "ubuntu-sdk") | ||
755 | 668 | c = ClickReviewSecurity(self.test_name) | ||
756 | 669 | c.check_template_push_helpers() | ||
757 | 670 | report = c.click_report | ||
758 | 671 | expected_counts = {'info': 0, 'warn': 0, 'error': 0} | ||
759 | 672 | self.check_results(report, expected_counts) | ||
760 | 673 | |||
761 | 674 | def test_check_template_pushhelper_wrong_template(self): | ||
762 | 675 | '''Test check_template_pushhelper - wrong template()''' | ||
763 | 676 | self.set_test_push_helper(self.default_appname, "exec", "foo") | ||
764 | 677 | self.set_test_security_manifest(self.default_appname, | ||
765 | 678 | "template", "ubuntu-webapp") | ||
766 | 679 | self.set_test_security_manifest(self.default_appname, | ||
767 | 680 | "policy_groups", | ||
768 | 681 | ["push-notification-client"]) | ||
769 | 682 | c = ClickReviewSecurity(self.test_name) | ||
770 | 683 | c.check_template_push_helpers() | ||
771 | 684 | report = c.click_report | ||
772 | 685 | expected_counts = {'info': None, 'warn': 0, 'error': 1} | ||
773 | 686 | self.check_results(report, expected_counts) | ||
774 | 603 | 687 | ||
775 | === modified file 'debian/changelog' | |||
776 | --- debian/changelog 2014-07-23 07:53:35 +0000 | |||
777 | +++ debian/changelog 2014-07-24 21:41:48 +0000 | |||
778 | @@ -26,11 +26,12 @@ | |||
779 | 26 | group in 1.2 (LP: #1340869) | 26 | group in 1.2 (LP: #1340869) |
780 | 27 | * refactor the way we handle apparmor policy into a central static list | 27 | * refactor the way we handle apparmor policy into a central static list |
781 | 28 | which should be easy to update. | 28 | which should be easy to update. |
782 | 29 | * implement push-helper tests | ||
783 | 29 | 30 | ||
784 | 30 | [ Daniel Holbach ] | 31 | [ Daniel Holbach ] |
785 | 31 | * refer to documentation about click in case we encounter .deb packages. | 32 | * refer to documentation about click in case we encounter .deb packages. |
786 | 32 | 33 | ||
788 | 33 | -- Jamie Strandboge <jamie@ubuntu.com> Fri, 18 Jul 2014 14:51:46 -0500 | 34 | -- Jamie Strandboge <jamie@ubuntu.com> Thu, 24 Jul 2014 14:04:23 -0500 |
789 | 34 | 35 | ||
790 | 35 | click-reviewers-tools (0.7.1) utopic; urgency=medium | 36 | click-reviewers-tools (0.7.1) utopic; urgency=medium |
791 | 36 | 37 |
I haven't been able to go through the tests' tests yet, but have some nitpicks inline below.