public void testLookupBySession() throws Exception {
    // Still have that weird error creating a test server
    // sometimes in hosted.
    ActivationKey k = createTestActivationKey(user);
    KickstartData ksdata = KickstartDataTest.createKickstartWithOptions(k.getOrg());
    KickstartFactory.saveKickstartData(ksdata);
    KickstartSession sess = KickstartSessionTest.createKickstartSession(ksdata, k.getCreator());
    KickstartFactory.saveKickstartSession(sess);
    k.setKickstartSession(sess);
    ActivationKeyFactory.save(k);
    k = (ActivationKey) reload(k);

    ActivationKey lookedUp = ActivationKeyFactory.lookupByKickstartSession(sess);
    assertNotNull(lookedUp);
  }
Пример #2
0
  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);
  }