diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-03-16 19:19:15 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-04-01 17:40:34 -0400 |
commit | 58ed0cb840b29139483ce3b499354a6e5669498b (patch) | |
tree | a6fc0fd15c11dbf00099225e055d33d9a2cd06de /org.eclipse.jgit.http.test/tst | |
parent | 64b524e3ca3d1f66edaa49eda2d8863ddca779b5 (diff) | |
download | jgit-58ed0cb840b29139483ce3b499354a6e5669498b.tar.gz jgit-58ed0cb840b29139483ce3b499354a6e5669498b.zip |
smart HTTP: Return errors inside payload
When the client is clearly making a smart HTTP request to our smart
HTTP server, return any errors like RepositoryNotFoundException or
ServiceNotEnabledException inside of the payload as a Git level ERR
message, rather than an HTTP error code.
This prevents the C Git command line client from retrying a failed
"$URL/info/refs?service=git-upload-pack" request without the smart
service URL, only to fail again with "403 Forbidden" when the dumb
as-is service has been disabled by the server configuration, or is
unavailable because the repository is not on the local filesystem.
Change-Id: I57e8756d5026e885e0ca615979bfcd729703be6c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
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 | 32 |
1 files changed, 32 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 209f161c9b..c3590a44fb 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 @@ -55,6 +55,7 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.io.PrintWriter; +import java.net.URISyntaxException; import java.util.Collections; import java.util.List; import java.util.Map; @@ -73,6 +74,7 @@ import org.eclipse.jetty.servlet.FilterMapping; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jgit.JGitText; +import org.eclipse.jgit.errors.RemoteRepositoryException; import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.TransportException; import org.eclipse.jgit.http.server.GitServlet; @@ -224,6 +226,36 @@ public class SmartClientSmartServerTest extends HttpTestCase { } @Test + public void testListRemote_BadName() throws IOException, URISyntaxException { + Repository dst = createBareRepository(); + URIish uri = new URIish(this.remoteURI.toString() + ".invalid"); + Transport t = Transport.open(dst, uri); + try { + try { + t.openFetch(); + fail("fetch connection opened"); + } catch (RemoteRepositoryException notFound) { + assertEquals(uri + ": Git repository not found", + notFound.getMessage()); + } + } finally { + t.close(); + } + + List<AccessEvent> requests = getRequests(); + assertEquals(1, requests.size()); + + AccessEvent info = requests.get(0); + assertEquals("GET", info.getMethod()); + assertEquals(join(uri, "info/refs"), info.getPath()); + assertEquals(1, info.getParameters().size()); + assertEquals("git-upload-pack", info.getParameter("service")); + assertEquals(200, info.getStatus()); + assertEquals("application/x-git-upload-pack-advertisement", + info.getResponseHeader(HDR_CONTENT_TYPE)); + } + + @Test public void testInitialClone_Small() throws Exception { Repository dst = createBareRepository(); assertFalse(dst.hasObject(A_txt)); |