public void testKsViewLabel() {
   // URL:
   String url =
       "http://rhn.redhat.com/ks/cfg/org/"
           + user.getOrg().getId().toString()
           + "/view_label/"
           + ksdata.getLabel();
   request.setAttribute(RequestContext.REQUESTED_URI, url);
   Map<String, Object> options = helper.parseKickstartUrl(url);
   assertNotNull(options.get("ksdata"));
   //  This is the key test
   assertNull(options.get("session"));
 }
 public void testKsPathparse() {
   // URL:
   String url =
       "http://rhn.redhat.com/ks/cfg/org/"
           + user.getOrg().getId().toString()
           + "/label/"
           + ksdata.getLabel();
   request.setAttribute(RequestContext.REQUESTED_URI, url);
   Map<String, Object> options = helper.parseKickstartUrl(url);
   assertNotNull(options);
   assertNotNull(options.get("org_id"));
   assertNotNull(options.get("label"));
   assertNotNull(options.get("ksdata"));
   assertNotNull(options.get("host"));
 }
  public void testIpRangeLabel() throws Exception {

    KickstartIpRange range = new KickstartIpRange();
    range.setMaxString("127.0.0.2");
    range.setMinString("127.0.0.1");
    range.setKsdata(ksdata);
    range.setOrg(user.getOrg());
    ksdata.getIps().add(range);

    // URL:
    String url =
        "http://rhn.redhat.com/ks/cfg/org/" + user.getOrg().getId().toString() + "/mode/ip_range";
    request.setAttribute(RequestContext.REQUESTED_URI, url);
    helper = new KickstartHelper(request);
    Map<String, Object> options = helper.parseKickstartUrl(url);

    assertEquals(ksdata, options.get("ksdata"));
  }
  public void testKsSessionPathparse() throws Exception {
    user.addPermanentRole(RoleFactory.ORG_ADMIN);
    KickstartSession session = KickstartSessionTest.createKickstartSession(ksdata, user);
    KickstartFactory.saveKickstartSession(session);
    session = (KickstartSession) reload(session);
    assertNotSame(session.getState(), KickstartFactory.SESSION_STATE_CONFIG_ACCESSED);

    String encodedSession = SessionSwap.encodeData(session.getId().toString());
    // URL: /kickstart/ks/session/2xb7d56e8958b0425e762cc74e8705d8e7
    String url = "http://rhn.redhat.com/session/ks/session/" + encodedSession;
    request.setAttribute(RequestContext.REQUESTED_URI, url);
    Map<String, Object> options = helper.parseKickstartUrl(url);
    assertNotNull(options);
    assertNotNull(options.get("org_id"));
    assertNotNull(options.get("ksdata"));
    assertNotNull(options.get("session"));
    assertNotNull(options.get("host"));
    assertEquals(session.getState(), KickstartFactory.SESSION_STATE_CONFIG_ACCESSED);
  }
 public void testKsNoOrg() {
   String url = "http://somesat.redhat.com/ks/cfg/label/" + ksdata.getLabel();
   request.setAttribute(RequestContext.REQUESTED_URI, url);
   Map<String, Object> options = helper.parseKickstartUrl(url);
   assertNotNull(options);
 }