package org.apereo.cas.web.flow;

import org.apereo.cas.config.CasCoreMultifactorAuthenticationConfiguration;
import org.apereo.cas.config.PasswordlessAuthenticationConfiguration;
import org.apereo.cas.config.PasswordlessAuthenticationWebflowConfiguration;
import org.apereo.cas.web.flow.config.CasMultifactorAuthenticationWebflowConfiguration;

import lombok.val;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.engine.TransitionableState;

import static org.junit.jupiter.api.Assertions.*;

/**
 * This is {@link PasswordlessAuthenticationWebflowConfigurerTests}.
 *
 * @author Misagh Moayyed
 * @since 6.2.0
 */
@Import({
    ThymeleafAutoConfiguration.class,
    CasCoreMultifactorAuthenticationConfiguration.class,
    CasMultifactorAuthenticationWebflowConfiguration.class,
    BaseWebflowConfigurerTests.SharedTestConfiguration.class,
    PasswordlessAuthenticationConfiguration.class,
    PasswordlessAuthenticationWebflowConfiguration.class
})
@Tag("Webflow")
public class PasswordlessAuthenticationWebflowConfigurerTests extends BaseWebflowConfigurerTests {

    @Test
    public void verifyOperation() {
        assertFalse(casWebflowExecutionPlan.getWebflowConfigurers().isEmpty());
        val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
        assertNotNull(flow);

        var state = (TransitionableState) flow.getState(PasswordlessAuthenticationWebflowConfigurer.STATE_ID_ACCEPT_PASSWORDLESS_AUTHENTICATION);
        assertNotNull(state);
        state = (TransitionableState) flow.getState(PasswordlessAuthenticationWebflowConfigurer.STATE_ID_PASSWORDLESS_DISPLAY);
        assertNotNull(state);
        state = (TransitionableState) flow.getState(PasswordlessAuthenticationWebflowConfigurer.STATE_ID_PASSWORDLESS_GET_USERID);
        assertNotNull(state);
        state = (TransitionableState) flow.getState(PasswordlessAuthenticationWebflowConfigurer.STATE_ID_PASSWORDLESS_VERIFY_ACCOUNT);
        assertNotNull(state);
        state = (TransitionableState) flow.getState(PasswordlessAuthenticationWebflowConfigurer.STATE_ID_PASSWORDLESS_DETERMINE_MFA);
        assertNotNull(state);
    }
}


@@ -95,32 +95,84 @@
 nConfiguration;%0A
+import org.apereo.cas.config.CoreSamlConfiguration;%0A
 import org.apere
@@ -294,32 +294,236 @@
 wConfiguration;%0A
+import org.apereo.cas.support.pac4j.config.Pac4jDelegatedAuthenticationConfiguration;%0Aimport org.apereo.cas.support.pac4j.config.support.authentication.Pac4jAuthenticationEventExecutionPlanConfiguration;%0A
 import org.apere
@@ -593,16 +593,99 @@
 uration;
+%0Aimport org.apereo.cas.web.flow.config.DelegatedAuthenticationWebflowConfiguration;
 %0A%0Aimport
@@ -816,27 +816,206 @@
 ure.
-thymeleaf.Thymeleaf
+web.servlet.WebMvcAutoConfiguration;%0Aimport org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;%0Aimport org.springframework.boot.test.autoconfigure.web.servlet.MockMvc
 Auto
@@ -1386,200 +1386,473 @@
     
-ThymeleafAutoConfiguration.class,%0A    CasCoreMultifactorAuthenticationConfiguration.class,%0A    CasMultifactorAuthenticationWebflowConfiguration.class,%0A    BaseWebflowConfigurerTests.SharedTest
+BaseWebflowConfigurerTests.SharedTestConfiguration.class,%0A    WebMvcAutoConfiguration.class,%0A    MockMvcAutoConfiguration.class,%0A    ErrorMvcAutoConfiguration.class,%0A    CoreSamlConfiguration.class,%0A    CasCoreMultifactorAuthenticationConfiguration.class,%0A    CasMultifactorAuthenticationWebflowConfiguration.class,%0A    Pac4jDelegatedAuthenticationConfiguration.class,%0A    Pac4jAuthenticationEventExecutionPlanConfiguration.class,%0A    DelegatedAuthenticationWebflow
 Conf

clean up tests