Add test for unknown node identifiers on modify peer command
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 13 Jul 2015 18:39:38 +0000 (20:39 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Mon, 13 Jul 2015 18:39:38 +0000 (20:39 +0200)
src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java

index cf7a4ae..5979284 100644 (file)
@@ -1338,6 +1338,29 @@ public class DefaultFcpClientTest {
        }
 
        @Test
+       public void defaultFcpClientCanNotModifyPeerOfUnknownNode()
+       throws InterruptedException, ExecutionException, IOException {
+               Future<Optional<Peer>> peer = fcpClient.modifyPeer().enable().byIdentity("id1").execute();
+               connectNode();
+               List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+               String identifier = extractIdentifier(lines);
+               assertThat(lines, matchesFcpMessage(
+                       "ModifyPeer",
+                       "Identifier=" + identifier,
+                       "NodeIdentifier=id1",
+                       "IsDisabled=false",
+                       "EndMessage"
+               ));
+               fcpServer.writeLine(
+                       "UnknownNodeIdentifier",
+                       "Identifier=" + identifier,
+                       "NodeIdentifier=id1",
+                       "EndMessage"
+               );
+               assertThat(peer.get().isPresent(), is(false));
+       }
+
+       @Test
        public void defaultFcpClientCanAllowLocalAddressesOfPeer()
        throws InterruptedException, ExecutionException, IOException {
                Future<Optional<Peer>> peer = fcpClient.modifyPeer().allowLocalAddresses().byIdentity("id1").execute();