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

Side by Side Diff: chrome/browser/extensions/background_xhr_browsertest.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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h"
8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_io_data.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "extensions/common/extension.h"
15 #include "extensions/test/result_catcher.h"
16 #include "net/base/escape.h"
17 #include "net/base/url_util.h"
18 #include "net/ssl/client_cert_store.h"
19 #include "net/test/spawned_test_server/spawned_test_server.h"
20 #include "url/gurl.h"
21
22 namespace {
23
24 scoped_ptr<net::ClientCertStore> CreateNullCertStore() {
25 return nullptr;
26 }
27
28 void InstallNullCertStoreFactoryOnIOThread(
29 content::ResourceContext* resource_context) {
30 ProfileIOData::FromResourceContext(resource_context)
31 ->set_client_cert_store_factory_for_testing(
32 base::Bind(&CreateNullCertStore));
33 }
34
35 } // namespace
36
37 class BackgroundXhrTest : public ExtensionBrowserTest {
38 protected:
39 void RunTest(const std::string& path, const GURL& url) {
40 const extensions::Extension* extension =
41 LoadExtension(test_data_dir_.AppendASCII("background_xhr"));
42 ASSERT_TRUE(extension);
43
44 extensions::ResultCatcher catcher;
45 GURL test_url = net::AppendQueryParameter(extension->GetResourceURL(path),
46 "url", url.spec());
47 ui_test_utils::NavigateToURL(browser(), test_url);
48 ASSERT_TRUE(catcher.GetNextResult());
49 }
50 };
51
52 // Test that fetching a URL using TLS client auth doesn't crash, hang, or
53 // prompt.
54 IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, TlsClientAuth) {
55 // Install a null ClientCertStore so the client auth prompt isn't bypassed due
56 // to the system certificate store returning no certificates.
57 base::RunLoop loop;
58 content::BrowserThread::PostTaskAndReply(
59 content::BrowserThread::IO, FROM_HERE,
60 base::Bind(&InstallNullCertStoreFactoryOnIOThread,
61 browser()->profile()->GetResourceContext()),
62 loop.QuitClosure());
63 loop.Run();
64
65 // Launch HTTPS server.
66 net::SpawnedTestServer::SSLOptions ssl_options;
67 ssl_options.request_client_certificate = true;
68 net::SpawnedTestServer https_server(
69 net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
70 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
71 ASSERT_TRUE(https_server.Start());
72
73 ASSERT_NO_FATAL_FAILURE(
74 RunTest("test_tls_client_auth.html", https_server.GetURL("")));
75 }
76
77 // Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt.
78 IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, HttpAuth) {
79 ASSERT_TRUE(test_server()->Start());
80 ASSERT_NO_FATAL_FAILURE(
81 RunTest("test_http_auth.html", test_server()->GetURL("auth-basic")));
82 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/ssl/ssl_client_auth_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698