Search in sources :

Example 1 with DefaultAuthenticationTransaction

use of org.apereo.cas.authentication.DefaultAuthenticationTransaction in project cas by apereo.

the class SuccessfulHandlerMetaDataPopulatorTests method verifyOperation.

@Test
public void verifyOperation() {
    val input = new SuccessfulHandlerMetaDataPopulator();
    val transaction = new DefaultAuthenticationTransaction(CoreAuthenticationTestUtils.getWebApplicationService(), List.of(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword("cas")));
    val builder = new DefaultAuthenticationBuilder();
    input.populateAttributes(builder, transaction);
    assertFalse(builder.hasAttribute(AuthenticationHandler.SUCCESSFUL_AUTHENTICATION_HANDLERS));
    assertTrue(builder.getAttributes().get(AuthenticationHandler.SUCCESSFUL_AUTHENTICATION_HANDLERS).isEmpty());
}
Also used : lombok.val(lombok.val) DefaultAuthenticationBuilder(org.apereo.cas.authentication.DefaultAuthenticationBuilder) DefaultAuthenticationTransaction(org.apereo.cas.authentication.DefaultAuthenticationTransaction) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultAuthenticationTransaction

use of org.apereo.cas.authentication.DefaultAuthenticationTransaction in project cas by apereo.

the class CasAuthenticationEventListenerTests method verifyCasAuthenticationPolicyFailureEvent.

@Test
public void verifyCasAuthenticationPolicyFailureEvent() {
    val event = new CasAuthenticationPolicyFailureEvent(this, CollectionUtils.wrap("error", new FailedLoginException()), new DefaultAuthenticationTransaction(CoreAuthenticationTestUtils.getService(), CollectionUtils.wrap(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword())), CoreAuthenticationTestUtils.getAuthentication());
    applicationContext.publishEvent(event);
    assertFalse(casEventRepository.load().findAny().isEmpty());
}
Also used : lombok.val(lombok.val) FailedLoginException(javax.security.auth.login.FailedLoginException) DefaultAuthenticationTransaction(org.apereo.cas.authentication.DefaultAuthenticationTransaction) CasAuthenticationPolicyFailureEvent(org.apereo.cas.support.events.authentication.CasAuthenticationPolicyFailureEvent) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)2 DefaultAuthenticationTransaction (org.apereo.cas.authentication.DefaultAuthenticationTransaction)2 Test (org.junit.jupiter.api.Test)2 FailedLoginException (javax.security.auth.login.FailedLoginException)1 DefaultAuthenticationBuilder (org.apereo.cas.authentication.DefaultAuthenticationBuilder)1 CasAuthenticationPolicyFailureEvent (org.apereo.cas.support.events.authentication.CasAuthenticationPolicyFailureEvent)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1