Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('certificate_manager_page', function() { | 5 cr.define('certificate_manager_page', function() { |
| 6 /** | 6 /** |
| 7 * A test version of CertificatesBrowserProxy. Provides helper methods | 7 * A test version of CertificatesBrowserProxy. Provides helper methods |
| 8 * for allowing tests to know when a method was called, as well as | 8 * for allowing tests to know when a method was called, as well as |
| 9 * specifying mock responses. | 9 * specifying mock responses. |
| 10 * | 10 * |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 'getCaCertificateTrust', | 22 'getCaCertificateTrust', |
| 23 'importCaCertificate', | 23 'importCaCertificate', |
| 24 'importCaCertificateTrustSelected', | 24 'importCaCertificateTrustSelected', |
| 25 'importPersonalCertificate', | 25 'importPersonalCertificate', |
| 26 'importPersonalCertificatePasswordSelected', | 26 'importPersonalCertificatePasswordSelected', |
| 27 'importServerCertificate', | 27 'importServerCertificate', |
| 28 'refreshCertificates', | 28 'refreshCertificates', |
| 29 'viewCertificate', | 29 'viewCertificate', |
| 30 ]); | 30 ]); |
| 31 | 31 |
| 32 /** @type {boolean} */ | |
| 33 this.useHardwareBacked = false; | |
| 34 | |
| 32 /** @private {!CaTrustInfo} */ | 35 /** @private {!CaTrustInfo} */ |
| 33 this.caTrustInfo_ = {ssl: true, email: true, objSign: true}; | 36 this.caTrustInfo_ = {ssl: true, email: true, objSign: true}; |
| 34 | 37 |
| 35 /** @private {?CertificatesError} */ | 38 /** @private {?CertificatesError} */ |
| 36 this.certificatesError_ = null; | 39 this.certificatesError_ = null; |
| 37 }; | 40 }; |
| 38 | 41 |
| 39 TestCertificatesBrowserProxy.prototype = { | 42 TestCertificatesBrowserProxy.prototype = { |
| 40 __proto__: settings.TestBrowserProxy.prototype, | 43 __proto__: settings.TestBrowserProxy.prototype, |
| 41 | 44 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 }, | 109 }, |
| 107 | 110 |
| 108 /** @override */ | 111 /** @override */ |
| 109 exportPersonalCertificatePasswordSelected: function(password) { | 112 exportPersonalCertificatePasswordSelected: function(password) { |
| 110 this.resolverMap_.get( | 113 this.resolverMap_.get( |
| 111 'exportPersonalCertificatePasswordSelected').resolve(password); | 114 'exportPersonalCertificatePasswordSelected').resolve(password); |
| 112 return this.fulfillRequest_(); | 115 return this.fulfillRequest_(); |
| 113 }, | 116 }, |
| 114 | 117 |
| 115 /** @override */ | 118 /** @override */ |
| 116 importPersonalCertificate: function() { | 119 importPersonalCertificate: function(useHardwareBacked) { |
| 120 this.useHardwareBacked = useHardwareBacked; | |
| 117 this.methodCalled('importPersonalCertificate'); | 121 this.methodCalled('importPersonalCertificate'); |
| 118 return Promise.resolve(true); | 122 return Promise.resolve(true); |
|
dpapad
2017/01/24 23:16:03
This should be
return Promise.resolve(this.useHar
stevenjb
2017/01/25 19:39:35
Actually, useHardwareBacked can be passed to metho
dpapad
2017/01/25 21:14:00
Ah you are right. That is what I origanaly meant,
| |
| 119 }, | 123 }, |
| 120 | 124 |
| 121 /** @override */ | 125 /** @override */ |
| 122 importPersonalCertificatePasswordSelected: function(password) { | 126 importPersonalCertificatePasswordSelected: function(password) { |
| 123 this.resolverMap_.get( | 127 this.resolverMap_.get( |
| 124 'importPersonalCertificatePasswordSelected').resolve(password); | 128 'importPersonalCertificatePasswordSelected').resolve(password); |
| 125 return this.fulfillRequest_(); | 129 return this.fulfillRequest_(); |
| 126 }, | 130 }, |
| 127 | 131 |
| 128 /** @override */ | 132 /** @override */ |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 teardown(function() { element.remove(); }); | 796 teardown(function() { element.remove(); }); |
| 793 | 797 |
| 794 /** | 798 /** |
| 795 * Tests the "Import" button functionality. | 799 * Tests the "Import" button functionality. |
| 796 * @param {!CertificateType} certificateType | 800 * @param {!CertificateType} certificateType |
| 797 * @param {string} proxyMethodName The name of the proxy method expected | 801 * @param {string} proxyMethodName The name of the proxy method expected |
| 798 * to be called. | 802 * to be called. |
| 799 * @param {boolean} actionEventExpected Whether a | 803 * @param {boolean} actionEventExpected Whether a |
| 800 * settings.CertificateActionEvent is expected to fire as a result | 804 * settings.CertificateActionEvent is expected to fire as a result |
| 801 * tapping the Import button. | 805 * tapping the Import button. |
| 806 * @param {boolean=} opt_bind Whether to click on the import and bind btn. | |
|
dpapad
2017/01/24 23:16:03
Can we make this parameter required? All calls are
stevenjb
2017/01/25 19:39:35
Noisy change imho, but sure.
| |
| 802 */ | 807 */ |
| 803 function testImportForCertificateType( | 808 function testImportForCertificateType( |
| 804 certificateType, proxyMethodName, actionEventExpected) { | 809 certificateType, proxyMethodName, actionEventExpected, opt_bind) { |
| 805 element.certificateType = certificateType | 810 element.certificateType = certificateType; |
| 806 Polymer.dom.flush(); | 811 Polymer.dom.flush(); |
| 807 | 812 |
| 808 var importButton = element.$$('paper-button'); | 813 var importButton = |
| 814 opt_bind ? element.$$('#importAndBind') : element.$$('#import'); | |
| 809 assertTrue(!!importButton); | 815 assertTrue(!!importButton); |
| 810 | 816 |
| 811 var waitForActionEvent = actionEventExpected ? | 817 var waitForActionEvent = actionEventExpected ? |
| 812 test_util.eventToPromise(settings.CertificateActionEvent, element) : | 818 test_util.eventToPromise(settings.CertificateActionEvent, element) : |
| 813 Promise.resolve(null); | 819 Promise.resolve(null); |
| 814 | 820 |
| 815 MockInteractions.tap(importButton); | 821 MockInteractions.tap(importButton); |
| 816 return browserProxy.whenCalled(proxyMethodName).then(function() { | 822 return browserProxy.whenCalled(proxyMethodName).then(function() { |
| 817 return waitForActionEvent; | 823 return waitForActionEvent; |
| 818 }).then(function(event) { | 824 }).then(function(event) { |
| 819 if (actionEventExpected) { | 825 if (actionEventExpected) { |
| 820 assertEquals( | 826 assertEquals( |
| 821 CertificateAction.IMPORT, event.detail.action); | 827 CertificateAction.IMPORT, event.detail.action); |
| 822 assertEquals(certificateType, event.detail.certificateType); | 828 assertEquals(certificateType, event.detail.certificateType); |
| 829 assertTrue( | |
| 830 proxyMethodName != 'importPersonalCertificate' || | |
|
dpapad
2017/01/24 23:16:03
Don't fully understand this assertion. Can you exp
stevenjb
2017/01/25 19:39:35
Done.
| |
| 831 !!opt_bind == browserProxy.useHardwareBacked); | |
| 823 } | 832 } |
| 824 }); | 833 }); |
| 825 } | 834 } |
| 826 | 835 |
| 827 test('ImportButton_Personal', function() { | 836 test('ImportButton_Personal', function() { |
| 828 return testImportForCertificateType( | 837 return testImportForCertificateType( |
| 829 CertificateType.PERSONAL, | 838 CertificateType.PERSONAL, |
| 830 'importPersonalCertificate', true); | 839 'importPersonalCertificate', true); |
| 831 }); | 840 }); |
| 832 | 841 |
| 842 if (cr.isChromeOS) { | |
| 843 test('ImportAndBindButton_Personal', function() { | |
| 844 return testImportForCertificateType( | |
| 845 CertificateType.PERSONAL, | |
| 846 'importPersonalCertificate', true, true); | |
| 847 }); | |
| 848 } | |
| 849 | |
| 833 test('ImportButton_Server', function() { | 850 test('ImportButton_Server', function() { |
| 834 return testImportForCertificateType( | 851 return testImportForCertificateType( |
| 835 CertificateType.SERVER, 'importServerCertificate', | 852 CertificateType.SERVER, 'importServerCertificate', |
| 836 false); | 853 false); |
| 837 }); | 854 }); |
| 838 | 855 |
| 839 test('ImportButton_CA', function() { | 856 test('ImportButton_CA', function() { |
| 840 return testImportForCertificateType( | 857 return testImportForCertificateType( |
| 841 CertificateType.CA, 'importCaCertificate', true); | 858 CertificateType.CA, 'importCaCertificate', true); |
| 842 }); | 859 }); |
| 843 }); | 860 }); |
| 844 } | 861 } |
| 845 | 862 |
| 846 return { | 863 return { |
| 847 registerTests: function() { | 864 registerTests: function() { |
| 848 registerCaTrustEditDialogTests(); | 865 registerCaTrustEditDialogTests(); |
| 849 registerDeleteDialogTests(); | 866 registerDeleteDialogTests(); |
| 850 registerPasswordEncryptDialogTests(); | 867 registerPasswordEncryptDialogTests(); |
| 851 registerPasswordDecryptDialogTests(); | 868 registerPasswordDecryptDialogTests(); |
| 852 registerPageTests(); | 869 registerPageTests(); |
| 853 registerCertificateSubentryTests(); | 870 registerCertificateSubentryTests(); |
| 854 registerCertificateListTests(); | 871 registerCertificateListTests(); |
| 855 }, | 872 }, |
| 856 }; | 873 }; |
| 857 }); | 874 }); |
| OLD | NEW |