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

Unified Diff: chrome/browser/extensions/background_xhr_apitest.cc

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: fix 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/extensions/background_xhr_apitest.cc
diff --git a/chrome/browser/extensions/background_xhr_apitest.cc b/chrome/browser/extensions/background_xhr_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c59e0dd97c329ee0926ee4a2f66d5973499611d7
--- /dev/null
+++ b/chrome/browser/extensions/background_xhr_apitest.cc
@@ -0,0 +1,63 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_io_data.h"
+#include "chrome/browser/ui/browser.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/ssl/client_cert_store.h"
+#include "net/test/spawned_test_server/spawned_test_server.h"
+
+namespace {
+
+scoped_ptr<net::ClientCertStore> CreateNullCertStore() {
+ return nullptr;
+}
+
+void InstallNullCertStoreFactoryOnIOThread(
+ content::ResourceContext* resource_context) {
+ ProfileIOData::FromResourceContext(resource_context)
+ ->set_client_cert_store_factory_for_testing(
+ base::Bind(&CreateNullCertStore));
+}
+
+} // namespace
+
+// Test that fetching a URL using TLS client auth doesn't crash, hang, or
+// prompt.
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BackgroundXhrTlsClientAuth) {
asargent_no_longer_on_chrome 2015/03/03 00:10:30 Usually ExtensionApiTest tests are for testing ext
davidben 2015/03/05 20:01:52 Done.
+ // Install a null ClientCertStore so the client auth prompt isn't bypassed due
+ // to the system certificate store returning no certificates.
+ base::RunLoop loop;
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstallNullCertStoreFactoryOnIOThread,
+ browser()->profile()->GetResourceContext()),
+ loop.QuitClosure());
+ loop.Run();
+
+ // Launch HTTPS server.
+ net::SpawnedTestServer::SSLOptions ssl_options;
+ ssl_options.request_client_certificate = true;
+ net::SpawnedTestServer https_server(
+ net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
+ base::FilePath(FILE_PATH_LITERAL("content/test/data")));
+ ASSERT_TRUE(https_server.Start());
+
+ std::string url = https_server.GetURL("").spec();
+ ASSERT_TRUE(RunExtensionSubtestWithArg(
+ "background_xhr", "test_tls_client_auth.html", url.c_str()))
+ << message_;
+}
+
+// Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt.
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BackgroundXhrHttpAuth) {
+ ASSERT_TRUE(StartSpawnedTestServer());
+ ASSERT_TRUE(RunExtensionSubtest("background_xhr", "test_http_auth.html"))
+ << message_;
+}

Powered by Google App Engine
This is Rietveld 408576698