Skip to content

Commit

Permalink
added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SavvasMisaghMoayyed committed Apr 22, 2015
1 parent 775caee commit 5ed46ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Expand Up @@ -494,8 +494,9 @@ public TicketGrantingTicket createTicketGrantingTicket(final Credential... crede
this.ticketRegistry.addTicket(ticketGrantingTicket);
return ticketGrantingTicket;
}
logger.warn("No credentials were specified in the request for creating a new ticket-granting ticket");
throw new TicketCreationException();
final String msg = "No credentials were specified in the request for creating a new ticket-granting ticket";
logger.warn(msg);
throw new TicketCreationException(new IllegalArgumentException(msg));
}

/**
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.jasig.cas.services.UnauthorizedServiceException;
import org.jasig.cas.services.UnauthorizedServiceForPrincipalException;
import org.jasig.cas.services.UnauthorizedSsoServiceException;
import org.jasig.cas.ticket.TicketCreationException;
import org.jasig.cas.ticket.TicketException;
import org.jasig.cas.ticket.ExpirationPolicy;
import org.jasig.cas.ticket.ServiceTicket;
Expand Down Expand Up @@ -81,13 +82,26 @@ public void verifyDestroyTicketGrantingTicketWithValidTicket() throws Exception
getCentralAuthenticationService().destroyTicketGrantingTicket(ticketId.getId());
}

@Test(expected=TicketCreationException.class)
public void disallowNullCredentionalsWhenCreatingTicketGrantingTicket() throws Exception {
final TicketGrantingTicket ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(null);

}

@Test(expected=TicketCreationException.class)
public void disallowNullCredentionalsArrayWhenCreatingTicketGrantingTicket() throws Exception {
final TicketGrantingTicket ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(new Credential[] {null, null} );
}

@Test(expected=ClassCastException.class)
public void verifyDestroyTicketGrantingTicketWithInvalidTicket() throws Exception {
final TicketGrantingTicket ticketId = getCentralAuthenticationService()
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
.createTicketGrantingTicket(
TestUtils.getCredentialsWithSameUsernameAndPassword());
final ServiceTicket serviceTicketId = getCentralAuthenticationService()
.grantServiceTicket(ticketId.getId(), TestUtils.getService());
.grantServiceTicket(ticketId.getId(), TestUtils.getService());

getCentralAuthenticationService().destroyTicketGrantingTicket(
serviceTicketId.getId());
Expand Down

0 comments on commit 5ed46ca

Please sign in to comment.