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

Side by Side Diff: chrome/test/data/webui/settings/certificate_manager_page_test.js

Issue 1867093003: MD Settings: Certificate manager, respect export/edit/delete restrictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit 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 unified diff | Download patch
OLDNEW
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 MockInteractions.tap(viewButton); 523 MockInteractions.tap(viewButton);
524 return browserProxy.whenCalled('viewCertificate').then(function(id) { 524 return browserProxy.whenCalled('viewCertificate').then(function(id) {
525 assertEquals(subentry.model.id, id); 525 assertEquals(subentry.model.id, id);
526 }); 526 });
527 }); 527 });
528 528
529 // Test that the 'Edit' option is only shown when appropriate and that 529 // Test that the 'Edit' option is only shown when appropriate and that
530 // once tapped the correct event is fired. 530 // once tapped the correct event is fired.
531 test('MenuOptions_Edit', function() { 531 test('MenuOptions_Edit', function() {
532 var editButton = subentry.shadowRoot.querySelector('#edit'); 532 var editButton = subentry.shadowRoot.querySelector('#edit');
533 assertTrue(!!editButton);
533 // Should be disabled for any certificate type other than 534 // Should be disabled for any certificate type other than
534 // CertificateType.CA 535 // CertificateType.CA
535 assertTrue(editButton.hidden); 536 assertTrue(editButton.hidden);
536 subentry.certificateType = settings.CertificateType.CA; 537 subentry.certificateType = settings.CertificateType.CA;
537 assertFalse(editButton.hidden); 538 assertFalse(editButton.hidden);
538 539
540 // Should be disabled if |policy| is true.
541 var model = createSampleCertificateSubnode();
542 model.policy = true;
543 subentry.model = model;
544 assertTrue(editButton.hidden);
545
546 subentry.model = createSampleCertificateSubnode();
539 var waitForActionEvent = actionEventToPromise(); 547 var waitForActionEvent = actionEventToPromise();
540 MockInteractions.tap(editButton); 548 MockInteractions.tap(editButton);
541 return waitForActionEvent.then(function(event) { 549 return waitForActionEvent.then(function(event) {
542 var detail = /** @type {!CertificateActionEventDetail} */ ( 550 var detail = /** @type {!CertificateActionEventDetail} */ (
543 event.detail); 551 event.detail);
544 assertEquals(settings.CertificateAction.EDIT, detail.action); 552 assertEquals(settings.CertificateAction.EDIT, detail.action);
545 assertEquals(subentry.model.id, detail.subnode.id); 553 assertEquals(subentry.model.id, detail.subnode.id);
546 assertEquals(subentry.certificateType, detail.certificateType); 554 assertEquals(subentry.certificateType, detail.certificateType);
547 }); 555 });
548 }); 556 });
549 557
550 // Test that the 'Delete' option is only shown when appropriate and that 558 // Test that the 'Delete' option is only shown when appropriate and that
551 // once tapped the correct event is fired. 559 // once tapped the correct event is fired.
552 test('MenuOptions_Delete', function() { 560 test('MenuOptions_Delete', function() {
553 subentry.set('model.readonly', true); 561 var deleteButton = subentry.shadowRoot.querySelector('#delete');
562 assertTrue(!!deleteButton);
554 563
555 var deleteButton = subentry.shadowRoot.querySelector('#delete');
556 // Should be disabled when 'model.readonly' is true. 564 // Should be disabled when 'model.readonly' is true.
565 var model = createSampleCertificateSubnode();
566 model.readonly = true;
567 subentry.model = model;
557 assertTrue(deleteButton.hidden); 568 assertTrue(deleteButton.hidden);
558 subentry.set('model.readonly', false);
559 assertFalse(deleteButton.hidden);
560 569
570 // Should be disabled when 'model.policy' is true.
571 var model = createSampleCertificateSubnode();
572 model.policy = true;
573 subentry.model = model;
574 assertTrue(deleteButton.hidden);
575
576 subentry.model = createSampleCertificateSubnode();
561 var waitForActionEvent = actionEventToPromise(); 577 var waitForActionEvent = actionEventToPromise();
562 MockInteractions.tap(deleteButton); 578 MockInteractions.tap(deleteButton);
563 return waitForActionEvent.then(function(event) { 579 return waitForActionEvent.then(function(event) {
564 var detail = /** @type {!CertificateActionEventDetail} */ ( 580 var detail = /** @type {!CertificateActionEventDetail} */ (
565 event.detail); 581 event.detail);
566 assertEquals(settings.CertificateAction.DELETE, detail.action); 582 assertEquals(settings.CertificateAction.DELETE, detail.action);
567 assertEquals(subentry.model.id, detail.subnode.id); 583 assertEquals(subentry.model.id, detail.subnode.id);
568 }); 584 });
569 }); 585 });
570 586
571 // Test case of exporting a certificate that is not PERSONAL. 587 // Test that the 'Export' option is always shown when the certificate type
588 // is not PERSONAL and that once tapped the correct event is fired.
572 test('MenuOptions_Export', function() { 589 test('MenuOptions_Export', function() {
573 subentry.certificateType = settings.CertificateType.SERVER; 590 subentry.certificateType = settings.CertificateType.SERVER;
574 var exportButton = subentry.shadowRoot.querySelector('#export'); 591 var exportButton = subentry.shadowRoot.querySelector('#export');
592 assertTrue(!!exportButton);
tommycli 2016/04/07 21:35:01 This assertion should be that it's not hidden righ
dpapad 2016/04/07 22:07:23 Done (added both).
575 MockInteractions.tap(exportButton); 593 MockInteractions.tap(exportButton);
576 return browserProxy.whenCalled('exportCertificate').then(function(id) { 594 return browserProxy.whenCalled('exportCertificate').then(function(id) {
577 assertEquals(subentry.model.id, id); 595 assertEquals(subentry.model.id, id);
578 }); 596 });
579 }); 597 });
580 598
581 // Test case of exporting a PERSONAL certificate. 599 // Test case of exporting a PERSONAL certificate.
582 test('MenuOptions_ExportPersonal', function() { 600 test('MenuOptions_ExportPersonal', function() {
601 var exportButton = subentry.shadowRoot.querySelector('#export');
602 assertTrue(!!exportButton);
603
604 // Should be disabled when 'model.extractable' is false.
605 assertTrue(exportButton.hidden);
606
607 var model = createSampleCertificateSubnode();
608 model.extractable = true;
609 subentry.model = model;
610 assertFalse(exportButton.hidden);
611
583 var waitForActionEvent = actionEventToPromise(); 612 var waitForActionEvent = actionEventToPromise();
584
585 var exportButton = subentry.shadowRoot.querySelector('#export');
586 MockInteractions.tap(exportButton); 613 MockInteractions.tap(exportButton);
587 return browserProxy.whenCalled('exportPersonalCertificate').then( 614 return browserProxy.whenCalled('exportPersonalCertificate').then(
588 function(id) { 615 function(id) {
589 assertEquals(subentry.model.id, id); 616 assertEquals(subentry.model.id, id);
590 617
591 // A promise firing once |settings.CertificateActionEvent| is 618 // A promise firing once |settings.CertificateActionEvent| is
592 // fired. 619 // fired.
593 return waitForActionEvent; 620 return waitForActionEvent;
594 }).then( 621 }).then(
595 function(event) { 622 function(event) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 registerCaTrustEditDialogTests(); 847 registerCaTrustEditDialogTests();
821 registerDeleteDialogTests(); 848 registerDeleteDialogTests();
822 registerPasswordEncryptDialogTests(); 849 registerPasswordEncryptDialogTests();
823 registerPasswordDecryptDialogTests(); 850 registerPasswordDecryptDialogTests();
824 registerPageTests(); 851 registerPageTests();
825 registerCertificateSubentryTests(); 852 registerCertificateSubentryTests();
826 registerCertificateListTests(); 853 registerCertificateListTests();
827 }, 854 },
828 }; 855 };
829 }); 856 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698