From 125c4277dad06cbd413f4d2b4d41a16a65c7b286 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 9 Jul 2015 07:12:56 +0200 Subject: [PATCH] Add test for client put not reacting to wrong TestDDAReply --- .../fcp/quelaton/DefaultFcpClientTest.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 47aff70..da454df 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -473,5 +473,47 @@ public class DefaultFcpClientTest { assertThat(key.get().isPresent(), is(false)); } + @Test + public void clientPutDoesNotReplyToWrongTestDdaReply() throws IOException, ExecutionException, + InterruptedException { + File tempFile = createTempFile(); + fcpClient.clientPut().from(new File(tempFile.getParent(), "test.dat")).key(new Key("KSK@foo.txt")); + connectNode(); + List lines = fcpServer.collectUntil(is("EndMessage")); + String identifier = extractIdentifier(lines); + fcpServer.writeLine( + "ProtocolError", + "Identifier=" + identifier, + "Code=25", + "EndMessage" + ); + lines = fcpServer.collectUntil(is("EndMessage")); + assertThat(lines, matchesFcpMessage( + "TestDDARequest", + "Directory=" + tempFile.getParent(), + "WantReadDirectory=true", + "WantWriteDirectory=false", + "EndMessage" + )); + fcpServer.writeLine( + "TestDDAReply", + "Directory=/some-other-directory", + "ReadFilename=" + tempFile, + "EndMessage" + ); + fcpServer.writeLine( + "TestDDAReply", + "Directory=" + tempFile.getParent(), + "ReadFilename=" + tempFile, + "EndMessage" + ); + lines = fcpServer.collectUntil(is("EndMessage")); + assertThat(lines, matchesFcpMessage( + "TestDDAResponse", + "Directory=" + tempFile.getParent(), + "ReadContent=test-content", + "EndMessage" + )); + } } -- 2.7.4