Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Unified Diff: chrome/test/data/webui/settings/certificate_manager_page_test.js

Issue 1863733003: MD Settings: Certificate manager, implement importing CA certificate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove hasOwnProperty. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/settings/certificate_manager_page_test.js
diff --git a/chrome/test/data/webui/settings/certificate_manager_page_test.js b/chrome/test/data/webui/settings/certificate_manager_page_test.js
index 1f4316c8ff914ae787ed7669862059ba2b1876e8..139eaadf279dc269a06a12dd592a2ec29d170552 100644
--- a/chrome/test/data/webui/settings/certificate_manager_page_test.js
+++ b/chrome/test/data/webui/settings/certificate_manager_page_test.js
@@ -21,6 +21,7 @@ cr.define('certificate_manager_page', function() {
'exportPersonalCertificatePasswordSelected',
'getCaCertificateTrust',
'importCaCertificate',
+ 'importCaCertificateTrustSelected',
'importPersonalCertificate',
'importPersonalCertificatePasswordSelected',
'importServerCertificate',
@@ -64,6 +65,14 @@ cr.define('certificate_manager_page', function() {
},
/** @override */
+ importCaCertificateTrustSelected: function(ssl, email, objSign) {
+ this.methodCalled('importCaCertificateTrustSelected', {
+ ssl: ssl, email: email, objSign: objSign,
+ });
+ return this.fulfillRequest_();
+ },
+
+ /** @override */
editCaCertificateTrust: function(id, ssl, email, objSign) {
this.methodCalled('editCaCertificateTrust', {
id: id, ssl: ssl, email: email, objSign: objSign,
@@ -192,9 +201,6 @@ cr.define('certificate_manager_page', function() {
/** @type {?TestCertificatesBrowserProxy} */
var browserProxy = null;
- /** @type {!CertificateSubnode} */
- var model = createSampleCertificateSubnode();
-
/** @type {!CaTrustInfo} */
var caTrustInfo = { ssl: true, email: false, objSign: false };
@@ -206,16 +212,17 @@ cr.define('certificate_manager_page', function() {
settings.CertificatesBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
dialog = document.createElement('settings-ca-trust-edit-dialog');
- dialog.model = model;
- document.body.appendChild(dialog);
});
teardown(function() { dialog.remove(); });
test('EditSuccess', function() {
+ dialog.model = createSampleCertificateSubnode();
+ document.body.appendChild(dialog);
+
return browserProxy.whenCalled('getCaCertificateTrust').then(
function(id) {
- assertEquals(model.id, id);
+ assertEquals(dialog.model.id, id);
assertEquals(caTrustInfo.ssl, dialog.$.ssl.checked);
assertEquals(caTrustInfo.email, dialog.$.email.checked);
assertEquals(caTrustInfo.objSign, dialog.$.objSign.checked);
@@ -229,9 +236,8 @@ cr.define('certificate_manager_page', function() {
MockInteractions.tap(dialog.$.ok);
return browserProxy.whenCalled('editCaCertificateTrust');
- }).then(
- function(args) {
- assertEquals(model.id, args.id);
+ }).then(function(args) {
+ assertEquals(dialog.model.id, args.id);
// Checking that the values sent to C++ are reflecting the
// changes made by the user (toggling all checkboxes).
assertEquals(caTrustInfo.ssl, !args.ssl);
@@ -242,8 +248,32 @@ cr.define('certificate_manager_page', function() {
});
});
+ test('ImportSuccess', function() {
+ dialog.model = {name: 'Dummy certificate name'};
+ document.body.appendChild(dialog);
+
+ assertFalse(dialog.$.ssl.checked);
+ assertFalse(dialog.$.email.checked);
+ assertFalse(dialog.$.objSign.checked);
+
+ MockInteractions.tap(dialog.$.ssl);
+ MockInteractions.tap(dialog.$.email);
+
+ // Simulate clicking 'OK'.
+ MockInteractions.tap(dialog.$.ok);
+ return browserProxy.whenCalled('importCaCertificateTrustSelected').then(
+ function(args) {
+ assertTrue(args.ssl);
+ assertTrue(args.email);
+ assertFalse(args.objSign);
+ });
+ });
+
test('EditError', function() {
+ dialog.model = createSampleCertificateSubnode();
+ document.body.appendChild(dialog);
browserProxy.forceCertificatesError();
+
var whenErrorEventFired = eventToPromise('certificates-error', dialog);
return browserProxy.whenCalled('getCaCertificateTrust').then(
@@ -651,30 +681,14 @@ cr.define('certificate_manager_page', function() {
});
/**
- * Dispatches a settings.CertificateActionEvent.
- * @param {!settings.CertificateAction} action The type of action to
- * simulate.
- */
- function dispatchCertificateActionEvent(action) {
- page.fire(
- settings.CertificateActionEvent,
- /** @type {!CertificateActionEventDetail} */ ({
- action: action,
- subnode: createSampleCertificateSubnode(),
- certificateType: settings.CertificateType.PERSONAL
- }));
- }
-
- /**
* Tests that a dialog opens as a response to a
* settings.CertificateActionEvent.
* @param {string} dialogTagName The type of dialog to test.
- * @param {!settings.CertificateAction} action The action that is supposed
- * to trigger the dialog.
+ * @param {CertificateActionEventDetail} eventDetail
*/
- function testDialogOpensOnAction(dialogTagName, action) {
+ function testDialogOpensOnAction(dialogTagName, eventDetail) {
assertFalse(!!page.shadowRoot.querySelector(dialogTagName));
- dispatchCertificateActionEvent(action);
+ page.fire(settings.CertificateActionEvent, eventDetail);
Polymer.dom.flush();
assertTrue(!!page.shadowRoot.querySelector(dialogTagName));
}
@@ -682,24 +696,51 @@ cr.define('certificate_manager_page', function() {
test('OpensDialog_DeleteConfirmation', function() {
testDialogOpensOnAction(
'settings-certificate-delete-confirmation-dialog',
- settings.CertificateAction.DELETE);
+ /** @type {!CertificateActionEventDetail} */ ({
+ action: settings.CertificateAction.DELETE,
+ subnode: createSampleCertificateSubnode(),
+ certificateType: settings.CertificateType.PERSONAL
+ }));
});
test('OpensDialog_PasswordEncryption', function() {
testDialogOpensOnAction(
'settings-certificate-password-encryption-dialog',
- settings.CertificateAction.EXPORT_PERSONAL);
+ /** @type {!CertificateActionEventDetail} */ ({
+ action: settings.CertificateAction.EXPORT_PERSONAL,
+ subnode: createSampleCertificateSubnode(),
+ certificateType: settings.CertificateType.PERSONAL
+ }));
});
test('OpensDialog_PasswordDecryption', function() {
testDialogOpensOnAction(
'settings-certificate-password-decryption-dialog',
- settings.CertificateAction.IMPORT);
+ /** @type {!CertificateActionEventDetail} */ ({
+ action: settings.CertificateAction.IMPORT,
+ subnode: createSampleCertificateSubnode(),
+ certificateType: settings.CertificateType.PERSONAL
+ }));
});
test('OpensDialog_CaTrustEdit', function() {
testDialogOpensOnAction(
- 'settings-ca-trust-edit-dialog', settings.CertificateAction.EDIT);
+ 'settings-ca-trust-edit-dialog',
+ /** @type {!CertificateActionEventDetail} */ ({
+ action: settings.CertificateAction.EDIT,
+ subnode: createSampleCertificateSubnode(),
+ certificateType: settings.CertificateType.CA
+ }));
+ });
+
+ test('OpensDialog_CaTrustImport', function() {
+ testDialogOpensOnAction(
+ 'settings-ca-trust-edit-dialog',
+ /** @type {!CertificateActionEventDetail} */ ({
+ action: settings.CertificateAction.IMPORT,
+ subnode: {name: 'Dummy Certificate Name', id: null},
+ certificateType: settings.CertificateType.CA
+ }));
});
});
}
« no previous file with comments | « chrome/browser/resources/settings/certificate_manager_page/certificates_error_dialog.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698