| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import unittest | |
| 7 | |
| 8 import patching | |
| 9 import handlers.policy_checklist.parser | |
| 10 | |
| 11 | |
| 12 def parse_patch_to_chunks(text): | |
| 13 lines = patching.ParsePatchToLines(text.splitlines()) | |
| 14 return handlers.policy_checklist.parser.parse(lines) | |
| 15 | |
| 16 | |
| 17 class PolicyChecklistParserTest(unittest.TestCase): | |
| 18 def test_basic_addition(self): | |
| 19 self.assertEquals([ | |
| 20 { | |
| 21 'start': [None, 4985], | |
| 22 'end': [None, 5003], | |
| 23 'comment_pos': [None, 4986], | |
| 24 'additions': True, | |
| 25 'removals': False, | |
| 26 }], parse_patch_to_chunks(""" | |
| 27 Index: chrome/app/policy/policy_templates.json | |
| 28 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 29 index 7fca71bb7cae78f36f65ec166671a9596cd63a4b..52680ca8ee898a0f1a81c00a7cef669e
38fcac51 100644 | |
| 30 --- a/chrome/app/policy/policy_templates.json | |
| 31 +++ b/chrome/app/policy/policy_templates.json | |
| 32 @@ -112,7 +112,7 @@ | |
| 33 # persistent IDs for all fields (but not for groups!) are needed. These are | |
| 34 # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, | |
| 35 # because doing so would break the deployed wire format! | |
| 36 -# For your editing convenience: highest ID currently used: 218 | |
| 37 +# For your editing convenience: highest ID currently used: 219 | |
| 38 # | |
| 39 # Placeholders: | |
| 40 # The following placeholder strings are automatically substituted: | |
| 41 @@ -4982,6 +4982,24 @@ | |
| 42 | |
| 43 This policy is for internal use by Chrome itself.''', | |
| 44 }, | |
| 45 + { | |
| 46 + 'name': 'SupervisedUsersEnabled', | |
| 47 + 'type': 'main', | |
| 48 + 'schema': { 'type': 'boolean' }, | |
| 49 + 'supported_on': ['chrome_os:29-'], | |
| 50 + 'device_only': True, | |
| 51 + 'features': { | |
| 52 + 'dynamic_refresh': False, | |
| 53 + }, | |
| 54 + 'example_value': True, | |
| 55 + 'id': 219, | |
| 56 + 'caption': '''Enable supervised users.''', | |
| 57 + 'desc': '''If set to true, it is possible to create and log in as a s
upervised user. | |
| 58 + | |
| 59 + If set to false or not configured, supervised users creation and logi
n will be disabled. All existing supervised users will be hidden. | |
| 60 + | |
| 61 + NOTE: The default behavior for consumer and enterprise devices differ
s: on consumer devices supervised users are enabled by default, but on enterpric
e devices they aren't.''' | |
| 62 + }, | |
| 63 ], | |
| 64 }, | |
| 65 ], | |
| 66 """)) | |
| 67 | |
| 68 def test_one_addition_shifted(self): | |
| 69 self.assertEquals([ | |
| 70 { | |
| 71 'start': [None, 4068], | |
| 72 'end': [None, 4081], | |
| 73 'comment_pos': [None, 4068], | |
| 74 'additions': True, | |
| 75 'removals': False, | |
| 76 }], parse_patch_to_chunks(""" | |
| 77 Index: chrome/app/policy/policy_templates.json | |
| 78 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 79 index 1cc92452f6375b7b718c232c42f29d19816554aa..10ad804e04cdcec44eaee5438caa8243
5b799671 100644 | |
| 80 --- a/chrome/app/policy/policy_templates.json | |
| 81 +++ b/chrome/app/policy/policy_templates.json | |
| 82 @@ -117,7 +117,7 @@ | |
| 83 # persistent IDs for all fields (but not for groups!) are needed. These are | |
| 84 # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, | |
| 85 # because doing so would break the deployed wire format! | |
| 86 -# For your editing convenience: highest ID currently used: 235 | |
| 87 +# For your editing convenience: highest ID currently used: 236 | |
| 88 # | |
| 89 # Placeholders: | |
| 90 # The following placeholder strings are automatically substituted: | |
| 91 @@ -4065,6 +4065,20 @@ | |
| 92 The format of the value follows the names of timezones in the "IANA Time
Zone Database" (see "http://en.wikipedia.org/wiki/List_of_tz_database_time"). In
particular, most timezones can be referred to by "continent/large_city" or "oce
an/large_city".''', | |
| 93 }, | |
| 94 { | |
| 95 + 'name': 'SystemUse24HourClock', | |
| 96 + 'type': 'main', | |
| 97 + 'schema': { 'type': 'boolean' }, | |
| 98 + 'supported_on': ['chrome_os:30-'], | |
| 99 + 'device_only': True, | |
| 100 + 'features': { | |
| 101 + 'dynamic_refresh': True, | |
| 102 + }, | |
| 103 + 'example_value': True, | |
| 104 + 'id': 236, | |
| 105 + 'caption': '''Use 24 hour clock by default''', | |
| 106 + 'desc': '''Specifies the clock format be used for the device. Users can o
verride clock format for the current session. However, on logout it is set back
to the specified value. If an empty string is provided, device owner preference
is used.''', | |
| 107 + }, | |
| 108 + { | |
| 109 'name': 'ShowLogoutButtonInTray', | |
| 110 'type': 'main', | |
| 111 'schema': { 'type': 'boolean' }, | |
| 112 """)) | |
| 113 | |
| 114 def test_nested_blocks(self): | |
| 115 self.assertEquals([ | |
| 116 { | |
| 117 'start': [None, 5256], | |
| 118 'end': [None, 5290], | |
| 119 'comment_pos': [None, 5259], | |
| 120 'additions': True, | |
| 121 'removals': False, | |
| 122 }], parse_patch_to_chunks(""" | |
| 123 Index: chrome/app/policy/policy_templates.json | |
| 124 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 125 index 86bc3ac3677d3405afdf39f17c7be373fc0fa0d1..3a32920b3d745fb50432cc15a11a45b8
f88a95d8 100644 | |
| 126 --- a/chrome/app/policy/policy_templates.json | |
| 127 +++ b/chrome/app/policy/policy_templates.json | |
| 128 @@ -5253,6 +5253,40 @@ | |
| 129 }, | |
| 130 ], | |
| 131 }, | |
| 132 + # TODO(joaodasilva): replace the 'dict' type with a more generic | |
| 133 + # 'json' type. The actual schema type for this should be 'array'. | |
| 134 + { | |
| 135 + 'name': 'ManagedBookmarks', | |
| 136 + 'type': 'dict', | |
| 137 + 'schema': { | |
| 138 + 'type': 'object', | |
| 139 + 'items': { | |
| 140 + 'type': 'object', | |
| 141 + 'properties': { | |
| 142 + 'name': { 'type': 'string' }, | |
| 143 + 'url': { 'type': 'string' }, | |
| 144 + }, | |
| 145 + }, | |
| 146 + }, | |
| 147 + 'supported_on': ['android:30-'], | |
| 148 + 'features': { | |
| 149 + 'dynamic_refresh': True, | |
| 150 + 'per_profile': True, | |
| 151 + }, | |
| 152 + 'future': True, | |
| 153 + 'example_value': { "name": "Google", "url": "google.com" }, | |
| 154 + 'id': 227, | |
| 155 + 'caption': '''Managed Bookmarks''', | |
| 156 + 'desc': '''Configures a list of managed bookmarks. | |
| 157 + | |
| 158 + The policy is a list of bookmarks, and each bookmark is a dictionary cont
aining the bookmark "name" and target "url". | |
| 159 + | |
| 160 + These bookmarks are placed in a Managed bookmarks folder inside the Mobil
e bookmarks. These bookmarks can't be modified by the user. | |
| 161 + | |
| 162 + When this policy is set then the Managed bookmarks are the default folder
opened when the bookmarks view is opened in Chrome. | |
| 163 + | |
| 164 + Managed bookmarks are not synced to the user account.''', | |
| 165 + }, | |
| 166 ], | |
| 167 'messages': { | |
| 168 # Messages that are not associated to any policies. | |
| 169 """)) | |
| 170 | |
| 171 def test_two_additions(self): | |
| 172 self.assertEquals([ | |
| 173 { | |
| 174 'start': [None, 4502], | |
| 175 'end': [None, 4525], | |
| 176 'comment_pos': [None, 4503], | |
| 177 'additions': True, | |
| 178 'removals': False, | |
| 179 }, { | |
| 180 'start': [None, 4525], | |
| 181 'end': [None, 4548], | |
| 182 'comment_pos': [None, 4526], | |
| 183 'additions': True, | |
| 184 'removals': False, | |
| 185 }], parse_patch_to_chunks(""" | |
| 186 Index: chrome/app/policy/policy_templates.json | |
| 187 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 188 index 3abaf03cb7529667e01472287eb56773bdcbfc69..fbd4a5bc36fc09825eb321ad10008841
6610b50a 100644 | |
| 189 --- a/chrome/app/policy/policy_templates.json | |
| 190 +++ b/chrome/app/policy/policy_templates.json | |
| 191 @@ -112,7 +112,7 @@ | |
| 192 # persistent IDs for all fields (but not for groups!) are needed. These are | |
| 193 # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, | |
| 194 # because doing so would break the deployed wire format! | |
| 195 -# For your editing convenience: highest ID currently used: 210 | |
| 196 +# For your editing convenience: highest ID currently used: 214 | |
| 197 # | |
| 198 # Placeholders: | |
| 199 # The following placeholder strings are automatically substituted: | |
| 200 @@ -4499,6 +4499,52 @@ | |
| 201 | |
| 202 If this policy is left unset, Accessibility options will not appear i
n the system tray menu, but the user can cause the Accessibility options to appe
ar via the Settings page.''' | |
| 203 }, | |
| 204 + { | |
| 205 + 'name': 'LargeCursorEnabled', | |
| 206 + 'type': 'main', | |
| 207 + 'schema': { 'type': 'boolean' }, | |
| 208 + 'supported_on': ['chrome_os:29-'], | |
| 209 + 'features': { | |
| 210 + 'can_be_recommended': True, | |
| 211 + 'dynamic_refresh': True, | |
| 212 + 'per_profile': True, | |
| 213 + }, | |
| 214 + 'example_value': True, | |
| 215 + 'id': 211, | |
| 216 + 'caption': '''Enable large cursor''', | |
| 217 + 'desc': '''Enable the large cursor accessibility feature. | |
| 218 + | |
| 219 + If this policy is set to true, the large cursor will always be enable
d. | |
| 220 + | |
| 221 + If this policy is set to false, the large cursor will always be disab
led. | |
| 222 + | |
| 223 + If you set this policy, users cannot change or override it. | |
| 224 + | |
| 225 + If this policy is left unset, the large cursor is disabled initially
but can be enabled by the user anytime.''' | |
| 226 + }, | |
| 227 + { | |
| 228 + 'name': 'SpokenFeedbackEnabled', | |
| 229 + 'type': 'main', | |
| 230 + 'schema': { 'type': 'boolean' }, | |
| 231 + 'supported_on': ['chrome_os:29-'], | |
| 232 + 'features': { | |
| 233 + 'can_be_recommended': True, | |
| 234 + 'dynamic_refresh': True, | |
| 235 + 'per_profile': True, | |
| 236 + }, | |
| 237 + 'example_value': True, | |
| 238 + 'id': 212, | |
| 239 + 'caption': '''Enable spoken feedback''', | |
| 240 + 'desc': '''Enable the spoken feedback accessibility feature. | |
| 241 + | |
| 242 + If this policy is set to true, spoken feedback will always be enabled
. | |
| 243 + | |
| 244 + If this policy is set to false, spoken feedback will always be disabl
ed. | |
| 245 + | |
| 246 + If you set this policy, users cannot change or override it. | |
| 247 + | |
| 248 + If this policy is left unset, spoken feedback is disabled initially b
ut can be enabled by the user anytime.''' | |
| 249 + }, | |
| 250 ], | |
| 251 }, | |
| 252 { | |
| 253 """)) | |
| 254 | |
| 255 def test_group_additions(self): | |
| 256 self.assertEquals([ | |
| 257 { | |
| 258 'start': [None, 4523], | |
| 259 'end': [None, 4545], | |
| 260 'comment_pos': [None, 4530], | |
| 261 'additions': True, | |
| 262 'removals': False, | |
| 263 }, { | |
| 264 'start': [None, 4545], | |
| 265 'end': [None, 4564], | |
| 266 'comment_pos': [None, 4546], | |
| 267 'additions': True, | |
| 268 'removals': False, | |
| 269 }], parse_patch_to_chunks(""" | |
| 270 Index: chrome/app/policy/policy_templates.json | |
| 271 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 272 index 6a1293696283e232070e61104a369e52a615cdf1..dad016adf0ae2055a6e7cb1275fb99d3
3c703ab2 100644 | |
| 273 --- a/chrome/app/policy/policy_templates.json | |
| 274 +++ b/chrome/app/policy/policy_templates.json | |
| 275 @@ -112,7 +112,7 @@ | |
| 276 # persistent IDs for all fields (but not for groups!) are needed. These are | |
| 277 # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, | |
| 278 # because doing so would break the deployed wire format! | |
| 279 -# For your editing convenience: highest ID currently used: 199 | |
| 280 +# For your editing convenience: highest ID currently used: 201 | |
| 281 # | |
| 282 # Placeholders: | |
| 283 # The following placeholder strings are automatically substituted: | |
| 284 @@ -4520,6 +4520,49 @@ | |
| 285 | |
| 286 If not specified, will not modify the Variations seed URL.''', | |
| 287 }, | |
| 288 + { | |
| 289 + 'name': 'Attestation', | |
| 290 + 'type': 'group', | |
| 291 + 'caption': 'Remote Attestation', | |
| 292 + 'desc': 'Configure the remote attestation with TPM mechanism.', | |
| 293 + 'policies': [ | |
| 294 + { | |
| 295 + 'name': 'AttestationEnabledForUser', | |
| 296 + 'type': 'main', | |
| 297 + 'schema': { 'type': 'boolean' }, | |
| 298 + 'supported_on': ['chrome_os:28-'], | |
| 299 + 'features': { | |
| 300 + 'dynamic_refresh': True, | |
| 301 + 'per_profile': True, | |
| 302 + }, | |
| 303 + 'example_value': True, | |
| 304 + 'id': 200, | |
| 305 + 'caption': '''Enable remote attestation for the user.''', | |
| 306 + 'desc': '''If true, the user can use the hardware on Chrome devices t
o remote attest its identity to the privacy CA via the Enterprise Platform Keys
API chrome.enterprise.platformKeysPrivate.challengeUserKey(). | |
| 307 + | |
| 308 + If it is set to false, or if it is not set, calls to the API will fai
l with an error code.''', | |
| 309 + }, | |
| 310 + { | |
| 311 + 'name': 'AttestationExtensionWhitelist', | |
| 312 + 'type': 'list', | |
| 313 + 'schema': { | |
| 314 + 'type': 'array', | |
| 315 + 'items': { 'type': 'string' }, | |
| 316 + }, | |
| 317 + 'supported_on': ['chrome_os:28-'], | |
| 318 + 'features': { | |
| 319 + 'dynamic_refresh': True, | |
| 320 + 'per_profile': True, | |
| 321 + }, | |
| 322 + 'example_value': ['ghdilpkmfbfdnomkmaiogjhjnggaggoi'], | |
| 323 + 'id': 201, | |
| 324 + 'caption': '''Extensions allowed to to use the remote attestation API
.''', | |
| 325 + 'desc': '''This policy specifies the allowed extensions to use Enterp
rise Platform Keys API chrome.enterprise.platformKeysPrivate.challengeUserKey()
for remote attestation. Extensions must be added to this list to use the API. | |
| 326 + | |
| 327 + If an extension is not in the list, or the list is not set, the call
to the API will fail with an error code.''', | |
| 328 + }, | |
| 329 + ], | |
| 330 + }, | |
| 331 ], | |
| 332 'messages': { | |
| 333 # Messages that are not associated to any policies. | |
| 334 """)) | |
| 335 | |
| 336 def test_simple_edit(self): | |
| 337 self.assertEquals([ | |
| 338 { | |
| 339 'start': [300, 300], | |
| 340 'end': [301, 301], | |
| 341 'comment_pos': [300, 300], | |
| 342 'additions': True, | |
| 343 'removals': True, | |
| 344 }], parse_patch_to_chunks(""" | |
| 345 Index: chrome/app/policy/policy_templates.json | |
| 346 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 347 index 02e1801f8906343b6168f86c45ae3b2c0c9f5363..86bc3ac3677d3405afdf39f17c7be373
fc0fa0d1 100644 | |
| 348 --- a/chrome/app/policy/policy_templates.json | |
| 349 +++ b/chrome/app/policy/policy_templates.json | |
| 350 @@ -297,7 +297,7 @@ | |
| 351 'name': 'DisableSpdy', | |
| 352 'type': 'main', | |
| 353 'schema': { 'type': 'boolean' }, | |
| 354 - 'supported_on': ['chrome.*:8-', 'chrome_os:0.11-'], | |
| 355 + 'supported_on': ['chrome.*:8-', 'chrome_os:0.11-', 'android:30-'], | |
| 356 'features': { | |
| 357 'dynamic_refresh': True, | |
| 358 'per_profile': False, | |
| 359 """)) | |
| 360 | |
| 361 def test_complex_edit(self): | |
| 362 self.assertEquals([ | |
| 363 { | |
| 364 'start': [328, 328], | |
| 365 'end': [332, 335], | |
| 366 'comment_pos': [328, 328], | |
| 367 'additions': True, | |
| 368 'removals': True, | |
| 369 }], parse_patch_to_chunks(""" | |
| 370 Index: chrome/app/policy/policy_templates.json | |
| 371 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 372 index 602196317bd5bc00ed0884c2ef3e563910820686..c38156df31142a39a6b6fa215bc629f2
ca0e7f94 100644 | |
| 373 --- a/chrome/app/policy/policy_templates.json | |
| 374 +++ b/chrome/app/policy/policy_templates.json | |
| 375 @@ -325,10 +325,13 @@ | |
| 376 'dynamic_refresh': True, | |
| 377 'per_profile': False, | |
| 378 }, | |
| 379 - 'example_value': ['file', 'mailto'], | |
| 380 + 'deprecated': True, | |
| 381 + 'example_value': ['file', 'https'], | |
| 382 'id': 85, | |
| 383 'caption': '''Disable URL protocol schemes''', | |
| 384 - 'desc': '''Disables the listed protocol schemes in <ph name="PRODUCT_NAME
">$1<ex>Google Chrome</ex></ph>. | |
| 385 + 'desc': '''This policy is deprecated, please use URLBlacklist instead. | |
| 386 + | |
| 387 + Disables the listed protocol schemes in <ph name="PRODUCT_NAME">$1<ex>Goo
gle Chrome</ex></ph>. | |
| 388 | |
| 389 URLs using a scheme from this list will not load and can not be navigated
to. | |
| 390 """)) | |
| 391 | |
| 392 def test_enum_item_names_ignored_for_comment_pos(self): | |
| 393 self.assertEquals([ | |
| 394 { | |
| 395 'start': [None, 3323], | |
| 396 'end': [None, 3363], | |
| 397 'comment_pos': [None, 3324], | |
| 398 'additions': True, | |
| 399 'removals': False, | |
| 400 }], parse_patch_to_chunks(""" | |
| 401 Index: chrome/app/policy/policy_templates.json | |
| 402 diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_
templates.json | |
| 403 index c888dcbf4fc32656c048054ca149e245989281d5..7de3edae00f1e8ff5984be8f10091ee0
44655d8a 100644 | |
| 404 --- a/chrome/app/policy/policy_templates.json | |
| 405 +++ b/chrome/app/policy/policy_templates.json | |
| 406 @@ -112,7 +112,7 @@ | |
| 407 # persistent IDs for all fields (but not for groups!) are needed. These are | |
| 408 # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, | |
| 409 # because doing so would break the deployed wire format! | |
| 410 -# For your editing convenience: highest ID currently used: 165 | |
| 411 +# For your editing convenience: highest ID currently used: 166 | |
| 412 # | |
| 413 # Placeholders: | |
| 414 # The following placeholder strings are automatically substituted: | |
| 415 @@ -3320,6 +3320,46 @@ | |
| 416 | |
| 417 If this policy is left not set, the users will be able to change whether
the built-in DNS client is used by editing chrome://flags or specifying a comman
d-line flag.''', | |
| 418 }, | |
| 419 + { | |
| 420 + 'name': 'ShelfAutoHideBehavior', | |
| 421 + 'type': 'string-enum', | |
| 422 + 'schema': { | |
| 423 + 'type': 'string', | |
| 424 + 'enum': [ | |
| 425 + 'Always', | |
| 426 + 'Never' | |
| 427 + ], | |
| 428 + }, | |
| 429 + 'items': [ | |
| 430 + { | |
| 431 + 'name': 'AlwaysAutoHideShelf', | |
| 432 + 'value': 'Always', | |
| 433 + 'caption': '''Always auto-hide the shelf''', | |
| 434 + }, | |
| 435 + { | |
| 436 + 'name': 'NeverAutoHideShelf', | |
| 437 + 'value': 'Never', | |
| 438 + 'caption': '''Never auto-hide the shelf''', | |
| 439 + }, | |
| 440 + ], | |
| 441 + 'supported_on': ['chrome_os:25-'], | |
| 442 + 'features': { | |
| 443 + 'dynamic_refresh': True, | |
| 444 + 'can_be_recommended': True, | |
| 445 + }, | |
| 446 + 'example_value': 'Always', | |
| 447 + 'id': 166, | |
| 448 + 'caption': '''Control shelf auto-hiding''', | |
| 449 + 'desc': '''Control auto-hiding of the <ph name="PRODUCT_OS_NAME">$2<ex>Go
ogle Chrome OS</ex></ph> shelf. | |
| 450 + | |
| 451 + If this policy is set to 'AlwaysAutoHideShelf', the shelf will always aut
o-hide. | |
| 452 + | |
| 453 + If this policy is set to 'NeverAutoHideShelf', the shelf never auto-hide. | |
| 454 + | |
| 455 + If you set this policy, users cannot change or override it. | |
| 456 + | |
| 457 + If the policy is left not set, users can choose whether the shelf should
auto-hide.''', | |
| 458 + }, | |
| 459 ], | |
| 460 'messages': { | |
| 461 # Messages that are not associated to any policies. | |
| 462 """)) | |
| 463 | |
| 464 | |
| 465 if __name__ == '__main__': | |
| 466 unittest.main() | |
| OLD | NEW |