MCPcopy Index your code
hub / github.com/OWASP/SecurityShepherd / verifyTestUser

Method verifyTestUser

src/test/java/dbProcs/GetterTest.java:174–202  ·  view source on GitHub ↗

This method will sign in as a User, or create the user and sign in as them. If this fails it will throw an Exception @param applicationRoot Context of running application @param userName The user name of the user you want to create or sign in as @param password The password of the user you want to c

(String applicationRoot, String userName, String password)

Source from the content-addressed store, hash-verified

172 * @throws Exception If User Create function fails, an exception will be passed up
173 */
174 public static boolean verifyTestUser(String applicationRoot, String userName, String password) throws Exception
175 {
176 boolean result = false;
177 try
178 {
179 String user[] = Getter.authUser(applicationRoot, userName, userName);
180 if(user == null || user[0].isEmpty())
181 {
182 log.debug("Test Failed. User not found in DB. Adding user to DB and Retesting before reporting failure");
183 Setter.userCreate(applicationRoot, null, userName, userName, "player", userName+"@test.com", false);
184 user = Getter.authUser(applicationRoot, userName, userName);
185 }
186 if(user != null && !user[0].isEmpty())
187 {
188 log.debug(userName + " could authenticate. returning true");
189 result = true;
190 }
191 else
192 {
193 log.error("Couldnt verify that " + userName + " could authenticate at all. Throwing Exception");
194 throw new Exception("Could not Verify User " + userName + " could authenticate at all.");
195 }
196 }
197 catch(Exception e)
198 {
199 throw new Exception("Could not Create User " + userName + ": " + e.toString());
200 }
201 return result;
202 }
203
204 /**
205 * This method will sign in as a User, or create the user and sign in as them. If this fails it will throw an Exception.

Calls 4

authUserMethod · 0.95
userCreateMethod · 0.95
getClassInfoMethod · 0.95
updatePlayerClassMethod · 0.95

Tested by

no test coverage detected