/** * Verifies that authentication requests without subjects are not accepted. * * @throws Exception if an error occurs. */ @Test public void shouldNotAuthenticateWithoutSubject() throws Exception { logger.debug("Verifying that an authentication request without a subject is rejected..."); AssertionBuilder assertionBuilder = new AssertionBuilder(); Saml2AuthenticationToken authentication = new Saml2AuthenticationToken(assertionBuilder.getAssertion()); assertNull(authnProvider.authenticate(authentication)); assertFalse(authentication.isAuthenticated()); }
/** * Verifies that valid authentication requests are accepted. * * @throws Exception if an error occurs. */ @Test public void shouldAuthenticate() throws Exception { logger.debug("Verifying that a valid authentication request is accepted..."); AssertionBuilder assertionBuilder = new AssertionBuilder(); assertionBuilder.setSubject("*****@*****.**"); Saml2AuthenticationToken authentication = new Saml2AuthenticationToken(assertionBuilder.getAssertion()); assertNotNull(authnProvider.authenticate(authentication)); assertTrue(authentication.isAuthenticated()); }