@Test
    void verifyDeviceTrusted() throws Throwable {
        val context = MockRequestContext.create(applicationContext);
        WebUtils.putServiceIntoFlowScope(context, RegisteredServiceTestUtils.getService());
        WebUtils.putRegisteredService(context, RegisteredServiceTestUtils.getRegisteredService("sample-service", Collections.emptyMap()));

        context.setRemoteAddr("123.456.789.000");
        context.setLocalAddr("123.456.789.000");
        context.withUserAgent();
        context.setClientInfo();

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

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

        val authn = RegisteredServiceTestUtils.getAuthentication(record.getPrincipal());
        WebUtils.putAuthentication(authn, context);
        assertEquals(CasWebflowConstants.TRANSITION_ID_YES, mfaVerifyTrustAction.execute(context).getId());
        assertTrue(MultifactorAuthenticationTrustUtils.isMultifactorAuthenticationTrustedInScope(context));
        assertTrue(authn.containsAttribute(casProperties.getAuthn().getMfa().getTrusted().getCore().getAuthenticationContextAttribute()));
        assertTrue(MultifactorAuthenticationTrustUtils.getMultifactorAuthenticationTrustRecord(context, MultifactorAuthenticationTrustRecord.class).isPresent());
    }
This is {@link MultifactorAuthenticationVerifyTrustActionTests}.

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