Skip to content

Commit

Permalink
Change some test user data values
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamura committed Apr 23, 2017
1 parent 74aeaff commit 6abc9c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
28 changes: 17 additions & 11 deletions src/main/java/org/t246osslab/easybuggy/core/dao/DBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ private static void createUsersTable(Statement stmt) throws SQLException {
// create users table
stmt.executeUpdate("create table users (id varchar(10) primary key, name varchar(30), password varchar(30), secret varchar(100), ispublic varchar(5), phone varchar(20), mail varchar(100))");

// insert sample records
stmt.executeUpdate("insert into users values ('0','Mark','password','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('1','David','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('2','Peter','pa33word','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('3','James','pathwood','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('4','Benjamin','password','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('5','Eric','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('6','Sharon','pa33word','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('7','Pamela','pathwood','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('8','Jacqueline','password','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('9','Michelle','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
// insert private (invisible) user records
stmt.executeUpdate("insert into users values ('admin','admin','password','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('admin02','admin02','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('admin03','admin03','pa33word','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");
stmt.executeUpdate("insert into users values ('admin04','admin04','pathwood','" + RandomStringUtils.randomNumeric(10) + "','false', '', '')");

// insert public (test) user records
stmt.executeUpdate("insert into users values ('user00','Mark','pastword','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user01','David','pa32w0rd','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user02','Peter','pa23word','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user03','James','patwired','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user04','Benjamin','password','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user05','Eric','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user06','Sharon','pa3world','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user07','Pamela','pathwood','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user08','Jacqueline','password','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
stmt.executeUpdate("insert into users values ('user09','Michelle','pas2w0rd','" + RandomStringUtils.randomNumeric(10) + "','true', '', '')");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private String selectUsers(String name, String password, HttpServletRequest req)
try {
conn = DBClient.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM users WHERE name='" + name + "' AND password='" + password + "'");
rs = stmt.executeQuery("SELECT * FROM users WHERE ispublic = 'true' AND name='" + name + "' AND password='" + password + "'");
StringBuilder sb = new StringBuilder();
while (rs.next()) {
sb.append("<tr><td>" + rs.getString("name") + "</td><td>" + rs.getString("secret") + "</td></tr>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws Ser
bodyHtml.append(ESAPI.encoder().encodeForHTML("<users>") + "<br>");
bodyHtml.append(TAB);
bodyHtml.append(ESAPI.encoder().encodeForHTML(
"<user uid=\"11\" name=\"Tommy\" password=\"pasworld\" phone=\"090-1004-5678\" mail=\"[email protected]\"/>"));
"<user uid=\"user11\" name=\"Tommy\" password=\"pasworld\" phone=\"090-1004-5678\" mail=\"[email protected]\"/>"));
bodyHtml.append("<br>");
bodyHtml.append(TAB);
bodyHtml.append(ESAPI.encoder().encodeForHTML(
"<user uid=\"12\" name=\"Matt\" password=\"PaSsWoRd\" phone=\"090-9984-1118\" mail=\"[email protected]\"/>"));
"<user uid=\"user12\" name=\"Matt\" password=\"PaSsWoRd\" phone=\"090-9984-1118\" mail=\"[email protected]\"/>"));
bodyHtml.append("<br>");
bodyHtml.append(ESAPI.encoder().encodeForHTML("</users>"));
bodyHtml.append("</pre>");
Expand Down

0 comments on commit 6abc9c7

Please sign in to comment.