MCPcopy Create free account
hub / github.com/OWASP/SecurityShepherd / loginDoPost

Method loginDoPost

src/test/java/servlets/LogoutTest.java:61–97  ·  view source on GitHub ↗

Method to simulate login servlet interaction. Can't seem to recyle the method in LoginTest with the MockRequests @param userName User to Sign in @param password User Password to use to Sign in @param theClass Class of the User @throws Exception If the process fails, an exception will be thrown

(String userName, String password, String theClass)

Source from the content-addressed store, hash-verified

59 * @throws Exception If the process fails, an exception will be thrown
60 */
61 public void loginDoPost(String userName, String password, String theClass) throws Exception
62 {
63 try
64 {
65 int expectedResponseCode = 302;
66
67 log.debug("Creating Login Servlet Instance");
68 Login servlet = new Login();
69 servlet.init(new MockServletConfig("Login"));
70
71 //Setup Servlet Parameters and Attributes
72 log.debug("Setting Up Params and Atrributes");
73 request.addParameter("login", userName);
74 request.addParameter("pwd", password);
75 request.getSession().setAttribute("lang", lang);
76
77 log.debug("Running doPost");
78 servlet.doPost(request, response);
79
80 if(response.getStatus() != expectedResponseCode)
81 fail("Login Servlet Returned " + response.getStatus() + " Code. 302 Expected");
82 else
83 {
84 log.debug("302 OK Detected");
85 String location = response.getHeader("Location");
86 log.debug("302 pointing at: " + location);
87 if(!location.endsWith("index.jsp"))
88 {
89 throw new Exception("Login not Redirecting to index.jsp. Login Proceedure Failed");
90 }
91 }
92 }
93 catch(Exception e)
94 {
95 throw e;
96 }
97 }
98
99 public void logoutDoPost(String csrfToken) throws Exception
100 {

Callers 2

testLogoutMethod · 0.95
testLogoutBadCsrfMethod · 0.95

Calls 3

doPostMethod · 0.95
initMethod · 0.80
getSessionMethod · 0.80

Tested by

no test coverage detected