aboutsummaryrefslogtreecommitdiff
path: root/juick-server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 2d45aae0..e4e5f298 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -56,7 +56,6 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
-import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
@@ -84,6 +83,7 @@ import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.Instant;
@@ -1098,4 +1098,17 @@ public class ServerTests {
assertThat(postJpgCmyk.getNewMessage().get().getAttachment().getMedium().getHeight(), is(1024));
assertThat(postJpgCmyk.getNewMessage().get().getAttachment().getSmall().getHeight(), is(512));
}
+ @Test
+ public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception {
+ Path pngOutput = Paths.get(tmpDir, "cmyk.png");
+ Files.delete(pngOutput);
+ Files.copy(getClass().getClassLoader().getResourceAsStream("cmyk.jpg"), pngOutput);
+ assertThat(pngOutput.toFile().exists(), is(true));
+ CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", pngOutput.toUri());
+ assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true));
+ assertThat(postJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
+ CommandResult replyJpgCmyk = commandsManager.processCommand(ugnich, String.format("#%d YO", postJpgCmyk.getNewMessage().get().getMid()), pngOutput.toUri());
+ assertThat(replyJpgCmyk.getNewMessage().isPresent(), is(true));
+ assertThat(replyJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
+ }
}