Gitlab Community Edition Instance

Commit bb12e9d9 authored by mhellka's avatar mhellka
Browse files

Test unicode names in file upload

parent d3a841e9
......@@ -7,10 +7,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.Response.Status;
import org.junit.Test;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -20,6 +16,9 @@ import de.gwdg.cdstar.rest.BaseRestTest;
import de.gwdg.cdstar.runtime.client.CDStarFile;
import de.gwdg.cdstar.runtime.services.VaultRegistry;
import de.gwdg.cdstar.web.common.model.FileInfo;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.Response.Status;
public class CrudFileTest extends BaseRestTest {
......@@ -88,6 +87,22 @@ public class CrudFileTest extends BaseRestTest {
assertEquals(2, getJsonLong("file_count"));
}
@Test
public void testUnicodeNames() {
var id = makeArchive();
var name = "測試";
putFile(id, name, "Hello World", "text/plain");
assertStatus(Status.CREATED);
putFile(id, name, "Hello World 2", "text/plain");
assertStatus(Status.OK);
target("/v3/test/", id, "/", name).request().get();
assertStatus(Status.OK);
target("/v3/test/", id, "/", name).queryParam("info", "true").request().get();
assertStatus(Status.OK);
assertEquals("測試", getJsonString("name"));
}
@Test
public void testPreventOverwrite() {
final String id = makeArchive();
......@@ -124,7 +139,7 @@ public class CrudFileTest extends BaseRestTest {
target("/v3/test/", id, "/test.txt").queryParam("info", "").request().get();
assertStatus(Status.OK);
assertEquals(new HashSet<>(Arrays.asList("md5", "sha1", "sha256")),
new HashSet<>(getJsonKeys("digests")));
new HashSet<>(getJsonKeys("digests")));
// Re-create file with only SHA256 enabled
putFile(id, "test.txt", "bar", "plain/text");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment