Search in sources :

Example 51 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class SessionIdServiceTest method testUpdateLastUsedDate.

@Parameters({ "userInum" })
@Test
public void testUpdateLastUsedDate(String userInum) {
    SessionId m_sessionId = generateSession(userInum);
    final SessionId fromLdap1 = m_service.getSessionId(m_sessionId.getId());
    final Date createdDate = m_sessionId.getLastUsedAt();
    System.out.println("Created date = " + createdDate);
    Assert.assertEquals(createdDate, fromLdap1.getLastUsedAt());
    sleepSeconds(1);
    m_service.updateSessionId(m_sessionId);
    final SessionId fromLdap2 = m_service.getSessionId(m_sessionId.getId());
    System.out.println("Updated date = " + fromLdap2.getLastUsedAt());
    Assert.assertTrue(createdDate.before(fromLdap2.getLastUsedAt()));
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId) Date(java.util.Date) Parameters(org.testng.annotations.Parameters) BaseComponentTest(org.gluu.oxauth.BaseComponentTest) Test(org.testng.annotations.Test)

Example 52 with SessionId

use of org.gluu.oxauth.model.common.SessionId in project oxAuth by GluuFederation.

the class SessionIdServiceTest method testUpdateAttributes.

@Parameters({ "userInum" })
@Test
public void testUpdateAttributes(String userInum) {
    SessionId m_sessionId = generateSession(userInum);
    final String clientId = "testClientId";
    final SessionId fromLdap1 = m_service.getSessionId(m_sessionId.getId());
    final Date createdDate = m_sessionId.getLastUsedAt();
    assertEquals(createdDate, fromLdap1.getLastUsedAt());
    assertFalse(fromLdap1.isPermissionGrantedForClient(clientId));
    sleepSeconds(1);
    m_sessionId.setAuthenticationTime(new Date());
    m_sessionId.addPermission(clientId, true);
    m_service.updateSessionId(m_sessionId);
    final SessionId fromLdap2 = m_service.getSessionId(m_sessionId.getId());
    assertTrue(createdDate.before(fromLdap2.getLastUsedAt()));
    assertNotNull(fromLdap2.getAuthenticationTime());
    assertTrue(fromLdap2.isPermissionGrantedForClient(clientId));
}
Also used : SessionId(org.gluu.oxauth.model.common.SessionId) Date(java.util.Date) Parameters(org.testng.annotations.Parameters) BaseComponentTest(org.gluu.oxauth.BaseComponentTest) Test(org.testng.annotations.Test)

Aggregations

SessionId (org.gluu.oxauth.model.common.SessionId)52 CustomScriptConfiguration (org.gluu.model.custom.script.conf.CustomScriptConfiguration)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 User (org.gluu.oxauth.model.common.User)7 Date (java.util.Date)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 URISyntaxException (java.net.URISyntaxException)4 HashMap (java.util.HashMap)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 AuthorizationGrant (org.gluu.oxauth.model.common.AuthorizationGrant)4 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 BaseComponentTest (org.gluu.oxauth.BaseComponentTest)3 SimpleUser (org.gluu.oxauth.model.common.SimpleUser)3 AcrChangedException (org.gluu.oxauth.model.exception.AcrChangedException)3 InvalidSessionStateException (org.gluu.oxauth.model.exception.InvalidSessionStateException)3 Client (org.gluu.oxauth.model.registration.Client)3 ConsentGatheringContext (org.gluu.oxauth.service.external.context.ConsentGatheringContext)3 UmaGatherContext (org.gluu.oxauth.uma.authorization.UmaGatherContext)3 Parameters (org.testng.annotations.Parameters)3