summaryrefslogtreecommitdiff
path: root/components/cronet/testing
diff options
context:
space:
mode:
Diffstat (limited to 'components/cronet/testing')
-rw-r--r--components/cronet/testing/test_server/data/server_error.txt.mock-http-headers2
-rw-r--r--components/cronet/testing/test_server/test_server.cc13
-rw-r--r--components/cronet/testing/test_server/test_server.h11
3 files changed, 20 insertions, 6 deletions
diff --git a/components/cronet/testing/test_server/data/server_error.txt.mock-http-headers b/components/cronet/testing/test_server/data/server_error.txt.mock-http-headers
index 472aa4b9b..23bb3abed 100644
--- a/components/cronet/testing/test_server/data/server_error.txt.mock-http-headers
+++ b/components/cronet/testing/test_server/data/server_error.txt.mock-http-headers
@@ -1 +1 @@
-HTTP/1.1 500 INTERNAL SERVER ERROR
+HTTP/1.1 500 INTERNAL SERVER ERROR \ No newline at end of file
diff --git a/components/cronet/testing/test_server/test_server.cc b/components/cronet/testing/test_server/test_server.cc
index 6fbe746eb..113b7955c 100644
--- a/components/cronet/testing/test_server/test_server.cc
+++ b/components/cronet/testing/test_server/test_server.cc
@@ -170,17 +170,19 @@ namespace cronet {
/* static */
bool TestServer::StartServeFilesFromDirectory(
- const base::FilePath& test_files_root) {
+ const base::FilePath& test_files_root,
+ net::EmbeddedTestServer::Type server_type,
+ net::EmbeddedTestServer::ServerCertificate server_certificate) {
// Shouldn't happen.
if (g_test_server)
return false;
- g_test_server = std::make_unique<net::EmbeddedTestServer>(
- net::EmbeddedTestServer::TYPE_HTTP);
+ g_test_server = std::make_unique<net::EmbeddedTestServer>(server_type);
g_test_server->RegisterRequestHandler(
base::BindRepeating(&CronetTestRequestHandler));
g_test_server->ServeFilesFromDirectory(test_files_root);
net::test_server::RegisterDefaultHandlers(g_test_server.get());
+ g_test_server->SetSSLConfig(server_certificate);
CHECK(g_test_server->Start());
return true;
}
@@ -189,7 +191,10 @@ bool TestServer::StartServeFilesFromDirectory(
bool TestServer::Start() {
base::FilePath src_root;
CHECK(base::PathService::Get(base::DIR_SRC_TEST_DATA_ROOT, &src_root));
- return StartServeFilesFromDirectory(src_root.Append(kTestDataRelativePath));
+ return StartServeFilesFromDirectory(
+ src_root.Append(kTestDataRelativePath),
+ net::test_server::EmbeddedTestServer::TYPE_HTTP,
+ net::test_server::EmbeddedTestServer::CERT_OK);
}
/* static */
diff --git a/components/cronet/testing/test_server/test_server.h b/components/cronet/testing/test_server/test_server.h
index 82a74acd6..cd4d3635b 100644
--- a/components/cronet/testing/test_server/test_server.h
+++ b/components/cronet/testing/test_server/test_server.h
@@ -7,6 +7,8 @@
#include <string>
+#include "net/test/embedded_test_server/embedded_test_server.h"
+
namespace base {
class FilePath;
} // namespace base
@@ -17,11 +19,18 @@ class TestServer {
public:
// Starts the server serving files from default test data directory.
// Returns true if started, false if server is already running.
+ // This will run the server in default mode (HTTP/1 with no SSL)
static bool Start();
+
// Starts the server serving files from |test_files_root| directory.
// Returns true if started, false if server is already running.
+ // The provided server will support either HTTP/1 or HTTPS/1 depending
+ // on the |type| provided.
static bool StartServeFilesFromDirectory(
- const base::FilePath& test_files_root);
+ const base::FilePath& test_files_root,
+ net::EmbeddedTestServer::Type type,
+ net::EmbeddedTestServer::ServerCertificate cert);
+
// Shuts down the server.
static void Shutdown();