diff options
author | Vitaly Takmazov | 2018-07-24 14:08:36 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-07-24 14:08:36 +0300 |
commit | 3fa18888d5ca53b59c778de3f829870614d05c27 (patch) | |
tree | 7e38b5838a45ae783e0cb636b4fb10ddcedfbf97 /juick-server/src/test/java | |
parent | 10ee29dcb05f992fe2b7aa726b6ac7c9e9aba87d (diff) |
Ignore uploaded file extension
* guess content type from content stream
Diffstat (limited to 'juick-server/src/test/java')
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 15 |
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 2d45aae00..e4e5f2986 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")); + } } |