aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test/tst/org
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2020-05-19 07:17:24 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2021-01-03 16:25:01 +0100
commitd9143287b778deba259cdd9d7db0a6aaba558eb2 (patch)
treef8c23a9607db94493d570dbd5840e389049a4856 /org.eclipse.jgit.http.test/tst/org
parent0853a2410f22c8bd97a179dec14e3c083a27abbb (diff)
downloadjgit-d9143287b778deba259cdd9d7db0a6aaba558eb2.tar.gz
jgit-d9143287b778deba259cdd9d7db0a6aaba558eb2.zip
Enable git wire protocol version 2 on server side per default
Bug: 563145 Change-Id: Id5030c2b85466da0a8ccf3d78ae78df16d64ffc5 Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Diffstat (limited to 'org.eclipse.jgit.http.test/tst/org')
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java29
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java5
2 files changed, 20 insertions, 14 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
index 26a453be14..df093c185b 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
@@ -38,7 +38,6 @@ import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.http.AccessEvent;
import org.eclipse.jgit.junit.http.AppServer;
-import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
@@ -50,7 +49,6 @@ import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.PacketLineIn;
import org.eclipse.jgit.transport.PacketLineOut;
import org.eclipse.jgit.transport.Transport;
-import org.eclipse.jgit.transport.TransferConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.eclipse.jgit.transport.http.HttpConnection;
@@ -326,7 +324,22 @@ public class HttpClientTests extends AllFactoriesHttpTestCase {
}
@Test
- public void testHttpClientWantsV2ButServerNotConfigured() throws Exception {
+ public void testHttpClientWantsV2AndServerNotConfigured() throws Exception {
+ String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
+ HttpConnection c = HttpTransport.getConnectionFactory()
+ .create(new URL(url));
+ c.setRequestMethod("GET");
+ c.setRequestProperty("Git-Protocol", "version=2");
+ assertEquals(200, c.getResponseCode());
+
+ PacketLineIn pckIn = new PacketLineIn(c.getInputStream());
+ assertThat(pckIn.readString(), is("version 2"));
+ }
+
+ @Test
+ public void testHttpServerConfiguredToV0() throws Exception {
+ remoteRepository.getRepository().getConfig().setInt(
+ "protocol", null, "version", 0);
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
HttpConnection c = HttpTransport.getConnectionFactory()
.create(new URL(url));
@@ -344,11 +357,6 @@ public class HttpClientTests extends AllFactoriesHttpTestCase {
@Test
public void testV2HttpFirstResponse() throws Exception {
- remoteRepository.getRepository().getConfig().setString(
- ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
- ConfigConstants.CONFIG_KEY_VERSION,
- TransferConfig.ProtocolVersion.V2.version());
-
String url = smartAuthNoneURI.toString() + "/info/refs?service=git-upload-pack";
HttpConnection c = HttpTransport.getConnectionFactory()
.create(new URL(url));
@@ -368,11 +376,6 @@ public class HttpClientTests extends AllFactoriesHttpTestCase {
@Test
public void testV2HttpSubsequentResponse() throws Exception {
- remoteRepository.getRepository().getConfig().setString(
- ConfigConstants.CONFIG_PROTOCOL_SECTION, null,
- ConfigConstants.CONFIG_KEY_VERSION,
- TransferConfig.ProtocolVersion.V2.version());
-
String url = smartAuthNoneURI.toString() + "/git-upload-pack";
HttpConnection c = HttpTransport.getConnectionFactory()
.create(new URL(url));
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 f3e56f85d3..f2c7bc63c4 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
@@ -1333,6 +1333,8 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
new DfsRepositoryDescription(repoName));
final TestRepository<Repository> repo = new TestRepository<>(
badRefsRepo);
+ badRefsRepo.getConfig().setInt("protocol", null, "version",
+ enableProtocolV2 ? 2 : 0);
ServletContextHandler app = noRefServer.addContext("/git");
GitServlet gs = new GitServlet();
@@ -1362,7 +1364,8 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
Collections.<ObjectId> emptySet());
fail("Successfully served ref with value " + c.getRef(master));
} catch (TransportException err) {
- assertEquals("Internal server error", err.getMessage());
+ assertTrue("Unexpected exception message " + err.getMessage(),
+ err.getMessage().contains("Internal server error"));
}
} finally {
noRefServer.tearDown();