Commit 19347a2d authored by gman@chromium.org's avatar gman@chromium.org

Revert 128266 - Added a pepper test for SSLHandshake. This starts an SSL...

Revert 128266 - Added a pepper test for SSLHandshake. This starts an SSL server which the test can connect to.

BUG=114626
TEST=Ran pepper TCP tests.


Review URL: http://codereview.chromium.org/9791003

TBR=raymes@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9836015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128268 0039d316-1c4b-4281-b951-d872f2087c98
parent 641bdeb0
...@@ -160,33 +160,61 @@ void PPAPITestBase::RunTestAndReload(const std::string& test_case) { ...@@ -160,33 +160,61 @@ void PPAPITestBase::RunTestAndReload(const std::string& test_case) {
} }
void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) {
FilePath document_root; // For HTTP tests, we use the output DIR to grab the generated files such
ASSERT_TRUE(GetHTTPDocumentRoot(&document_root)); // as the NEXEs.
RunHTTPTestServer(document_root, test_case, ""); FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
} FilePath src_dir;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &src_dir));
// TestServer expects a path relative to source. So we must first
// generate absolute paths to SRC and EXE and from there generate
// a relative path.
if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
ASSERT_TRUE(exe_dir.IsAbsolute());
ASSERT_TRUE(src_dir.IsAbsolute());
void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { size_t match, exe_size, src_size;
FilePath document_root; std::vector<FilePath::StringType> src_parts, exe_parts;
ASSERT_TRUE(GetHTTPDocumentRoot(&document_root));
net::TestServer test_server(net::BaseTestServer::HTTPSOptions(), // Determine point at which src and exe diverge, and create a relative path.
document_root); exe_dir.GetComponents(&exe_parts);
src_dir.GetComponents(&src_parts);
exe_size = exe_parts.size();
src_size = src_parts.size();
for (match = 0; match < exe_size && match < src_size; ++match) {
if (exe_parts[match] != src_parts[match])
break;
}
FilePath web_dir;
for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
web_dir = web_dir.Append(FILE_PATH_LITERAL(".."));
}
for (; match < exe_size; ++match) {
web_dir = web_dir.Append(exe_parts[match]);
}
net::TestServer test_server(net::TestServer::TYPE_HTTP,
net::TestServer::kLocalhost,
web_dir);
ASSERT_TRUE(test_server.Start()); ASSERT_TRUE(test_server.Start());
uint16_t port = test_server.host_port_pair().port(); std::string query = BuildQuery("files/test_case.html?", test_case);
RunHTTPTestServer(document_root, test_case,
StringPrintf("ssl_server_port=%d", port)); GURL url = test_server.GetURL(query);
RunTestURL(url);
} }
void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
FilePath websocket_root_dir; FilePath websocket_root_dir;
ASSERT_TRUE( ASSERT_TRUE(
PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_root_dir)); PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_root_dir));
ui_test_utils::TestWebSocketServer server; ui_test_utils::TestWebSocketServer server;
int port = server.UseRandomPort(); int port = server.UseRandomPort();
ASSERT_TRUE(server.Start(websocket_root_dir)); ASSERT_TRUE(server.Start(websocket_root_dir));
FilePath http_document_root; std::string url = StringPrintf("%s&websocket_port=%d",
ASSERT_TRUE(GetHTTPDocumentRoot(&http_document_root)); test_case.c_str(), port);
RunHTTPTestServer(http_document_root, test_case, RunTestViaHTTP(url);
StringPrintf("websocket_port=%d", port));
} }
std::string PPAPITestBase::StripPrefixes(const std::string& test_name) { std::string PPAPITestBase::StripPrefixes(const std::string& test_name) {
...@@ -214,61 +242,6 @@ void PPAPITestBase::RunTestURL(const GURL& test_url) { ...@@ -214,61 +242,6 @@ void PPAPITestBase::RunTestURL(const GURL& test_url) {
EXPECT_STREQ("PASS", observer.result().c_str()); EXPECT_STREQ("PASS", observer.result().c_str());
} }
void PPAPITestBase::RunHTTPTestServer(
const FilePath& document_root,
const std::string& test_case,
const std::string& extra_params) {
net::TestServer test_server(net::TestServer::TYPE_HTTP,
net::TestServer::kLocalhost,
document_root);
ASSERT_TRUE(test_server.Start());
std::string query = BuildQuery("files/test_case.html?", test_case);
if (!extra_params.empty())
query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str());
GURL url = test_server.GetURL(query);
RunTestURL(url);
}
bool PPAPITestBase::GetHTTPDocumentRoot(FilePath* document_root) {
// For HTTP tests, we use the output DIR to grab the generated files such
// as the NEXEs.
FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
FilePath src_dir;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
return false;
// TestServer expects a path relative to source. So we must first
// generate absolute paths to SRC and EXE and from there generate
// a relative path.
if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
if (!exe_dir.IsAbsolute())
return false;
if (!src_dir.IsAbsolute())
return false;
size_t match, exe_size, src_size;
std::vector<FilePath::StringType> src_parts, exe_parts;
// Determine point at which src and exe diverge, and create a relative path.
exe_dir.GetComponents(&exe_parts);
src_dir.GetComponents(&src_parts);
exe_size = exe_parts.size();
src_size = src_parts.size();
for (match = 0; match < exe_size && match < src_size; ++match) {
if (exe_parts[match] != src_parts[match])
break;
}
for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
*document_root = document_root->Append(FILE_PATH_LITERAL(".."));
}
for (; match < exe_size; ++match) {
*document_root = document_root->Append(exe_parts[match]);
}
return true;
}
PPAPITest::PPAPITest() { PPAPITest::PPAPITest() {
} }
...@@ -374,16 +347,6 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery( ...@@ -374,16 +347,6 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
} }
// Similar macros that test with an SSL server.
#define TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
}
#define TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(test_name) \
IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, test_name) { \
RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
}
// Similar macros that test with WebSocket server // Similar macros that test with WebSocket server
#define TEST_PPAPI_IN_PROCESS_WITH_WS(test_name) \ #define TEST_PPAPI_IN_PROCESS_WITH_WS(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \ IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \
...@@ -413,12 +376,6 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery( ...@@ -413,12 +376,6 @@ std::string PPAPINaClTestDisallowedSockets::BuildQuery(
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \ RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
} }
// NaCl based PPAPI tests with SSL server
#define TEST_PPAPI_NACL_VIA_HTTP_WITH_SSL_SERVER(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
RunTestWithSSLServer(STRIP_PREFIXES(test_name)); \
}
// NaCl based PPAPI tests with WebSocket server // NaCl based PPAPI tests with WebSocket server
#define TEST_PPAPI_NACL_VIA_HTTP_WITH_WS(test_name) \ #define TEST_PPAPI_NACL_VIA_HTTP_WITH_WS(test_name) \
IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \ IN_PROC_BROWSER_TEST_F(PPAPINaClTest, test_name) { \
...@@ -503,9 +460,9 @@ TEST_PPAPI_OUT_OF_PROCESS(BrowserFont) ...@@ -503,9 +460,9 @@ TEST_PPAPI_OUT_OF_PROCESS(BrowserFont)
TEST_PPAPI_IN_PROCESS(Buffer) TEST_PPAPI_IN_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS(Buffer) TEST_PPAPI_OUT_OF_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate) TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(TCPSocketPrivate)
TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate) TEST_PPAPI_IN_PROCESS_VIA_HTTP(TCPSocketPrivate)
TEST_PPAPI_NACL_VIA_HTTP_WITH_SSL_SERVER(TCPSocketPrivate) TEST_PPAPI_NACL_VIA_HTTP(TCPSocketPrivate)
TEST_PPAPI_IN_PROCESS_VIA_HTTP(UDPSocketPrivate) TEST_PPAPI_IN_PROCESS_VIA_HTTP(UDPSocketPrivate)
TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(UDPSocketPrivate) TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(UDPSocketPrivate)
......
...@@ -26,7 +26,6 @@ class PPAPITestBase : public InProcessBrowserTest { ...@@ -26,7 +26,6 @@ class PPAPITestBase : public InProcessBrowserTest {
// instance object vars. // instance object vars.
void RunTestAndReload(const std::string& test_case); void RunTestAndReload(const std::string& test_case);
void RunTestViaHTTP(const std::string& test_case); void RunTestViaHTTP(const std::string& test_case);
void RunTestWithSSLServer(const std::string& test_case);
void RunTestWithWebSocketServer(const std::string& test_case); void RunTestWithWebSocketServer(const std::string& test_case);
std::string StripPrefixes(const std::string& test_name); std::string StripPrefixes(const std::string& test_name);
...@@ -34,15 +33,6 @@ class PPAPITestBase : public InProcessBrowserTest { ...@@ -34,15 +33,6 @@ class PPAPITestBase : public InProcessBrowserTest {
// Runs the test for a tab given the tab that's already navigated to the // Runs the test for a tab given the tab that's already navigated to the
// given URL. // given URL.
void RunTestURL(const GURL& test_url); void RunTestURL(const GURL& test_url);
// Run the given |test_case| on a HTTP test server whose document root is
// specified by |document_root|. |extra_params| will be passed as URL
// parameters to the test.
void RunHTTPTestServer(const FilePath& document_root,
const std::string& test_case,
const std::string& extra_params);
// Return the document root for the HTTP server on which tests will be run.
// The result is placed in |document_root|. False is returned upon failure.
bool GetHTTPDocumentRoot(FilePath* document_root);
}; };
// In-process plugin test runner. See OutOfProcessPPAPITest below for the // In-process plugin test runner. See OutOfProcessPPAPITest below for the
......
...@@ -34,14 +34,11 @@ function AppendFrame(testcase, i) { ...@@ -34,14 +34,11 @@ function AppendFrame(testcase, i) {
var frame = document.createElement("IFRAME"); var frame = document.createElement("IFRAME");
var mode = ExtractSearchParameter("mode"); var mode = ExtractSearchParameter("mode");
var websocket_port = ExtractSearchParameter("websocket_port"); var websocket_port = ExtractSearchParameter("websocket_port");
var ssl_server_port = ExtractSearchParameter("ssl_server_port");
var src = "?testcase=" + testcase; var src = "?testcase=" + testcase;
if (mode == "nacl") if (mode == "nacl")
src += "&mode=nacl"; src += "&mode=nacl";
if (websocket_port != "") if (websocket_port != "")
src += "&websocket_port=" + websocket_port; src += "&websocket_port=" + websocket_port;
if (ssl_server_port != "")
src += "&ssl_server_port=" + ssl_server_port;
frame.setAttribute("src", src); frame.setAttribute("src", src);
frame.setAttribute("onload", "LoadNext(" + (i + 1) + ")"); frame.setAttribute("onload", "LoadNext(" + (i + 1) + ")");
...@@ -225,10 +222,6 @@ onload = function() { ...@@ -225,10 +222,6 @@ onload = function() {
var websocket_port = ExtractSearchParameter("websocket_port"); var websocket_port = ExtractSearchParameter("websocket_port");
if (websocket_port != "") if (websocket_port != "")
obj.setAttribute("websocket_port", websocket_port); obj.setAttribute("websocket_port", websocket_port);
var ssl_server_port = ExtractSearchParameter("ssl_server_port");
if (ssl_server_port != "")
obj.setAttribute("ssl_server_port", ssl_server_port);
var container = document.getElementById("container"); var container = document.getElementById("container");
container.addEventListener("message", handleTestingMessage, true); container.addEventListener("message", handleTestingMessage, true);
// Register a bad dispatchEvent to make sure it isn't used. See 'EVIL' note // Register a bad dispatchEvent to make sure it isn't used. See 'EVIL' note
......
...@@ -40,16 +40,12 @@ bool TestTCPSocketPrivate::Init() { ...@@ -40,16 +40,12 @@ bool TestTCPSocketPrivate::Init() {
if (!GetLocalHostPort(instance_->pp_instance(), &host_, &port_)) if (!GetLocalHostPort(instance_->pp_instance(), &host_, &port_))
return false; return false;
// Get the port for the SSL server.
ssl_port_ = instance_->ssl_server_port();
return true; return true;
} }
void TestTCPSocketPrivate::RunTests(const std::string& filter) { void TestTCPSocketPrivate::RunTests(const std::string& filter) {
RUN_TEST_FORCEASYNC_AND_NOT(Basic, filter); RUN_TEST_FORCEASYNC_AND_NOT(Basic, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ReadWrite, filter); RUN_TEST_FORCEASYNC_AND_NOT(ReadWrite, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ReadWriteSSL, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ConnectAddress, filter); RUN_TEST_FORCEASYNC_AND_NOT(ConnectAddress, filter);
} }
...@@ -95,34 +91,6 @@ std::string TestTCPSocketPrivate::TestReadWrite() { ...@@ -95,34 +91,6 @@ std::string TestTCPSocketPrivate::TestReadWrite() {
PASS(); PASS();
} }
std::string TestTCPSocketPrivate::TestReadWriteSSL() {
pp::TCPSocketPrivate socket(instance_);
TestCompletionCallback cb(instance_->pp_instance(), force_async_);
int32_t rv = socket.Connect(host_.c_str(), ssl_port_, cb);
ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING);
if (rv == PP_OK_COMPLETIONPENDING)
rv = cb.WaitForResult();
ASSERT_EQ(PP_OK, rv);
rv = socket.SSLHandshake(host_.c_str(), ssl_port_, cb);
ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING);
if (rv == PP_OK_COMPLETIONPENDING)
rv = cb.WaitForResult();
ASSERT_EQ(PP_OK, rv);
ASSERT_EQ(PP_OK, WriteStringToSocket(&socket, "GET / HTTP/1.0\r\n\r\n"));
// Read up to the first \n and check that it looks like valid HTTP response.
std::string s;
ASSERT_EQ(PP_OK, ReadFirstLineFromSocket(&socket, &s));
ASSERT_TRUE(ValidateHttpResponse(s));
socket.Disconnect();
PASS();
}
std::string TestTCPSocketPrivate::TestConnectAddress() { std::string TestTCPSocketPrivate::TestConnectAddress() {
PP_NetAddress_Private address; PP_NetAddress_Private address;
...@@ -160,6 +128,8 @@ std::string TestTCPSocketPrivate::TestConnectAddress() { ...@@ -160,6 +128,8 @@ std::string TestTCPSocketPrivate::TestConnectAddress() {
PASS(); PASS();
} }
// TODO(viettrungluu): Try testing SSL somehow.
int32_t TestTCPSocketPrivate::ReadFirstLineFromSocket( int32_t TestTCPSocketPrivate::ReadFirstLineFromSocket(
pp::TCPSocketPrivate* socket, pp::TCPSocketPrivate* socket,
std::string* s) { std::string* s) {
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -25,7 +25,6 @@ class TestTCPSocketPrivate : public TestCase { ...@@ -25,7 +25,6 @@ class TestTCPSocketPrivate : public TestCase {
private: private:
std::string TestBasic(); std::string TestBasic();
std::string TestReadWrite(); std::string TestReadWrite();
std::string TestReadWriteSSL();
std::string TestConnectAddress(); std::string TestConnectAddress();
int32_t ReadFirstLineFromSocket(pp::TCPSocketPrivate* socket, std::string* s); int32_t ReadFirstLineFromSocket(pp::TCPSocketPrivate* socket, std::string* s);
...@@ -34,7 +33,6 @@ class TestTCPSocketPrivate : public TestCase { ...@@ -34,7 +33,6 @@ class TestTCPSocketPrivate : public TestCase {
std::string host_; std::string host_;
uint16_t port_; uint16_t port_;
uint16_t ssl_port_;
}; };
#endif // PAPPI_TESTS_TEST_TCP_SOCKET_PRIVATE_H_ #endif // PAPPI_TESTS_TEST_TCP_SOCKET_PRIVATE_H_
...@@ -31,7 +31,6 @@ TestingInstance::TestingInstance(PP_Instance instance) ...@@ -31,7 +31,6 @@ TestingInstance::TestingInstance(PP_Instance instance)
current_case_(NULL), current_case_(NULL),
executed_tests_(false), executed_tests_(false),
nacl_mode_(false), nacl_mode_(false),
ssl_server_port_(-1),
websocket_port_(-1) { websocket_port_(-1) {
callback_factory_.Initialize(this); callback_factory_.Initialize(this);
} }
...@@ -52,8 +51,6 @@ bool TestingInstance::Init(uint32_t argc, ...@@ -52,8 +51,6 @@ bool TestingInstance::Init(uint32_t argc,
protocol_ = argv[i]; protocol_ = argv[i];
} else if (std::strcmp(argn[i], "websocket_port") == 0) { } else if (std::strcmp(argn[i], "websocket_port") == 0) {
websocket_port_ = atoi(argv[i]); websocket_port_ = atoi(argv[i]);
} else if (std::strcmp(argn[i], "ssl_server_port") == 0) {
ssl_server_port_ = atoi(argv[i]);
} }
} }
// Create the proper test case from the argument. // Create the proper test case from the argument.
......
...@@ -82,8 +82,6 @@ pp::InstancePrivate { ...@@ -82,8 +82,6 @@ pp::InstancePrivate {
return protocol_; return protocol_;
} }
int ssl_server_port() { return ssl_server_port_; }
int websocket_port() { return websocket_port_; } int websocket_port() { return websocket_port_; }
// Posts a message to the test page to eval() the script. // Posts a message to the test page to eval() the script.
...@@ -151,9 +149,6 @@ pp::InstancePrivate { ...@@ -151,9 +149,6 @@ pp::InstancePrivate {
// with http. // with http.
std::string protocol_; std::string protocol_;
// SSL server port.
int ssl_server_port_;
// WebSocket port. // WebSocket port.
int websocket_port_; int websocket_port_;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment