diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-02-16 15:09:05 -0800 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-02-16 15:09:05 -0800 |
commit | e7a6e85b95b2665b124f57181d8f9bc29100adce (patch) | |
tree | 228d5ed850c0658aca12f4d3b5fa16b84bd02943 /org.eclipse.jgit.http.test/tst | |
parent | ff5c756c79d1c10575b927cf3bb2eb1e1fcc391b (diff) | |
download | jgit-e7a6e85b95b2665b124f57181d8f9bc29100adce.tar.gz jgit-e7a6e85b95b2665b124f57181d8f9bc29100adce.zip |
smart HTTP server: Pass along "want X not valid" to client
If the client sends a SHA-1 that the server does not recognize echo
this back to the client with an explicit error message instead of
the generic "internal server error".
This was always the intent of the implementation but it was being
dropped on smart HTTP due to the UploadPackServlet catching the
PackProtocolException, discarding the buffered message UploadPack
meant to send, and sending along a generic message instead.
Change-Id: I8d96b064ec655aef64ac2ef3e01853625af32cd1
Diffstat (limited to 'org.eclipse.jgit.http.test/tst')
-rw-r--r-- | org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java index 82861ed9b7..0f3d3c6cf5 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java @@ -56,6 +56,7 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.PrintWriter; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -89,6 +90,8 @@ import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.ObjectIdRef; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.ReflogEntry; import org.eclipse.jgit.lib.ReflogReader; @@ -487,6 +490,25 @@ public class SmartClientSmartServerTest extends HttpTestCase { } @Test + public void testInvalidWant() throws Exception { + @SuppressWarnings("resource") + ObjectId id = new ObjectInserter.Formatter().idFor(Constants.OBJ_BLOB, + "testInvalidWant".getBytes(StandardCharsets.UTF_8)); + + Repository dst = createBareRepository(); + try (Transport t = Transport.open(dst, remoteURI); + FetchConnection c = t.openFetch()) { + Ref want = new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, id.name(), + id); + c.fetch(NullProgressMonitor.INSTANCE, Collections.singleton(want), + Collections.<ObjectId> emptySet()); + fail("Server accepted want " + id.name()); + } catch (TransportException err) { + assertEquals("want " + id.name() + " not valid", err.getMessage()); + } + } + + @Test public void testPush_NotAuthorized() throws Exception { final TestRepository src = createTestRepository(); final RevBlob Q_txt = src.blob("new text"); |