@Test
    void verifyOps() {
        val port = URI.create(casProperties.getAuthn().getMfa().getYubikey().getRest().getUrl()).getPort();
        try (val webServer = new MockWebServer(port)) {
            webServer.responseBodySupplier(() -> new ByteArrayResource(StringUtils.EMPTY.getBytes(StandardCharsets.UTF_8)));
            webServer.start();
            val request = YubiKeyDeviceRegistrationRequest.builder().username("casuser")
                .token(AbstractYubiKeyAccountRegistryTests.OTP).name(UUID.randomUUID().toString()).build();
            assertTrue(getYubiKeyAccountRegistry().registerAccountFor(request));
            assertDoesNotThrow(() -> {
                getYubiKeyAccountRegistry().delete(request.getUsername());
                getYubiKeyAccountRegistry().deleteAll();
            });

            var pubKey = getYubiKeyAccountRegistry().getAccountValidator().getTokenPublicId(AbstractYubiKeyAccountRegistryTests.OTP);
            var registeredDevice = YubiKeyRegisteredDevice.builder()
                .id(System.currentTimeMillis())
                .name("first-device")
                .publicId(getYubikeyAccountCipherExecutor().encode(pubKey).toString())
                .registrationDate(ZonedDateTime.now(Clock.systemUTC()))
                .build();
            var account = YubiKeyAccount.builder()
                .devices(CollectionUtils.wrapList(registeredDevice))
                .username("casuser")
                .build();
            webServer.responseBodyJson(account);
            val request2 = YubiKeyDeviceRegistrationRequest.builder().username(account.getUsername())
                .token(AbstractYubiKeyAccountRegistryTests.OTP).name(UUID.randomUUID().toString()).build();
            assertTrue(getYubiKeyAccountRegistry().isYubiKeyRegisteredFor(request2.getUsername()));
            assertDoesNotThrow(() -> getYubiKeyAccountRegistry().delete(account.getUsername(), registeredDevice.getId()));

            webServer.responseBodyJson(CollectionUtils.wrapList(account));
            assertFalse(getYubiKeyAccountRegistry().getAccounts().isEmpty());

            webServer.responseBodySupplier(() -> new ByteArrayResource("...".getBytes(StandardCharsets.UTF_8)));
            assertTrue(getYubiKeyAccountRegistry().getAccounts().isEmpty());
        }
    }
This is {@link RestfulYubiKeyAccountRegistryTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-yubikey/src/test/java/org/apereo/cas/adaptors/yubikey/registry/RestfulYubiKeyAccountRegistryTests.java