From: David ‘Bombe’ Roden Date: Wed, 8 Jan 2025 08:24:12 +0000 (+0100) Subject: ✅ Add more tests for deprecated methods X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d91d96d600b3eca26f794cb99d26324e35bbecd1;p=jFCPlib.git ✅ Add more tests for deprecated methods --- 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));