Search in sources :

Example 16 with Ticket

use of org.craftercms.profile.api.Ticket in project profile by craftercms.

the class AuthenticationServiceImplTest method testAuthenticate.

@Test
public void testAuthenticate() throws Exception {
    Ticket ticket = authenticationService.authenticate(TENANT_NAME, USERNAME1, PASSWORD);
    assertNotNull(ticket);
    assertEquals(PROFILE1_ID.toString(), ticket.getProfileId());
    assertNotNull(ticket.getLastRequestTime());
    verify(profileService).getProfileByUsername(TENANT_NAME, USERNAME1, ProfileConstants.NO_ATTRIBUTE);
    verify(ticketRepository).insert(ticket);
}
Also used : Ticket(org.craftercms.profile.api.Ticket) Test(org.junit.Test)

Example 17 with Ticket

use of org.craftercms.profile.api.Ticket in project profile by craftercms.

the class AuthenticationServiceIT method testInvalidateTicket.

@Test
public void testInvalidateTicket() throws Exception {
    Ticket ticket = authenticationService.authenticate(DEFAULT_TENANT_NAME, ADMIN_USERNAME, ADMIN_PASSWORD);
    assertNotNull(ticket);
    authenticationService.invalidateTicket(ticket.getId());
    ticket = authenticationService.getTicket(ticket.getId());
    assertNull(ticket);
}
Also used : Ticket(org.craftercms.profile.api.Ticket) Test(org.junit.Test)

Example 18 with Ticket

use of org.craftercms.profile.api.Ticket in project profile by craftercms.

the class AuthenticationServiceIT method testGetTicket.

@Test
public void testGetTicket() throws Exception {
    Ticket ticket = authenticationService.authenticate(DEFAULT_TENANT_NAME, ADMIN_USERNAME, ADMIN_PASSWORD);
    assertNotNull(ticket);
    Date lastRequestTime = ticket.getLastRequestTime();
    ticket = authenticationService.getTicket(ticket.getId());
    assertNotNull(ticket);
    assertTrue(ticket.getLastRequestTime().after(lastRequestTime));
    authenticationService.invalidateTicket(ticket.getId());
}
Also used : Ticket(org.craftercms.profile.api.Ticket) Date(java.util.Date) Test(org.junit.Test)

Example 19 with Ticket

use of org.craftercms.profile.api.Ticket in project profile by craftercms.

the class ProfileServiceImplTest method getTicket.

private Ticket getTicket() {
    Ticket ticket = new Ticket();
    ticket.setId(TICKET_ID);
    ticket.setTenant(TENANT1_NAME);
    ticket.setProfileId(PROFILE1_ID.toString());
    ticket.setLastRequestTime(new Date());
    return ticket;
}
Also used : Ticket(org.craftercms.profile.api.Ticket) Date(java.util.Date)

Aggregations

Ticket (org.craftercms.profile.api.Ticket)19 Test (org.junit.Test)9 Date (java.util.Date)8 MongoDataException (org.craftercms.commons.mongo.MongoDataException)4 Profile (org.craftercms.profile.api.Profile)4 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)4 ProfileException (org.craftercms.profile.api.exceptions.ProfileException)2 DisabledProfileException (org.craftercms.profile.exceptions.DisabledProfileException)2 ProfileRestServiceException (org.craftercms.profile.exceptions.ProfileRestServiceException)2 AuthenticationSystemException (org.craftercms.security.exception.AuthenticationSystemException)2 DisabledUserException (org.craftercms.security.exception.DisabledUserException)2 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)1 BadCredentialsException (org.craftercms.profile.exceptions.BadCredentialsException)1 ProfileLockedException (org.craftercms.profile.exceptions.ProfileLockedException)1 BadCredentialsException (org.craftercms.security.exception.BadCredentialsException)1