|
|
|
@ -72,14 +72,15 @@ public class DownloadTest extends LfsServerTest {
|
|
|
|
|
public void testDownloadInvalidPathInfo() |
|
|
|
|
throws ClientProtocolException, IOException { |
|
|
|
|
String TEXT = "test"; |
|
|
|
|
AnyLongObjectId id = putContent(TEXT); |
|
|
|
|
String id = putContent(TEXT).name().substring(0, 60); |
|
|
|
|
Path f = Paths.get(getTempDirectory().toString(), "download"); |
|
|
|
|
try { |
|
|
|
|
getContent(id.name().substring(0, 60), f); |
|
|
|
|
getContent(id, f); |
|
|
|
|
fail("expected RuntimeException"); |
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
|
assertEquals("Status: 422 Unprocessable Entity", |
|
|
|
|
e.getMessage()); |
|
|
|
|
String error = String.format( |
|
|
|
|
"Invalid pathInfo '/%s' does not match '/{SHA-256}'", id); |
|
|
|
|
assertEquals(formatErrorMessage(422, error), e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -87,14 +88,14 @@ public class DownloadTest extends LfsServerTest {
|
|
|
|
|
public void testDownloadInvalidId() |
|
|
|
|
throws ClientProtocolException, IOException { |
|
|
|
|
String TEXT = "test"; |
|
|
|
|
AnyLongObjectId id = putContent(TEXT); |
|
|
|
|
String id = putContent(TEXT).name().replace('f', 'z'); |
|
|
|
|
Path f = Paths.get(getTempDirectory().toString(), "download"); |
|
|
|
|
try { |
|
|
|
|
getContent(id.name().replace('f', 'z'), f); |
|
|
|
|
getContent(id, f); |
|
|
|
|
fail("expected RuntimeException"); |
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
|
assertEquals("Status: 422 Unprocessable Entity", |
|
|
|
|
e.getMessage()); |
|
|
|
|
String error = String.format("Invalid id: : %s", id); |
|
|
|
|
assertEquals(formatErrorMessage(422, error), e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -108,8 +109,8 @@ public class DownloadTest extends LfsServerTest {
|
|
|
|
|
getContent(id, f); |
|
|
|
|
fail("expected RuntimeException"); |
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
|
assertEquals("Status: 404 Not Found", |
|
|
|
|
e.getMessage()); |
|
|
|
|
String error = String.format("Object '%s' not found", id.getName()); |
|
|
|
|
assertEquals(formatErrorMessage(404, error), e.getMessage()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -129,4 +130,10 @@ public class DownloadTest extends LfsServerTest {
|
|
|
|
|
FileUtils.delete(f.toFile(), FileUtils.RETRY); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("boxing") |
|
|
|
|
private String formatErrorMessage(int status, String message) { |
|
|
|
|
return String.format("Status: %d {\n \"message\": \"%s\"\n}", status, |
|
|
|
|
message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|