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

Method testGetAdmins

src/test/java/dbProcs/GetterTest.java:3145–3197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3143 }
3144
3145 @Test
3146 public void testGetAdmins()
3147 {
3148 try
3149 {
3150 String userName = new String("adminsGetAll");
3151 for(int i = 0; i <= 9; i++)
3152 {
3153 if(verifyTestAdmin(applicationRoot, userName+i, userName+i))
3154 {
3155 log.debug("Created User " + userName+i);
3156 }
3157 else
3158 {
3159 fail("Could not create user " + userName+i);
3160 }
3161 }
3162 ResultSet admins = Getter.getAdmins(applicationRoot);
3163 try
3164 {
3165 int i = 0;
3166 while(admins.next())
3167 {
3168 if(admins.getString(2).startsWith(userName))
3169 {
3170 i++;
3171 }
3172 }
3173 if(i != 10)
3174 {
3175 if(i < 10)
3176 fail("Too Few Admins Returned");
3177 else if (i > 10)
3178 fail("Too Many Admins Returned");
3179 else
3180 {
3181 log.fatal("Then surely the number WAS 10? How did this happen");
3182 fail("Incorrect Amount of Admin User Returned");
3183 }
3184 }
3185 }
3186 catch(Exception e)
3187 {
3188 log.fatal("Failed to itterate through getAdmins: " + e.toString());
3189 fail("GetAdmins Result Set Issue");
3190 }
3191 }
3192 catch(Exception e)
3193 {
3194 log.fatal("Could not create Admin Users: " + e.toString());
3195 fail("Could not create Admin Users");
3196 }
3197 }
3198
3199
3200}

Callers

nothing calls this directly

Calls 2

verifyTestAdminMethod · 0.95
getAdminsMethod · 0.95

Tested by

no test coverage detected