Example #1
0
  public void testUnselectAll() throws Exception {
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.setupClampListBounds();
    ActionForward forward = sah.executeAction("unselectall");

    verifyRhnSetData(sah.getUser().getId(), action.getSetDecl().getLabel(), 0);
    verifyParam(forward.getPath(), "setupdated", "true");
  }
Example #2
0
  public void testFilter() throws Exception {
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.getRequest().setupAddParameter(RequestContext.FILTER_STRING, "zzzz");
    sah.setupClampListBounds();

    ActionForward forward = sah.executeAction("filter");
    verifyParam(forward.getPath(), RequestContext.FILTER_STRING, "zzzz");
  }
 private ActionHelper createActionHelper(String forwardName) throws Exception {
   ActionHelper result = new ActionHelper();
   result.setUpAction(action, forwardName);
   result.getForm().setFormName("probeEditForm");
   result.getRequest().setupAddParameter(ProbeDetailsAction.PROBEID, probe.getId().toString());
   String id = probeSuite.getId().toString();
   result.getRequest().setupAddParameter(RequestContext.SUITE_ID, id);
   result.getRequest().setupAddParameter(RequestContext.SUITE_ID, id);
   return result;
 }
Example #4
0
 public void testSelectAllBadDataType() throws Exception {
   ActionHelper sah = new ActionHelper();
   TestActionWithData a = new TestActionWithData();
   sah.setUpAction(a);
   sah.setupClampListBounds();
   // We check to make sure we throw
   // exception if the list has invalid types in it.
   boolean failed = false;
   try {
     sah.executeAction("selectall");
   } catch (Exception iea) {
     failed = true;
   }
   assertTrue(failed);
 }
Example #5
0
 public void testSelectAll() throws Exception {
   ActionHelper sah = new ActionHelper();
   TestActionWithData a =
       new TestActionWithData() {
         protected DataResult getDataResult(
             User user, ActionForm formIn, HttpServletRequest request) {
           List retval = new LinkedList();
           for (int i = 0; i < 10; i++) {
             retval.add(new TestIdObject(new Long(i)));
           }
           return new DataResult(retval);
         }
       };
   sah.setUpAction(a);
   sah.setupClampListBounds();
   ActionForward forward = sah.executeAction("selectall");
   verifyRhnSetData(sah.getUser().getId(), a.getSetDecl().getLabel(), 10);
   verifyParam(forward.getPath(), "setupdated", "true");
 }
  public void testSubmitExecute() throws Exception {

    ActionHelper ah = createActionHelper("success");
    ah.getForm().set(ProbeEditAction.SUBMITTED, new Boolean(true));
    ah.getForm().set("description", probe.getDescription());
    ah.getForm().set("notification", new Boolean(true));
    Long intv = new Long(probe.getCheckIntervalMinutes().longValue());
    ah.getForm().set("check_interval_min", intv);
    ah.getForm().set("notification_interval_min", probe.getNotificationIntervalMinutes());

    MonitoringTestUtils.setupParamValues(ah, probe.getCommand(), 3);

    ActionForward af = ah.executeAction();
    assertEquals("success", af.getName());

    Probe edited = (Probe) reload(probe);
    assertTrue(edited.isNotifyCritical().booleanValue());
    MonitoringTestUtils.verifyParameters(edited, probe.getCommand());
    assertEquals(intv, edited.getCheckIntervalMinutes());
  }
Example #7
0
  public void testUpdateListPipe() throws Exception {
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.setupClampListBounds();
    sah.getRequest().setRequestURL("foo");
    sah.getRequest()
        .setupAddParameter("items_selected", new String[] {"777|999", "99|555", "666|77656"});
    sah.getRequest().setupAddParameter("newset", (String) null);
    sah.getRequest().setupAddParameter("items_on_page", (String) null);
    sah.executeAction("updatelist");

    // let's go find the data
    verifyRhnSetData(sah.getUser().getId(), action.getSetDecl().getLabel(), 3);
  }
Example #8
0
  public void testUnspecified() throws Exception {
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.setupClampListBounds();
    sah.getRequest().setupAddParameter("items_selected", new String[] {"10", "20", "30"});
    sah.getRequest().setupAddParameter("newset", (String) null);
    sah.getRequest().setupAddParameter("items_on_page", (String) null);
    ActionForward forward = sah.executeAction("unspecified");

    verifyParam(forward.getPath(), "newset", "[10, 20, 30]");
  }
Example #9
0
  public void testUpdateList() throws Exception {
    // TestAction action = new TestAction();
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.setupClampListBounds();
    sah.getRequest().setRequestURL("foo");
    sah.getRequest().setupAddParameter("items_selected", new String[] {"10", "20", "30"});
    sah.getRequest().setupAddParameter("newset", (String) null);
    sah.getRequest().setupAddParameter("items_on_page", (String) null);
    ActionForward forward = sah.executeAction("updatelist");

    // let's go find the data
    verifyRhnSetData(sah.getUser().getId(), action.getSetDecl().getLabel(), 3);
    verifyParam(forward.getPath(), "setupdated", "true");
  }
  public void testExecute() throws Exception {

    ActionHelper ah = createActionHelper(RhnHelper.DEFAULT_FORWARD);
    ActionForward af = ah.executeAction();
    assertEquals(RhnHelper.DEFAULT_FORWARD, af.getName());
    assertNotNull(ah.getRequest().getAttribute("probe"));
    assertNotNull(ah.getRequest().getAttribute("probeSuite"));
    assertNotNull(ah.getRequest().getAttribute("intervals"));
    assertNotNull(ah.getRequest().getAttribute("contactGroups"));
    assertNotNull(ah.getRequest().getAttribute("paramValueList"));
    List pvalues = (List) ah.getRequest().getAttribute("paramValueList");
    assertTrue(pvalues.size() > 0);
  }
  public void testNoParamExecute() throws Exception {
    UserEditSetupAction action = new UserEditSetupAction();
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.getRequest().setRequestURL("rdu.redhat.com/rhn/users/UserDetails.do");
    setupExpectations(sah.getForm(), sah.getUser());

    sah.getRequest().setupAddParameter("uid", (String) null);
    sah.getRequest().getParameterValues("uid"); // now uid = null

    try {
      sah.executeAction();
      fail(); // should never get this far
    } catch (BadParameterException e) {
      // no op
    }
  }
  public void testSelectAll() throws Exception {
    BaseSystemListAction action = createAction();
    ActionHelper ah = new ActionHelper();
    ah.setUpAction(action);
    ah.setupProcessPagination();

    User user = ah.getUser();
    user.addPermanentRole(RoleFactory.ORG_ADMIN);
    UserManager.storeUser(user);
    ah.getRequest().setupAddParameter("items_on_page", (String[]) null);
    ah.getRequest().setupAddParameter("items_selected", (String[]) null);
    ah.executeAction("selectall");
    // This test only ensures that 'Select All' doesn't blow up.
    // To really test that something got selected, we would have to create an
    // appropriate system for each of the subclasses. The fact that the set cleaner
    // doesn't clean servers that should stay in the set is already tested by
    // testAddOne()
  }
  public void testAddOne() throws Exception {
    BaseSystemListAction action = createAction();
    ActionHelper ah = new ActionHelper();
    ah.setUpAction(action);
    ah.setupProcessPagination();

    User user = ah.getUser();
    user.addPermanentRole(RoleFactory.ORG_ADMIN);
    // Create a server that can be put in the set. Note that the
    // server is not set up entirely right for subclasses, which would
    // only display servers with certain attributes, e.g. a satellite.
    // But this test is only concerned with keeping a server in the set
    // w/o having it cleaned up by the set cleaner
    Server server =
        ServerFactoryTest.createTestServer(
            user, true, ServerConstants.getServerGroupTypeEnterpriseEntitled());
    UserManager.storeUser(user);
    String sid = server.getId().toString();
    ah.getRequest().setupAddParameter("items_on_page", (String[]) null);
    ah.getRequest().setupAddParameter("items_selected", new String[] {sid});
    ah.executeAction("updatelist");

    RhnSetActionTest.verifyRhnSetData(ah.getUser(), RhnSetDecl.SYSTEMS, 1);
  }
  public void testPerformExecute() throws Exception {
    UserEditSetupAction action = new UserEditSetupAction();
    ActionHelper sah = new ActionHelper();
    sah.setUpAction(action);
    sah.getRequest().setRequestURL("foo");

    User user = sah.getUser();
    user.setTitle("Test title");
    // Lets add some roles
    Iterator it = UserFactory.IMPLIEDROLES.iterator();
    user.addPermanentRole(RoleFactory.ORG_ADMIN);
    while (it.hasNext()) {
      Role cr = (Role) it.next();
      user.getOrg().addRole(cr);
      user.addPermanentRole(cr);
    }

    setupExpectations(sah.getForm(), sah.getUser());

    // Below we test to make sure that some of
    // the strings in the form are localized
    TestUtils.enableLocalizationDebugMode();
    try {
      sah.executeAction();

      // verify the dyna form got the right values we expected.
      sah.getForm().verify();

      assertEquals(sah.getUser().getLastLoggedIn(), sah.getRequest().getAttribute("lastLoggedIn"));
      // Verify some more intensive stuff
      assertNotNull(sah.getRequest().getAttribute("adminRoles"));
      assertNotNull(sah.getRequest().getAttribute("regularRoles"));
      List<UserRoleStatusBean> regularRoles =
          (List<UserRoleStatusBean>) sah.getRequest().getAttribute("regularRoles");
      assertEquals(5, regularRoles.size());
      UserRoleStatusBean lv = regularRoles.get(0);
      assertTrue(TestUtils.isLocalized(lv.getName()));
      assertEquals(true, lv.isDisabled());
      assertNotNull(sah.getRequest().getAttribute("disabledRoles"));
      assertTrue(sah.getRequest().getAttribute("user") instanceof User);

      // If we have pam setup where we're testing, make sure displaypam was set
      String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE);
      if (pamAuthService != null && pamAuthService.trim().length() > 0) {
        assertNotNull(sah.getRequest().getAttribute("displaypam"));
      }
    } finally {
      TestUtils.disableLocalizationDebugMode();
    }
  }