| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 '''Unit tests for writers.reg_writer''' | 7 '''Unit tests for writers.reg_writer''' |
| 8 | 8 |
| 9 | 9 |
| 10 import os | 10 import os |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 }''' | 311 }''' |
| 312 output = self.GetOutput(policy_json, {'_chromium' : '1'}, 'reg') | 312 output = self.GetOutput(policy_json, {'_chromium' : '1'}, 'reg') |
| 313 expected_output = self.NEWLINE.join([ | 313 expected_output = self.NEWLINE.join([ |
| 314 'Windows Registry Editor Version 5.00', | 314 'Windows Registry Editor Version 5.00', |
| 315 '', | 315 '', |
| 316 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', | 316 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', |
| 317 '"DictionaryPolicy"="{"bool": true, "dict": {"a": 1, ' | 317 '"DictionaryPolicy"="{"bool": true, "dict": {"a": 1, ' |
| 318 '"b": 2}, "int": 10, "list": [1, 2, 3], "string": "abc"}"']) | 318 '"b": 2}, "int": 10, "list": [1, 2, 3], "string": "abc"}"']) |
| 319 self.CompareOutputs(output, expected_output) | 319 self.CompareOutputs(output, expected_output) |
| 320 | 320 |
| 321 def testExternalPolicy(self): |
| 322 # Tests a policy group with a single policy of type 'external'. |
| 323 example = { |
| 324 'url': "https://example.com/avatar.jpg", |
| 325 'hash': "deadbeef", |
| 326 } |
| 327 policy_json = ''' |
| 328 { |
| 329 "policy_definitions": [ |
| 330 { |
| 331 "name": "ExternalPolicy", |
| 332 "type": "external", |
| 333 "caption": "", |
| 334 "desc": "", |
| 335 "supported_on": ["chrome.win:8-"], |
| 336 "example_value": %s |
| 337 }, |
| 338 ], |
| 339 "placeholders": [], |
| 340 "messages": {}, |
| 341 }''' % str(example) |
| 342 output = self.GetOutput(policy_json, {'_chromium' : '1'}, 'reg') |
| 343 expected_output = self.NEWLINE.join([ |
| 344 'Windows Registry Editor Version 5.00', |
| 345 '', |
| 346 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium]', |
| 347 '"ExternalPolicy"="{"hash": "deadbeef", "url": "https://example.com/avat
ar.jpg"}"']) |
| 348 self.CompareOutputs(output, expected_output) |
| 349 |
| 321 def testNonSupportedPolicy(self): | 350 def testNonSupportedPolicy(self): |
| 322 # Tests a policy that is not supported on Windows, so it shouldn't | 351 # Tests a policy that is not supported on Windows, so it shouldn't |
| 323 # be included in the .REG file. | 352 # be included in the .REG file. |
| 324 policy_json = ''' | 353 policy_json = ''' |
| 325 { | 354 { |
| 326 "policy_definitions": [ | 355 "policy_definitions": [ |
| 327 { | 356 { |
| 328 "name": "NonWindowsPolicy", | 357 "name": "NonWindowsPolicy", |
| 329 "type": "list", | 358 "type": "list", |
| 330 "caption": "", | 359 "caption": "", |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 '"Policy2"="c"', | 408 '"Policy2"="c"', |
| 380 '', | 409 '', |
| 381 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', | 410 '[HKEY_LOCAL_MACHINE\\Software\\Policies\\Chromium\\Policy1]', |
| 382 '"1"="a"', | 411 '"1"="a"', |
| 383 '"2"="b"']) | 412 '"2"="b"']) |
| 384 self.CompareOutputs(output, expected_output) | 413 self.CompareOutputs(output, expected_output) |
| 385 | 414 |
| 386 | 415 |
| 387 if __name__ == '__main__': | 416 if __name__ == '__main__': |
| 388 unittest.main() | 417 unittest.main() |
| OLD | NEW |