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

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

Issue 10541168: Add end to end client cert auth test for wss (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reflects review comments 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
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/ssl/cacert.pem » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 return base::Bind(&MessageLoopRunner::Quit, this); 870 return base::Bind(&MessageLoopRunner::Quit, this);
871 } 871 }
872 872
873 void MessageLoopRunner::Quit() { 873 void MessageLoopRunner::Quit() {
874 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run(); 874 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run();
875 } 875 }
876 876
877 TestWebSocketServer::TestWebSocketServer() 877 TestWebSocketServer::TestWebSocketServer()
878 : started_(false), 878 : started_(false),
879 port_(kDefaultWsPort), 879 port_(kDefaultWsPort),
880 secure_(false) { 880 secure_(false),
881 client_authentication_(false) {
881 #if defined(OS_POSIX) 882 #if defined(OS_POSIX)
882 process_group_id_ = base::kNullProcessHandle; 883 process_group_id_ = base::kNullProcessHandle;
883 #endif 884 #endif
884 } 885 }
885 886
886 int TestWebSocketServer::UseRandomPort() { 887 int TestWebSocketServer::UseRandomPort() {
887 port_ = base::RandInt(1024, 65535); 888 port_ = base::RandInt(1024, 65535);
888 return port_; 889 return port_;
889 } 890 }
890 891
891 void TestWebSocketServer::UseTLS() { 892 void TestWebSocketServer::UseTLS() {
892 secure_ = true; 893 secure_ = true;
893 } 894 }
894 895
896 void TestWebSocketServer::UseClientAuthentication() {
897 client_authentication_ = true;
898 }
899
895 bool TestWebSocketServer::Start(const FilePath& root_directory) { 900 bool TestWebSocketServer::Start(const FilePath& root_directory) {
896 if (started_) 901 if (started_)
897 return true; 902 return true;
898 // Append CommandLine arguments after the server script, switches won't work. 903 // Append CommandLine arguments after the server script, switches won't work.
899 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 904 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
900 cmd_line->AppendArg("--server=start"); 905 cmd_line->AppendArg("--server=start");
901 cmd_line->AppendArg("--chromium"); 906 cmd_line->AppendArg("--chromium");
902 cmd_line->AppendArg("--register_cygwin"); 907 cmd_line->AppendArg("--register_cygwin");
903 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + 908 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") +
904 root_directory.value()); 909 root_directory.value());
905 cmd_line->AppendArg("--port=" + base::IntToString(port_)); 910 cmd_line->AppendArg("--port=" + base::IntToString(port_));
906 if (secure_) 911 if (secure_)
907 cmd_line->AppendArg("--tls"); 912 cmd_line->AppendArg("--tls");
908 if (!temp_dir_.CreateUniqueTempDir()) { 913 if (!temp_dir_.CreateUniqueTempDir()) {
909 LOG(ERROR) << "Unable to create a temporary directory."; 914 LOG(ERROR) << "Unable to create a temporary directory.";
910 return false; 915 return false;
911 } 916 }
917 if (client_authentication_) {
918 FilePath cacert_path(root_directory);
919 cmd_line->AppendArg("--ca-certificate");
920 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("ssl"));
921 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("cacert.pem"));
922 cmd_line->AppendArgNative(cacert_path.value());
923 }
912 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") + 924 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") +
913 temp_dir_.path().value()); 925 temp_dir_.path().value());
914 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); 926 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid");
915 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + 927 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") +
916 websocket_pid_file_.value()); 928 websocket_pid_file_.value());
917 SetPythonPath(); 929 SetPythonPath();
918 930
919 base::LaunchOptions options; 931 base::LaunchOptions options;
920 base::ProcessHandle process_handle; 932 base::ProcessHandle process_handle;
921 933
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 int state, 1301 int state,
1290 const base::Closure& followup) { 1302 const base::Closure& followup) {
1291 if (!followup.is_null()) 1303 if (!followup.is_null())
1292 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); 1304 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup);
1293 else 1305 else
1294 ui_controls::SendMouseEvents(button, state); 1306 ui_controls::SendMouseEvents(button, state);
1295 } 1307 }
1296 1308
1297 } // namespace internal 1309 } // namespace internal
1298 } // namespace ui_test_utils 1310 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/ssl/cacert.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698