From: David ‘Bombe’ Roden Date: Sun, 23 Aug 2015 14:58:25 +0000 (+0200) Subject: Refactor generate key pair command test X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;ds=sidebyside;h=80ee63c3eea721f3b0f536d5d812e34549332264;p=jFCPlib.git Refactor generate key pair command test --- diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index f423e97..abe32d5 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -110,22 +110,6 @@ public class DefaultFcpClientTest { keyPairFuture.get(); } - @Test - public void defaultFcpClientCanGenerateKeypair() throws ExecutionException, InterruptedException, IOException { - Future keyPairFuture = fcpClient.generateKeypair().execute(); - connectNode(); - List lines = fcpServer.collectUntil(is("EndMessage")); - String identifier = extractIdentifier(lines); - fcpServer.writeLine("SSKKeypair", - "InsertURI=" + INSERT_URI + "", - "RequestURI=" + REQUEST_URI + "", - "Identifier=" + identifier, - "EndMessage"); - FcpKeyPair keyPair = keyPairFuture.get(); - assertThat(keyPair.getPublicKey(), is(REQUEST_URI)); - assertThat(keyPair.getPrivateKey(), is(INSERT_URI)); - } - private void connectNode() throws InterruptedException, ExecutionException, IOException { fcpServer.connect().get(); fcpServer.collectUntil(is("EndMessage")); @@ -1070,6 +1054,28 @@ public class DefaultFcpClientTest { assertThat(lines, requestMatcher.get()); } + public class GenerateKeyPair { + + @Test + public void defaultFcpClientCanGenerateKeypair() throws ExecutionException, InterruptedException, IOException { + Future keyPairFuture = fcpClient.generateKeypair().execute(); + connectAndAssert(() ->matchesFcpMessage("GenerateSSK", "EndMessage")); + replyWithKeyPair(); + FcpKeyPair keyPair = keyPairFuture.get(); + assertThat(keyPair.getPublicKey(), is(REQUEST_URI)); + assertThat(keyPair.getPrivateKey(), is(INSERT_URI)); + } + + private void replyWithKeyPair() throws IOException { + fcpServer.writeLine("SSKKeypair", + "InsertURI=" + INSERT_URI + "", + "RequestURI=" + REQUEST_URI + "", + "Identifier=" + identifier, + "EndMessage"); + } + + } + public class Peers { public class PeerCommands {