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

Unified Diff: content/network/url_loader_unittest.cc

Issue 2817033002: Plumb the net::SSLInfo to the browser process when it's using the network service. (Closed)
Patch Set: add net::SSLInfo test Created 3 years, 8 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: content/network/url_loader_unittest.cc
diff --git a/content/network/url_loader_unittest.cc b/content/network/url_loader_unittest.cc
index 8744b129ff2eea58f7e01bbb35f44a19c8d623cd..41de148209a6574ec4e061491d313c43554a7ba5 100644
--- a/content/network/url_loader_unittest.cc
+++ b/content/network/url_loader_unittest.cc
@@ -69,18 +69,24 @@ class URLLoaderImplTest : public testing::Test {
ASSERT_TRUE(test_server_.Start());
}
- void LoadAndCompareFile(const std::string& path) {
- TestURLLoaderClient client;
+ void Load(const GURL& url,
+ TestURLLoaderClient* client,
+ uint32_t options = 0) {
mojom::URLLoaderAssociatedPtr loader;
ResourceRequest request =
- CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME,
- test_server()->GetURL(std::string("/") + path));
+ CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url);
URLLoaderImpl loader_impl(context(), mojo::MakeIsolatedRequest(&loader),
- request, client.CreateInterfacePtr());
+ options, request, client->CreateInterfacePtr());
- client.RunUntilComplete();
+ client->RunUntilComplete();
+ }
+
+ void LoadAndCompareFile(const std::string& path) {
+ TestURLLoaderClient client;
+ GURL url = test_server()->GetURL(std::string("/") + path);
+ Load(url, &client);
base::FilePath file;
PathService::Get(content::DIR_TEST_DATA, &file);
@@ -110,4 +116,32 @@ TEST_F(URLLoaderImplTest, Basic) {
LoadAndCompareFile("simple_page.html");
}
+TEST_F(URLLoaderImplTest, BasicSSL) {
+ net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
+ https_server.ServeFilesFromSourceDirectory(
+ base::FilePath(FILE_PATH_LITERAL("content/test/data")));
+ ASSERT_TRUE(https_server.Start());
+
+ TestURLLoaderClient client;
+ GURL url = https_server.GetURL("/simple_page.html");
+ Load(url, &client, mojom::kURLLoadOptionSendSSLInfo);
+ ASSERT_TRUE(!!client.ssl_info());
+ ASSERT_TRUE(!!client.ssl_info()->cert);
+
+ ASSERT_TRUE(
+ https_server.GetCertificate()->Equals(client.ssl_info()->cert.get()));
+}
+
+TEST_F(URLLoaderImplTest, SSLSentOnlyWhenRequested) {
+ net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
+ https_server.ServeFilesFromSourceDirectory(
+ base::FilePath(FILE_PATH_LITERAL("content/test/data")));
+ ASSERT_TRUE(https_server.Start());
+
+ TestURLLoaderClient client;
+ GURL url = https_server.GetURL("/simple_page.html");
+ Load(url, &client, 0);
+ ASSERT_FALSE(!!client.ssl_info());
+}
+
} // namespace content
« no previous file with comments | « content/network/url_loader_impl.cc ('k') | content/renderer/service_worker/service_worker_context_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698