提交 228afdaf authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix TestWeb

上级 b02f0a5a
...@@ -436,7 +436,7 @@ Supported settings are: ...@@ -436,7 +436,7 @@ Supported settings are:
<ul><li><code>webAllowOthers</code>: allow other computers to connect. <ul><li><code>webAllowOthers</code>: allow other computers to connect.
</li><li><code>webPort</code>: the port of the H2 Console </li><li><code>webPort</code>: the port of the H2 Console
</li><li><code>webSSL</code>: use encrypted TLS (HTTPS) connections. </li><li><code>webSSL</code>: use encrypted TLS (HTTPS) connections.
</li><li><code>adminPassword</code>: password to access preferences and tools of H2 Console. </li><li><code>webAdminPassword</code>: password to access preferences and tools of H2 Console.
</li></ul> </li></ul>
<p> <p>
In addition to those settings, the properties of the last recently used connection In addition to those settings, the properties of the last recently used connection
......
...@@ -36,6 +36,6 @@ org.h2.tools.RunScript.main=Options are case sensitive. Supported options are\:\ ...@@ -36,6 +36,6 @@ org.h2.tools.RunScript.main=Options are case sensitive. Supported options are\:\
org.h2.tools.Script=Creates a SQL script file by extracting the schema and data of a database. org.h2.tools.Script=Creates a SQL script file by extracting the schema and data of a database.
org.h2.tools.Script.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The target script file name (default\: backup.sql)\n[-options ...] A list of options (only for embedded H2, see SCRIPT)\n[-quiet] Do not print progress information org.h2.tools.Script.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The target script file name (default\: backup.sql)\n[-options ...] A list of options (only for embedded H2, see SCRIPT)\n[-quiet] Do not print progress information
org.h2.tools.Server=Starts the H2 Console (web-) server, TCP, and PG server. org.h2.tools.Server=Starts the H2 Console (web-) server, TCP, and PG server.
org.h2.tools.Server.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-webAllowOthers] Allow other computers to connect - see below\n[-webDaemon] Use a daemon thread\n[-webPort <port>] The port (default\: 8082)\n[-webSSL] Use encrypted (HTTPS) connections\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-tcpAllowOthers] Allow other computers to connect - see below\n[-tcpDaemon] Use a daemon thread\n[-tcpPort <port>] The port (default\: 9092)\n[-tcpSSL] Use encrypted (SSL) connections\n[-tcpPassword <pwd>] The password for shutting down a TCP server\n[-tcpShutdown "<url>"] Stop the TCP server; example\: tcp\://localhost\n[-tcpShutdownForce] Do not wait until all connections are closed\n[-pg] Start the PG server\n[-pgAllowOthers] Allow other computers to connect - see below\n[-pgDaemon] Use a daemon thread\n[-pgPort <port>] The port (default\: 5435)\n[-properties "<dir>"] Server properties (default\: ~, disable\: null)\n[-baseDir <dir>] The base directory for H2 databases (all servers)\n[-ifExists] Only existing databases may be opened (all servers)\n[-ifNotExists] Databases are created when accessed\n[-trace] Print additional trace information (all servers)\n[-key <from> <to>] Allows to map a database name to another (all servers)\nThe options -xAllowOthers are potentially risky.\nFor details, see Advanced Topics / Protection against Remote Access. org.h2.tools.Server.main=When running without options, -tcp, -web, -browser and -pg are started.\nOptions are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-web] Start the web server with the H2 Console\n[-webAllowOthers] Allow other computers to connect - see below\n[-webDaemon] Use a daemon thread\n[-webPort <port>] The port (default\: 8082)\n[-webSSL] Use encrypted (HTTPS) connections\n[-webAdminPassword] Password of DB Console administrator\n[-browser] Start a browser connecting to the web server\n[-tcp] Start the TCP server\n[-tcpAllowOthers] Allow other computers to connect - see below\n[-tcpDaemon] Use a daemon thread\n[-tcpPort <port>] The port (default\: 9092)\n[-tcpSSL] Use encrypted (SSL) connections\n[-tcpPassword <pwd>] The password for shutting down a TCP server\n[-tcpShutdown "<url>"] Stop the TCP server; example\: tcp\://localhost\n[-tcpShutdownForce] Do not wait until all connections are closed\n[-pg] Start the PG server\n[-pgAllowOthers] Allow other computers to connect - see below\n[-pgDaemon] Use a daemon thread\n[-pgPort <port>] The port (default\: 5435)\n[-properties "<dir>"] Server properties (default\: ~, disable\: null)\n[-baseDir <dir>] The base directory for H2 databases (all servers)\n[-ifExists] Only existing databases may be opened (all servers)\n[-ifNotExists] Databases are created when accessed\n[-trace] Print additional trace information (all servers)\n[-key <from> <to>] Allows to map a database name to another (all servers)\nThe options -xAllowOthers are potentially risky.\nFor details, see Advanced Topics / Protection against Remote Access.
org.h2.tools.Shell=Interactive command line tool to access a database using JDBC. org.h2.tools.Shell=Interactive command line tool to access a database using JDBC.
org.h2.tools.Shell.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:h2\:...)\n[-user <user>] The user name\n[-password <pwd>] The password\n[-driver <class>] The JDBC driver class to use (not required in most cases)\n[-sql "<statements>"] Execute the SQL statements and exit\n[-properties "<dir>"] Load the server properties from this directory\nIf special characters don't work as expected, you may need to use\n -Dfile.encoding\=UTF-8 (Mac OS X) or CP850 (Windows). org.h2.tools.Shell.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url "<url>"] The database URL (jdbc\:h2\:...)\n[-user <user>] The user name\n[-password <pwd>] The password\n[-driver <class>] The JDBC driver class to use (not required in most cases)\n[-sql "<statements>"] Execute the SQL statements and exit\n[-properties "<dir>"] Load the server properties from this directory\nIf special characters don't work as expected, you may need to use\n -Dfile.encoding\=UTF-8 (Mac OS X) or CP850 (Windows).
...@@ -408,7 +408,7 @@ public class WebApp { ...@@ -408,7 +408,7 @@ public class WebApp {
server.setSSL(ssl); server.setSSL(ssl);
byte[] adminPassword = server.getAdminPassword(); byte[] adminPassword = server.getAdminPassword();
if (adminPassword != null) { if (adminPassword != null) {
prop.setProperty("adminPassword", StringUtils.convertBytesToHex(adminPassword)); prop.setProperty("webAdminPassword", StringUtils.convertBytesToHex(adminPassword));
} }
server.saveProperties(prop); server.saveProperties(prop);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -281,7 +281,7 @@ public class WebServer implements Service { ...@@ -281,7 +281,7 @@ public class WebServer implements Service {
"webSSL", false); "webSSL", false);
allowOthers = SortedProperties.getBooleanProperty(prop, allowOthers = SortedProperties.getBooleanProperty(prop,
"webAllowOthers", false); "webAllowOthers", false);
setAdminPassword(SortedProperties.getStringProperty(prop, "adminPassword", null)); setAdminPassword(SortedProperties.getStringProperty(prop, "webAdminPassword", null));
commandHistoryString = prop.getProperty(COMMAND_HISTORY); commandHistoryString = prop.getProperty(COMMAND_HISTORY);
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
String a = args[i]; String a = args[i];
...@@ -300,7 +300,7 @@ public class WebServer implements Service { ...@@ -300,7 +300,7 @@ public class WebServer implements Service {
ifExists = true; ifExists = true;
} else if (Tool.isOption(a, "-ifNotExists")) { } else if (Tool.isOption(a, "-ifNotExists")) {
ifExists = false; ifExists = false;
} else if (Tool.isOption(a, "-adminPassword")) { } else if (Tool.isOption(a, "-webAdminPassword")) {
setAdminPassword(args[++i]); setAdminPassword(args[++i]);
} else if (Tool.isOption(a, "-properties")) { } else if (Tool.isOption(a, "-properties")) {
// already set // already set
...@@ -686,7 +686,7 @@ public class WebServer implements Service { ...@@ -686,7 +686,7 @@ public class WebServer implements Service {
prop.setProperty("webSSL", prop.setProperty("webSSL",
Boolean.toString(SortedProperties.getBooleanProperty(old, "webSSL", ssl))); Boolean.toString(SortedProperties.getBooleanProperty(old, "webSSL", ssl)));
if (adminPassword != null) { if (adminPassword != null) {
prop.setProperty("adminPassword", StringUtils.convertBytesToHex(adminPassword)); prop.setProperty("webAdminPassword", StringUtils.convertBytesToHex(adminPassword));
} }
if (commandHistoryString != null) { if (commandHistoryString != null) {
prop.setProperty(COMMAND_HISTORY, commandHistoryString); prop.setProperty(COMMAND_HISTORY, commandHistoryString);
......
...@@ -72,7 +72,7 @@ public class Console extends Tool implements ShutdownHandler { ...@@ -72,7 +72,7 @@ public class Console extends Tool implements ShutdownHandler {
/** /**
* This tool starts the H2 Console (web-) server, as well as the TCP and PG * This tool starts the H2 Console (web-) server, as well as the TCP and PG
* server. For JDK 1.6, a system tray icon is created, for platforms that * server. A system tray icon is created, for platforms that
* support it. Otherwise, a small window opens. * support it. Otherwise, a small window opens.
* *
* @param args the command line arguments * @param args the command line arguments
......
...@@ -70,6 +70,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -70,6 +70,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* <td>The port (default: 8082)</td></tr> * <td>The port (default: 8082)</td></tr>
* <tr><td>[-webSSL]</td> * <tr><td>[-webSSL]</td>
* <td>Use encrypted (HTTPS) connections</td></tr> * <td>Use encrypted (HTTPS) connections</td></tr>
* <tr><td>[-webAdminPassword]</td>
* <td>Password of DB Console administrator</td></tr>
* <tr><td>[-browser]</td> * <tr><td>[-browser]</td>
* <td>Start a browser connecting to the web server</td></tr> * <td>Start a browser connecting to the web server</td></tr>
* <tr><td>[-tcp]</td> * <tr><td>[-tcp]</td>
...@@ -137,6 +139,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -137,6 +139,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
// no parameters // no parameters
} else if ("-webPort".equals(arg)) { } else if ("-webPort".equals(arg)) {
i++; i++;
} else if ("-webAdminPassword".equals(arg)) {
i += 2;
} else { } else {
throwUnsupportedOption(arg); throwUnsupportedOption(arg);
} }
...@@ -236,6 +240,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -236,6 +240,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
// no parameters // no parameters
} else if ("-webPort".equals(arg)) { } else if ("-webPort".equals(arg)) {
i++; i++;
} else if ("-webAdminPassword".equals(arg)) {
i += 2;
} else { } else {
showUsageAndThrowUnsupportedOption(arg); showUsageAndThrowUnsupportedOption(arg);
} }
......
...@@ -172,7 +172,7 @@ public class TestWeb extends TestDb { ...@@ -172,7 +172,7 @@ public class TestWeb extends TestDb {
Server server = new Server(); Server server = new Server();
server.setOut(new PrintStream(new ByteArrayOutputStream())); server.setOut(new PrintStream(new ByteArrayOutputStream()));
server.runTool("-web", "-webPort", "8182", server.runTool("-web", "-webPort", "8182",
"-properties", "null", "-tcp", "-tcpPort", "9101"); "-properties", "null", "-tcp", "-tcpPort", "9101", "-webAdminPassword", "123");
try { try {
String url = "http://localhost:8182"; String url = "http://localhost:8182";
WebClient client; WebClient client;
...@@ -180,6 +180,7 @@ public class TestWeb extends TestDb { ...@@ -180,6 +180,7 @@ public class TestWeb extends TestDb {
client = new WebClient(); client = new WebClient();
result = client.get(url); result = client.get(url);
client.readSessionId(result); client.readSessionId(result);
result = client.get(url, "adminLogin.do?password=123");
result = client.get(url, "tools.jsp"); result = client.get(url, "tools.jsp");
FileUtils.delete(getBaseDir() + "/backup.zip"); FileUtils.delete(getBaseDir() + "/backup.zip");
result = client.get(url, "tools.do?tool=Backup&args=-dir," + result = client.get(url, "tools.do?tool=Backup&args=-dir," +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论