Merge lp:~marcustomlinson/click-reviewers-tools/lp-1511063 into lp:click-reviewers-tools

Proposed by Marcus Tomlinson
Status: Merged
Merged at revision: 554
Proposed branch: lp:~marcustomlinson/click-reviewers-tools/lp-1511063
Merge into: lp:click-reviewers-tools
Diff against target: 88 lines (+36/-2)
3 files modified
check-names.list (+1/-0)
clickreviews/cr_scope.py (+21/-1)
clickreviews/tests/test_cr_scope.py (+14/-1)
To merge this branch: bzr merge lp:~marcustomlinson/click-reviewers-tools/lp-1511063
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Approve
Review via email: mp+279073@code.launchpad.net

Commit message

Forbid the internal "DebugMode" scope.ini key from making its way into the store

To post a comment you must log in.
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

LGTM. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'check-names.list'
--- check-names.list 2015-11-24 12:13:36 +0000
+++ check-names.list 2015-12-01 07:47:30 +0000
@@ -127,6 +127,7 @@
127scope:ini_scope_required_fields|127scope:ini_scope_required_fields|
128scope:ini_scope_section|128scope:ini_scope_section|
129scope:ini_scope_unknown_fields|129scope:ini_scope_unknown_fields|
130scope:ini_scope_internal_fields|
130scope:peer_hooks_disallowed|131scope:peer_hooks_disallowed|
131scope:peer_hooks_required|132scope:peer_hooks_required|
132security:apparmor_profile|133security:apparmor_profile|
133134
=== modified file 'clickreviews/cr_scope.py'
--- clickreviews/cr_scope.py 2015-11-17 12:41:31 +0000
+++ clickreviews/cr_scope.py 2015-12-01 07:47:30 +0000
@@ -120,6 +120,7 @@
120 translated = ['description',120 translated = ['description',
121 'displayname',121 'displayname',
122 'searchhint']122 'searchhint']
123 internal = ['debugmode']
123124
124 missing = []125 missing = []
125 t = 'info'126 t = 'info'
@@ -146,7 +147,7 @@
146 unknown = []147 unknown = []
147 for i in self.scopes[app]["scope_config"]['ScopeConfig'].keys():148 for i in self.scopes[app]["scope_config"]['ScopeConfig'].keys():
148 f = i.lower()149 f = i.lower()
149 if f not in required and f not in optional and \150 if f not in required and f not in optional and f not in internal and \
150 (f.split("[")[0] not in translated or not151 (f.split("[")[0] not in translated or not
151 re.search('.*\[[a-z]{2,3}(_[a-z]{2,3})?\]$', f)):152 re.search('.*\[[a-z]{2,3}(_[a-z]{2,3})?\]$', f)):
152 unknown.append(f)153 unknown.append(f)
@@ -162,3 +163,22 @@
162 self.scopes[app]["ini_file_rel"],163 self.scopes[app]["ini_file_rel"],
163 ", ".join(unknown))164 ", ".join(unknown))
164 self._add_result(t, n, s)165 self._add_result(t, n, s)
166
167 t = 'info'
168 n = self._get_check_name('ini_scope_internal_fields', app=app)
169 s = "OK"
170 forbidden = []
171 for r in internal:
172 if r in self.scopes[app]["scope_config"]['ScopeConfig']:
173 forbidden.append(r)
174 if len(forbidden) == 1:
175 t = 'error'
176 s = "Forbidden field in '%s': %s" % (
177 self.scopes[app]["ini_file_rel"],
178 forbidden[0])
179 elif len(forbidden) > 1:
180 t = 'error'
181 s = "Forbidden fields in '%s': %s" % (
182 self.scopes[app]["ini_file_rel"],
183 ", ".join(forbidden))
184 self._add_result(t, n, s)
165185
=== modified file 'clickreviews/tests/test_cr_scope.py'
--- clickreviews/tests/test_cr_scope.py 2015-11-17 12:41:31 +0000
+++ clickreviews/tests/test_cr_scope.py 2015-12-01 07:47:30 +0000
@@ -62,7 +62,7 @@
62 c = ClickReviewScope(self.test_name)62 c = ClickReviewScope(self.test_name)
63 c.check_scope_ini()63 c.check_scope_ini()
64 r = c.click_report64 r = c.click_report
65 expected_counts = {'info': 3, 'warn': 0, 'error': 0}65 expected_counts = {'info': 4, 'warn': 0, 'error': 0}
66 self.check_results(r, expected_counts)66 self.check_results(r, expected_counts)
6767
68 def test_check_scope_ini_missing_required1(self):68 def test_check_scope_ini_missing_required1(self):
@@ -197,6 +197,19 @@
197 expected_counts = {'info': None, 'warn': 1, 'error': 0}197 expected_counts = {'info': None, 'warn': 1, 'error': 0}
198 self.check_results(r, expected_counts)198 self.check_results(r, expected_counts)
199199
200 def test_check_scope_ini_forbidden_field(self):
201 '''Test check_scope_ini() - forbidden field'''
202 config = self._stub_config()
203 config['debugmode'] = "true"
204 scope = self._create_scope(config)
205
206 self.set_test_scope(self.default_appname, scope)
207 c = ClickReviewScope(self.test_name)
208 c.check_scope_ini()
209 r = c.click_report
210 expected_counts = {'info': None, 'warn': 0, 'error': 1}
211 self.check_results(r, expected_counts)
212
200 def test_check_peer_hooks(self):213 def test_check_peer_hooks(self):
201 '''Test check_peer_hooks()'''214 '''Test check_peer_hooks()'''
202 c = ClickReviewScope(self.test_name)215 c = ClickReviewScope(self.test_name)

Subscribers

People subscribed via source and target branches