@Test
    void verifyRemovalByKey() throws Throwable {
        val port = URI.create(casProperties.getAuthn().getMfa().getTrusted().getRest().getUrl()).getPort();

        try (val webServer = new MockWebServer(port)) {
            webServer.start();
            webServer.setContentType(MediaType.APPLICATION_JSON_VALUE);

            val record = MultifactorAuthenticationTrustRecord.newInstance("casuser", "geography", "fingerprint");
            webServer.responseBody(MAPPER.writeValueAsString(CollectionUtils.wrap(record)));

            assertDoesNotThrow(() -> mfaTrustEngine.remove(record.getRecordKey()));

            webServer.responseBody(MAPPER.writeValueAsString(CollectionUtils.wrap(record)));
            mfaTrustEngine.save(record);
            val saved = mfaTrustEngine.get(record.getId());
            assertNotNull(saved);
            assertNotNull(mfaTrustEngine.getAll());
            val records = mfaTrustEngine.get("casuser");
            assertNotNull(records);
            
            record.setRecordDate(ZonedDateTime.now(ZoneOffset.UTC).truncatedTo(ChronoUnit.SECONDS).minusDays(2));
            webServer.responseBody(MAPPER.writeValueAsString(CollectionUtils.wrap(record)));
            mfaTrustEngine.save(record);
            assertNotNull(mfaTrustEngine.get(record.getPrincipal()));
        }
    }
This is {@link RestMultifactorAuthenticationTrustStorageTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-trusted-mfa-rest/src/test/java/org/apereo/cas/trusted/authentication/storage/RestMultifactorAuthenticationTrustStorageTests.java