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

Unified Diff: chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: worker_common.js was missing a license header (also a rebase) Created 5 years, 9 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
Index: chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm
index a0c71106e6692e7941e9f90ba3cd50fc2e7e4115..26842361f3746e8e902040222eca8907162c3ecf 100644
--- a/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm
+++ b/chrome/browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm
@@ -8,12 +8,14 @@
#include "base/bind.h"
#import "base/mac/mac_util.h"
+#include "base/macros.h"
#include "chrome/browser/ssl/ssl_client_certificate_selector.h"
#include "chrome/browser/ssl/ssl_client_certificate_selector_test.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "content/public/browser/client_certificate_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
#include "ui/base/cocoa/window_size_constants.h"
@@ -22,12 +24,33 @@ using web_modal::WebContentsModalDialogManager;
namespace {
-void OnCertificateSelected(net::X509Certificate** out_cert,
- int* out_count,
- net::X509Certificate* cert) {
- *out_cert = cert;
- ++(*out_count);
-}
+class TestClientCertificateDelegate
+ : public content::ClientCertificateDelegate {
+ public:
+ // Creates a ClientCertificateDelegate that sets |*destroyed| to true on
+ // destruction.
+ explicit TestClientCertificateDelegate(bool* destroyed)
+ : destroyed_(destroyed) {}
+
+ ~TestClientCertificateDelegate() override {
+ if (destroyed_ != nullptr)
+ *destroyed_ = true;
+ }
+
+ // content::ClientCertificateDelegate.
+ void ContinueWithCertificate(net::X509Certificate* cert) override {
+ // TODO(davidben): Add a test which explicitly tests selecting a
+ // certificate, or selecting no certificate, since closing the dialog
+ // (normally by closing the tab) is not the same as explicitly selecting no
+ // certificate.
+ ADD_FAILURE() << "Certificate selected";
+ }
+
+ private:
+ bool* destroyed_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate);
+};
} // namespace
@@ -46,15 +69,13 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, DISABLED_Basic) {
WebContentsModalDialogManager::FromWebContents(web_contents);
EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
- net::X509Certificate* cert = NULL;
- int count = 0;
- SSLClientCertificateSelectorCocoa* selector =
- [[SSLClientCertificateSelectorCocoa alloc]
- initWithBrowserContext:web_contents->GetBrowserContext()
- certRequestInfo:auth_requestor_->cert_request_info_.get()
- callback:base::Bind(&OnCertificateSelected,
- &cert,
- &count)];
+ bool destroyed = false;
+ SSLClientCertificateSelectorCocoa* selector = [
+ [SSLClientCertificateSelectorCocoa alloc]
+ initWithBrowserContext:web_contents->GetBrowserContext()
+ certRequestInfo:auth_requestor_->cert_request_info_.get()
+ delegate:make_scoped_ptr(new TestClientCertificateDelegate(
+ &destroyed))];
[selector displayForWebContents:web_contents];
content::RunAllPendingInMessageLoop();
EXPECT_TRUE([selector panel]);
@@ -66,19 +87,19 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, DISABLED_Basic) {
content::RunAllPendingInMessageLoop();
EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
- EXPECT_EQ(NULL, cert);
- EXPECT_EQ(1, count);
+ EXPECT_TRUE(destroyed);
}
// Test that switching to another tab correctly hides the sheet.
IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
- SSLClientCertificateSelectorCocoa* selector =
- [[SSLClientCertificateSelectorCocoa alloc]
- initWithBrowserContext:web_contents->GetBrowserContext()
- certRequestInfo:auth_requestor_->cert_request_info_.get()
- callback:chrome::SelectCertificateCallback()];
+ SSLClientCertificateSelectorCocoa* selector = [
+ [SSLClientCertificateSelectorCocoa alloc]
+ initWithBrowserContext:web_contents->GetBrowserContext()
+ certRequestInfo:auth_requestor_->cert_request_info_.get()
+ delegate:make_scoped_ptr(
+ new TestClientCertificateDelegate(nullptr))];
[selector displayForWebContents:web_contents];
content::RunAllPendingInMessageLoop();

Powered by Google App Engine
This is Rietveld 408576698