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

Method logoutDoPost

src/test/java/servlets/LogoutTest.java:99–132  ·  view source on GitHub ↗
(String csrfToken)

Source from the content-addressed store, hash-verified

97 }
98
99 public void logoutDoPost(String csrfToken) throws Exception
100 {
101 try
102 {
103 int expectedResponseCode = 302;
104
105 log.debug("Creating Logout Servlet Instance");
106 Logout servlet = new Logout();
107 servlet.init(new MockServletConfig("Logout"));
108
109 //Setup Servlet Parameters and Attributes
110 log.debug("Setting Up Params and Atrributes");
111 request.addParameter("csrfToken", csrfToken);
112 try
113 {
114 log.debug("Running doGet");
115 servlet.doGet(request, response);
116 }
117 catch(IllegalStateException e)
118 {
119 log.debug("Logout Function Always throws: " + e.toString());
120 }
121 if(response.getStatus() != expectedResponseCode)
122 fail("Logout Servlet Returned " + response.getStatus() + " Code. 302 Expected");
123 else
124 {
125 log.debug("302 OK Detected");
126 }
127 }
128 catch(Exception e)
129 {
130 throw e;
131 }
132 }
133
134 /**
135 * This test logs the user in and then calls the logout function

Callers 2

testLogoutMethod · 0.95
testLogoutBadCsrfMethod · 0.95

Calls 2

doGetMethod · 0.95
initMethod · 0.80

Tested by

no test coverage detected