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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 10703189: Add end to end client cert auth test for wss (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add cacert.pem Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 return base::Bind(&MessageLoopRunner::Quit, this); 871 return base::Bind(&MessageLoopRunner::Quit, this);
872 } 872 }
873 873
874 void MessageLoopRunner::Quit() { 874 void MessageLoopRunner::Quit() {
875 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run(); 875 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run();
876 } 876 }
877 877
878 TestWebSocketServer::TestWebSocketServer() 878 TestWebSocketServer::TestWebSocketServer()
879 : started_(false), 879 : started_(false),
880 port_(kDefaultWsPort), 880 port_(kDefaultWsPort),
881 secure_(false) { 881 secure_(false),
882 client_authentication_(false) {
882 #if defined(OS_POSIX) 883 #if defined(OS_POSIX)
883 process_group_id_ = base::kNullProcessHandle; 884 process_group_id_ = base::kNullProcessHandle;
884 #endif 885 #endif
885 } 886 }
886 887
887 int TestWebSocketServer::UseRandomPort() { 888 int TestWebSocketServer::UseRandomPort() {
888 port_ = base::RandInt(1024, 65535); 889 port_ = base::RandInt(1024, 65535);
889 return port_; 890 return port_;
890 } 891 }
891 892
892 void TestWebSocketServer::UseTLS() { 893 void TestWebSocketServer::UseTLS() {
893 secure_ = true; 894 secure_ = true;
894 } 895 }
895 896
897 void TestWebSocketServer::UseClientAuthentication() {
898 client_authentication_ = true;
899 }
900
896 bool TestWebSocketServer::Start(const FilePath& root_directory) { 901 bool TestWebSocketServer::Start(const FilePath& root_directory) {
897 if (started_) 902 if (started_)
898 return true; 903 return true;
899 // Append CommandLine arguments after the server script, switches won't work. 904 // Append CommandLine arguments after the server script, switches won't work.
900 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 905 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
901 cmd_line->AppendArg("--server=start"); 906 cmd_line->AppendArg("--server=start");
902 cmd_line->AppendArg("--chromium"); 907 cmd_line->AppendArg("--chromium");
903 cmd_line->AppendArg("--register_cygwin"); 908 cmd_line->AppendArg("--register_cygwin");
904 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + 909 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") +
905 root_directory.value()); 910 root_directory.value());
906 cmd_line->AppendArg("--port=" + base::IntToString(port_)); 911 cmd_line->AppendArg("--port=" + base::IntToString(port_));
907 if (secure_) 912 if (secure_)
908 cmd_line->AppendArg("--tls"); 913 cmd_line->AppendArg("--tls");
909 if (!temp_dir_.CreateUniqueTempDir()) { 914 if (!temp_dir_.CreateUniqueTempDir()) {
910 LOG(ERROR) << "Unable to create a temporary directory."; 915 LOG(ERROR) << "Unable to create a temporary directory.";
911 return false; 916 return false;
912 } 917 }
918 if (client_authentication_) {
919 FilePath cacert_path(root_directory);
920 cmd_line->AppendArg("--ca-certificate");
921 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("ssl"));
922 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("cacert.pem"));
923 cmd_line->AppendArgNative(cacert_path.value());
924 }
913 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") + 925 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") +
914 temp_dir_.path().value()); 926 temp_dir_.path().value());
915 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); 927 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid");
916 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + 928 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") +
917 websocket_pid_file_.value()); 929 websocket_pid_file_.value());
918 SetPythonPath(); 930 SetPythonPath();
919 931
920 base::LaunchOptions options; 932 base::LaunchOptions options;
921 base::ProcessHandle process_handle; 933 base::ProcessHandle process_handle;
922 934
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 int state, 1302 int state,
1291 const base::Closure& followup) { 1303 const base::Closure& followup) {
1292 if (!followup.is_null()) 1304 if (!followup.is_null())
1293 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); 1305 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup);
1294 else 1306 else
1295 ui_controls::SendMouseEvents(button, state); 1307 ui_controls::SendMouseEvents(button, state);
1296 } 1308 }
1297 1309
1298 } // namespace internal 1310 } // namespace internal
1299 } // namespace ui_test_utils 1311 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698