use of org.springframework.binding.expression.support.LiteralExpression in project cas by apereo.
the class AuthenticationAttributeMultifactorAuthenticationPolicyEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
servicesManager.save(registeredService);
WebUtils.putRegisteredService(context, registeredService);
WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(), context);
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
var results = authenticationAttributeMultifactorAuthenticationPolicyEventResolver.resolve(context);
assertNull(results);
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
val authn = RegisteredServiceTestUtils.getAuthentication();
authn.getAttributes().put("authn-method-dummy", List.of("mfa-dummy"));
WebUtils.putAuthentication(authn, context);
results = authenticationAttributeMultifactorAuthenticationPolicyEventResolver.resolve(context);
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(TestMultifactorAuthenticationProvider.ID, results.iterator().next().getId());
}
use of org.springframework.binding.expression.support.LiteralExpression in project cas by apereo.
the class RequestHeaderMultifactorAuthenticationPolicyEventResolverTests method verifyOperation.
@Test
public void verifyOperation() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val service = RegisteredServiceTestUtils.getRegisteredService();
servicesManager.save(service);
WebUtils.putRegisteredService(context, service);
WebUtils.putAuthentication(RegisteredServiceTestUtils.getAuthentication(), context);
WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
var results = requestHeaderAuthenticationPolicyWebflowEventResolver.resolve(context);
assertNull(results);
val targetResolver = new DefaultTargetStateResolver(TestMultifactorAuthenticationProvider.ID);
val transition = new Transition(new DefaultTransitionCriteria(new LiteralExpression(TestMultifactorAuthenticationProvider.ID)), targetResolver);
context.getRootFlow().getGlobalTransitionSet().add(transition);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext);
request.addHeader(casProperties.getAuthn().getMfa().getTriggers().getHttp().getRequestHeader(), TestMultifactorAuthenticationProvider.ID);
results = requestHeaderAuthenticationPolicyWebflowEventResolver.resolve(context);
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(TestMultifactorAuthenticationProvider.ID, results.iterator().next().getId());
}
Aggregations