Search in sources :

Example 1 with MultifactorAuthenticationProviderBypassAuditResourceResolver

use of org.apereo.cas.authentication.bypass.audit.MultifactorAuthenticationProviderBypassAuditResourceResolver in project cas by apereo.

the class MultifactorAuthenticationProviderBypassAuditResourceResolverTests method verifyJsonOperation.

@Test
public void verifyJsonOperation() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    val resolver = new MultifactorAuthenticationProviderBypassAuditResourceResolver();
    resolver.setAuditFormat(AuditTrailManager.AuditFormats.JSON);
    val jp = mock(JoinPoint.class);
    val args = new Object[] { MultifactorAuthenticationTestUtils.getAuthentication("casuser"), MultifactorAuthenticationTestUtils.getRegisteredService(), TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext) };
    when(jp.getArgs()).thenReturn(args);
    when(jp.getTarget()).thenReturn("TargetObject");
    val outcome = resolver.resolveFrom(jp, new Object());
    assertTrue(outcome.length > 0);
    assertNotNull(resolver.resolveFrom(jp, new RuntimeException("failed")));
    when(jp.getArgs()).thenReturn(null);
    assertEquals(0, resolver.resolveFrom(jp, new Object()).length);
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) MultifactorAuthenticationProviderBypassAuditResourceResolver(org.apereo.cas.authentication.bypass.audit.MultifactorAuthenticationProviderBypassAuditResourceResolver) Test(org.junit.jupiter.api.Test)

Example 2 with MultifactorAuthenticationProviderBypassAuditResourceResolver

use of org.apereo.cas.authentication.bypass.audit.MultifactorAuthenticationProviderBypassAuditResourceResolver in project cas by apereo.

the class MultifactorAuthenticationProviderBypassAuditResourceResolverTests method verifyOperation.

@Test
public void verifyOperation() {
    val applicationContext = new StaticApplicationContext();
    applicationContext.refresh();
    val resolver = new MultifactorAuthenticationProviderBypassAuditResourceResolver();
    val jp = mock(JoinPoint.class);
    val args = new Object[] { MultifactorAuthenticationTestUtils.getAuthentication("casuser"), MultifactorAuthenticationTestUtils.getRegisteredService(), TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext) };
    when(jp.getArgs()).thenReturn(args);
    when(jp.getTarget()).thenReturn("TargetObject");
    val outcome = resolver.resolveFrom(jp, new Object());
    assertTrue(outcome.length > 0);
    assertNotNull(resolver.resolveFrom(jp, new RuntimeException("failed")));
    when(jp.getArgs()).thenReturn(null);
    assertEquals(0, resolver.resolveFrom(jp, new Object()).length);
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) MultifactorAuthenticationProviderBypassAuditResourceResolver(org.apereo.cas.authentication.bypass.audit.MultifactorAuthenticationProviderBypassAuditResourceResolver) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)2 MultifactorAuthenticationProviderBypassAuditResourceResolver (org.apereo.cas.authentication.bypass.audit.MultifactorAuthenticationProviderBypassAuditResourceResolver)2 Test (org.junit.jupiter.api.Test)2 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2