()
| 594 | } |
| 595 | |
| 596 | @Test |
| 597 | public void testSuspendUser() |
| 598 | { |
| 599 | String userName = new String("suspendedUser"); |
| 600 | try |
| 601 | { |
| 602 | log.debug("Checking User Name in DB"); |
| 603 | boolean loggedIn = false; |
| 604 | try |
| 605 | { |
| 606 | log.debug("Trying to Verify User"); |
| 607 | loggedIn = GetterTest.verifyTestUser(applicationRoot, userName, userName); |
| 608 | } |
| 609 | catch(Exception e) |
| 610 | { |
| 611 | log.debug("Could not verify. May be suspended. Unsuspending"); |
| 612 | //Might need to unsuspend player |
| 613 | Setter.unSuspendUser(applicationRoot, Getter.getUserIdFromName(applicationRoot, userName)); |
| 614 | //Gotta Sleep for a sec otherwise the time setting for suspension will fail test. Must be 1 sec after unsuspend function ran |
| 615 | Thread.sleep(1000); |
| 616 | loggedIn = GetterTest.verifyTestUser(applicationRoot, userName, userName); |
| 617 | } |
| 618 | if(!loggedIn) |
| 619 | { |
| 620 | fail("Could not Verify User"); |
| 621 | } |
| 622 | else |
| 623 | { |
| 624 | String userId = Getter.getUserIdFromName(applicationRoot, userName); |
| 625 | if(!Setter.suspendUser(applicationRoot, userId, 10)) |
| 626 | { |
| 627 | fail("Could not suspend User"); |
| 628 | } |
| 629 | else |
| 630 | { |
| 631 | String user[] = Getter.authUser(applicationRoot, userName, userName); |
| 632 | if(user == null || user[0].isEmpty()) |
| 633 | { |
| 634 | return;// PASS: User Could not Authenticate after suspension |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | fail("Could still authenticate as user after suspension"); |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | catch(Exception e) |
| 644 | { |
| 645 | log.fatal("Could not complete testSuspendUser: " + e.toString()); |
| 646 | fail("Could not complete testSuspendUser"); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | @Test |
| 651 | public void testUnSuspendUser() |
nothing calls this directly
no test coverage detected