OLD | NEW |
---|---|
(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_apitest.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 "content/public/browser/browser_thread.h" | |
13 #include "net/ssl/client_cert_store.h" | |
14 #include "net/test/spawned_test_server/spawned_test_server.h" | |
15 | |
16 namespace { | |
17 | |
18 scoped_ptr<net::ClientCertStore> CreateNullCertStore() { | |
19 return nullptr; | |
20 } | |
21 | |
22 void InstallNullCertStoreFactoryOnIOThread( | |
23 content::ResourceContext* resource_context) { | |
24 ProfileIOData::FromResourceContext(resource_context) | |
25 ->set_client_cert_store_factory_for_testing( | |
26 base::Bind(&CreateNullCertStore)); | |
27 } | |
28 | |
29 } // namespace | |
30 | |
31 // Test that fetching a URL using TLS client auth doesn't crash, hang, or | |
32 // prompt. | |
33 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.
| |
34 // Install a null ClientCertStore so the client auth prompt isn't bypassed due | |
35 // to the system certificate store returning no certificates. | |
36 base::RunLoop loop; | |
37 content::BrowserThread::PostTaskAndReply( | |
38 content::BrowserThread::IO, FROM_HERE, | |
39 base::Bind(&InstallNullCertStoreFactoryOnIOThread, | |
40 browser()->profile()->GetResourceContext()), | |
41 loop.QuitClosure()); | |
42 loop.Run(); | |
43 | |
44 // Launch HTTPS server. | |
45 net::SpawnedTestServer::SSLOptions ssl_options; | |
46 ssl_options.request_client_certificate = true; | |
47 net::SpawnedTestServer https_server( | |
48 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, | |
49 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | |
50 ASSERT_TRUE(https_server.Start()); | |
51 | |
52 std::string url = https_server.GetURL("").spec(); | |
53 ASSERT_TRUE(RunExtensionSubtestWithArg( | |
54 "background_xhr", "test_tls_client_auth.html", url.c_str())) | |
55 << message_; | |
56 } | |
57 | |
58 // Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt. | |
59 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BackgroundXhrHttpAuth) { | |
60 ASSERT_TRUE(StartSpawnedTestServer()); | |
61 ASSERT_TRUE(RunExtensionSubtest("background_xhr", "test_http_auth.html")) | |
62 << message_; | |
63 } | |
OLD | NEW |