From d91d96d600b3eca26f794cb99d26324e35bbecd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 8 Jan 2025 09:24:12 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Add=20more=20tests=20for=20deprecate?= =?utf8?q?d=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../fcp/plugin/WebOfTrustPluginTest.java | 43 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java index e8d5f35..8139cab 100644 --- a/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java +++ b/src/test/java/net/pterodactylus/fcp/plugin/WebOfTrustPluginTest.java @@ -120,12 +120,22 @@ public class WebOfTrustPluginTest { } @Test - public void creatingIdentityFailsWhenDifferentReplyIsSentByPlugin() { - FcpConnection fcpConnection = createFcpConnection(message -> (listener, connection) -> { - Map fields = createWebOfTrustReplyFields("OtherMessage", true); - FcpMessage replyMessage = createPluginReply(message, fields); - listener.receivedFCPPluginReply(connection, new FCPPluginReply(replyMessage, null)); - }); + public void creatingIdentityFailsWithoutKeysFailsWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true)); + } + + @Test + public void creatingIdentityFailsWithInsertKeyFailsWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true, "insert-uri")); + } + + @Test + public void creatingIdentityWithInsertAndRequestKeyFailsWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true, "some-request-uri", "insert-uri")); } @@ -199,6 +209,27 @@ public class WebOfTrustPluginTest { }); } + @Test + public void getOwnIdentitiesFailsWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, webOfTrustPlugin::getOwnIdentities); + } + + @Test + public void getOwnIdentitiesWithDeprecatedMethodFailsWhenDifferentReplyIsSentByPlugin() { + FcpConnection fcpConnection = createConnectionThatSendsOtherMessage(); + WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection); + assertThrows(FcpException.class, webOfTrustPlugin::getOwnIdentites); + } + + private FcpConnection createConnectionThatSendsOtherMessage() { + return createFcpConnection(message -> (listener, connection) -> { + Map fields = createWebOfTrustReplyFields("OtherMessage", true); + FcpMessage replyMessage = createPluginReply(message, fields); + listener.receivedFCPPluginReply(connection, new FCPPluginReply(replyMessage, null)); + }); + } private static WebOfTrustPlugin createWebOfTrustPlugin(FcpConnection fcpConnection) { return new WebOfTrustPlugin(new FcpClient(fcpConnection)); -- 2.7.4