This method will sign in as an admin, or create the admin and sign in as them. If this fails it will throw an Exception. This function will pass if correct user credentials are passed as well @param applicationRoot Context of running application @param userName The user name of the admin you want to
(String applicationRoot, String userName, String password)
| 134 | * @throws Exception If admin Create function fails, an exception will be passed up |
| 135 | */ |
| 136 | public static boolean verifyTestAdmin(String applicationRoot, String userName, String password) throws Exception |
| 137 | { |
| 138 | boolean result = false; |
| 139 | try |
| 140 | { |
| 141 | String user[] = Getter.authUser(applicationRoot, userName, userName); |
| 142 | if(user == null || user[0].isEmpty()) |
| 143 | { |
| 144 | log.debug("Test Failed. User not found in DB. Adding user to DB and Retesting before reporting failure"); |
| 145 | Setter.userCreate(applicationRoot, null, userName, userName, "admin", userName+"@test.com", false); |
| 146 | user = Getter.authUser(applicationRoot, userName, userName); |
| 147 | } |
| 148 | if(user != null && !user[0].isEmpty()) |
| 149 | { |
| 150 | log.debug(userName + " could authenticate. returning true"); |
| 151 | result = true; |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | log.error("Couldnt verify that " + userName + " could authenticate at all. Throwing Exception"); |
| 156 | throw new Exception("Could not Verify User " + userName + " could authenticate at all."); |
| 157 | } |
| 158 | } |
| 159 | catch(Exception e) |
| 160 | { |
| 161 | throw new Exception("Could not Create User " + userName + ": " + e.toString()); |
| 162 | } |
| 163 | return result; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * 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 |
no test coverage detected