Persons None Online Sources None 80 COLUMNS WIDE public class AccessControlTest

Persons none online sources none 80 columns wide

This preview shows page 1 - 3 out of 3 pages.

// // Persons: None // Online Sources: None // /////////////////////////////// 80 COLUMNS WIDE /////////////////////////////// public class AccessControlTest { /** * Testing main. Runs each test and prints which (if any) failed. */ public static void main(String[] args) { int fails = 0; if (!testLogin1()) { // Tests an invalid user System.out.println("testLogin1 [bad username] failed"); fails++; } if (!testLogin2()) { // Tests with a valid user System.out.println("testLogin2 [good login] failed"); fails++; } if (!testLogin3()) { System.out.println("testLogin1 [bad username with default password] failed"); fails++; } if (!testAddUser1()) { // Tests to add user without admin access System.out.println("testAddUser1 [no admin access] failed"); fails++; } if (!testRemoveUser()) { System.out.println("testRemoveUser [actual user] failed"); fails++; } if (!testGiveAdmin()) { System.out.println("testGiveAdmin [actual user, current user is admin]
Image of page 1
failed"); fails++; } if (!testTakeAdmin()) { System.out.println("testRemoveUser [actual user, current user is not admin] failed"); fails++; } if (fails == 0) System.out.println("All tests passed!"); } /** * This test tries to log in a user that doesn't exist * @return boolean test passed */ public static boolean testLogin1() { AccessControl ac = new AccessControl(); String user = "probablyNotInTheSystem1234"; String pw = "password"; return !AccessControl.isValidLogin(user, pw); // isValidLogin should return false } /** * Test method for the isValidLogin method in the access control class. Tests with a valid
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 3 pages?

  • Fall '19
  • Login, public class

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture