@BeforeEach
        void beforeEach() throws Exception {
            context = MockRequestContext.create(applicationContext);
            WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
            WebUtils.putRegisteredService(context, RegisteredServiceTestUtils.getRegisteredService("sample-service", Collections.emptyMap()));

            context.withUserAgent();
            val request = context.getHttpServletRequest();
            request.setRemoteAddr("123.456.789.000");
            request.setLocalAddr("123.456.789.000");
            ClientInfoHolder.setClientInfo(ClientInfo.from(request));

            val record = getMultifactorAuthenticationTrustRecord();
            record.setRecordDate(ZonedDateTime.now(ZoneOffset.UTC).minusSeconds(5));
            val deviceFingerprint = deviceFingerprintStrategy.determineFingerprint(
                RegisteredServiceTestUtils.getAuthentication(record.getPrincipal()),
                request, context.getHttpServletResponse());
            record.setDeviceFingerprint(deviceFingerprint);
            mfaTrustEngine.save(record);

            assertNotNull(context.getHttpServletResponse().getCookies());
            assertEquals(1, context.getHttpServletResponse().getCookies().length);
            request.setCookies(context.getHttpServletResponse().getCookies());

            val authn = RegisteredServiceTestUtils.getAuthentication(record.getPrincipal());
            WebUtils.putAuthentication(authn, context);

            ApplicationContextProvider.holdApplicationContext(applicationContext);
        }
This is {@link MultifactorAuthenticationPrepareTrustDeviceViewActionTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-trusted-mfa/src/test/java/org/apereo/cas/trusted/web/flow/MultifactorAuthenticationPrepareTrustDeviceViewActionTests.java