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

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: extension test Created 5 years, 10 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..b6546252769240e3c00173896f1239c130757b35 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,34 @@ 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:
+ TestClientCertificateDelegate(net::X509Certificate** out_cert, int* out_count)
+ : out_cert_(out_cert), out_count_(out_count) {}
+
+ // 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";
+ }
+
+ void CancelCertificateSelection() override {
+ if (out_cert_)
+ *out_cert_ = nullptr;
+ if (out_count_)
+ ++(*out_count_);
+ }
+
+ private:
+ net::X509Certificate** out_cert_;
+ int* out_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate);
+};
} // namespace
@@ -52,9 +76,9 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, DISABLED_Basic) {
[[SSLClientCertificateSelectorCocoa alloc]
initWithBrowserContext:web_contents->GetBrowserContext()
certRequestInfo:auth_requestor_->cert_request_info_.get()
- callback:base::Bind(&OnCertificateSelected,
- &cert,
- &count)];
+ delegate:scoped_ptr<content::ClientCertificateDelegate>(
+ new TestClientCertificateDelegate(
+ &cert, &count))];
[selector displayForWebContents:web_contents];
content::RunAllPendingInMessageLoop();
EXPECT_TRUE([selector panel]);
@@ -78,7 +102,9 @@ IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorCocoaTest, HideShow) {
[[SSLClientCertificateSelectorCocoa alloc]
initWithBrowserContext:web_contents->GetBrowserContext()
certRequestInfo:auth_requestor_->cert_request_info_.get()
- callback:chrome::SelectCertificateCallback()];
+ delegate:scoped_ptr<content::ClientCertificateDelegate>(
+ new TestClientCertificateDelegate(
+ nullptr, nullptr))];
[selector displayForWebContents:web_contents];
content::RunAllPendingInMessageLoop();

Powered by Google App Engine
This is Rietveld 408576698