summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-11-03 23:33:19 +0100
committerThomas Wolf <thomas.wolf@paranor.ch>2020-11-03 23:50:21 +0100
commitd69fb4d4ac7bcf7d0d84109bba56cf944646fb24 (patch)
tree12a796e526b04e9207ef7f05b28d263154150053 /org.eclipse.jgit.http.test
parent5dcc46591aa1ad63f19e5240eff2cabe6bb9f306 (diff)
downloadjgit-d69fb4d4ac7bcf7d0d84109bba56cf944646fb24.tar.gz
jgit-d69fb4d4ac7bcf7d0d84109bba56cf944646fb24.zip
Revert "Client-side protocol V2 support for fetching"
This reverts commit f802f06e7fd5a98f256b7b7727598491f563bf2f. I had misunderstood how protocol V2 works. This implementation only works if the negotiation during fetch is done in one round. Fixing this is substantial work in BasePackFetchConnection. Basically I think I'd have to change back negotiate to the V0 version, and have a doFetch() that does if protocol V2 doFetchV2() else doFetchV0() with doFetchV0 the old code, and doFetchV2 completely new. Plus there would need to be a HTTP test case requiring several negotiation rounds. This is a couple of days work at least, and I don't know when I will have the time to revisit this. So although the rest of the code is fine I prefer to back this out completely and not leave a only half working implementation in the code for an indeterminate time. Bug: 553083 Change-Id: Icbbbb09882b3b83f9897deac4a06d5f8dc99d84e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.http.test')
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllProtocolsHttpTestCase.java99
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java10
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java10
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java17
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java253
5 files changed, 87 insertions, 302 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllProtocolsHttpTestCase.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllProtocolsHttpTestCase.java
deleted file mode 100644
index c6931ad5b9..0000000000
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/AllProtocolsHttpTestCase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2020, Thomas Wolf <thomas.wolf@paranor.ch> and others
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Distribution License v. 1.0 which is available at
- * https://www.eclipse.org/org/documents/edl-v10.php.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-package org.eclipse.jgit.http.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jgit.junit.http.HttpTestCase;
-import org.eclipse.jgit.transport.HttpTransport;
-import org.eclipse.jgit.transport.http.HttpConnectionFactory;
-import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
-import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Abstract test base class for running HTTP-related tests with all connection
- * factories provided in JGit and with both protocol V0 and V2.
- */
-@Ignore
-@RunWith(Parameterized.class)
-public abstract class AllProtocolsHttpTestCase extends HttpTestCase {
-
- protected static class TestParameters {
-
- public final HttpConnectionFactory factory;
-
- public final boolean enableProtocolV2;
-
- public TestParameters(HttpConnectionFactory factory,
- boolean enableProtocolV2) {
- this.factory = factory;
- this.enableProtocolV2 = enableProtocolV2;
- }
-
- @Override
- public String toString() {
- return factory.toString() + " protocol "
- + (enableProtocolV2 ? "V2" : "V0");
- }
- }
-
- @Parameters(name = "{0}")
- public static Collection<TestParameters> data() {
- // run all tests with both connection factories we have
- HttpConnectionFactory[] factories = new HttpConnectionFactory[] {
- new JDKHttpConnectionFactory() {
-
- @Override
- public String toString() {
- return this.getClass().getSuperclass().getName();
- }
- }, new HttpClientConnectionFactory() {
-
- @Override
- public String toString() {
- return this.getClass().getSuperclass().getName();
- }
- } };
- List<TestParameters> result = new ArrayList<>();
- for (HttpConnectionFactory factory : factories) {
- result.add(new TestParameters(factory, false));
- result.add(new TestParameters(factory, true));
- }
- return result;
- }
-
- protected final boolean enableProtocolV2;
-
- protected AllProtocolsHttpTestCase(TestParameters params) {
- HttpTransport.setConnectionFactory(params.factory);
- enableProtocolV2 = params.enableProtocolV2;
- }
-
- private static HttpConnectionFactory originalFactory;
-
- @BeforeClass
- public static void saveConnectionFactory() {
- originalFactory = HttpTransport.getConnectionFactory();
- }
-
- @AfterClass
- public static void restoreConnectionFactory() {
- HttpTransport.setConnectionFactory(originalFactory);
- }
-
-}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
index ef9c41e625..6da5f86b3e 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
@@ -42,10 +42,11 @@ import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-public class DumbClientDumbServerTest extends AllProtocolsHttpTestCase {
+public class DumbClientDumbServerTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository;
private URIish remoteURI;
@@ -54,8 +55,8 @@ public class DumbClientDumbServerTest extends AllProtocolsHttpTestCase {
private RevCommit A, B;
- public DumbClientDumbServerTest(TestParameters params) {
- super(params);
+ public DumbClientDumbServerTest(HttpConnectionFactory cf) {
+ super(cf);
}
@Override
@@ -76,9 +77,6 @@ public class DumbClientDumbServerTest extends AllProtocolsHttpTestCase {
remoteRepository = src.getRepository();
remoteURI = toURIish(app, srcGit.getName());
- if (enableProtocolV2) {
- remoteRepository.getConfig().setInt("protocol", null, "version", 2);
- }
A_txt = src.blob("A");
A = src.commit().add("A_txt", A_txt).create();
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
index 096a199d0b..ccde1fe55c 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
@@ -42,10 +42,11 @@ import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.junit.Before;
import org.junit.Test;
-public class DumbClientSmartServerTest extends AllProtocolsHttpTestCase {
+public class DumbClientSmartServerTest extends AllFactoriesHttpTestCase {
private Repository remoteRepository;
private URIish remoteURI;
@@ -54,8 +55,8 @@ public class DumbClientSmartServerTest extends AllProtocolsHttpTestCase {
private RevCommit A, B;
- public DumbClientSmartServerTest(TestParameters params) {
- super(params);
+ public DumbClientSmartServerTest(HttpConnectionFactory cf) {
+ super(cf);
}
@Override
@@ -75,9 +76,6 @@ public class DumbClientSmartServerTest extends AllProtocolsHttpTestCase {
remoteRepository = src.getRepository();
remoteURI = toURIish(app, srcName);
- if (enableProtocolV2) {
- remoteRepository.getConfig().setInt("protocol", null, "version", 2);
- }
A_txt = src.blob("A");
A = src.commit().add("A_txt", A_txt).create();
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
index 3a43c6f4cf..597fb2e507 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017, 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
+ * Copyright (C) 2017 Thomas Wolf <thomas.wolf@paranor.ch> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -48,6 +48,7 @@ import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.Transport;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.util.HttpSupport;
import org.junit.Before;
import org.junit.Test;
@@ -55,7 +56,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
-public class SmartClientSmartServerSslTest extends AllProtocolsHttpTestCase {
+public class SmartClientSmartServerSslTest extends AllFactoriesHttpTestCase {
// We run these tests with a server on localhost with a self-signed
// certificate. We don't do authentication tests here, so there's no need
@@ -111,8 +112,8 @@ public class SmartClientSmartServerSslTest extends AllProtocolsHttpTestCase {
private RevCommit A, B;
- public SmartClientSmartServerSslTest(TestParameters params) {
- super(params);
+ public SmartClientSmartServerSslTest(HttpConnectionFactory cf) {
+ super(cf);
}
@Override
@@ -131,10 +132,6 @@ public class SmartClientSmartServerSslTest extends AllProtocolsHttpTestCase {
.getConfig()
.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true);
- if (enableProtocolV2) {
- src.getRepository().getConfig().setInt("protocol", null, "version",
- 2);
- }
GitServlet gs = new GitServlet();
@@ -241,7 +238,7 @@ public class SmartClientSmartServerSslTest extends AllProtocolsHttpTestCase {
fsck(dst, B);
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 3 : 2, requests.size());
+ assertEquals(2, requests.size());
}
@Test
@@ -259,7 +256,7 @@ public class SmartClientSmartServerSslTest extends AllProtocolsHttpTestCase {
fsck(dst, B);
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 4 : 3, requests.size());
+ assertEquals(3, requests.size());
}
@Test
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 9e88cefc69..8d1870a87e 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
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2020 Google Inc. and others
+ * Copyright (C) 2010, 2017 Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -86,12 +86,13 @@ import org.eclipse.jgit.transport.TransportHttp;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
+import org.eclipse.jgit.transport.http.HttpConnectionFactory;
import org.eclipse.jgit.util.HttpSupport;
import org.eclipse.jgit.util.SystemReader;
import org.junit.Before;
import org.junit.Test;
-public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
+public class SmartClientSmartServerTest extends AllFactoriesHttpTestCase {
private static final String HDR_TRANSFER_ENCODING = "Transfer-Encoding";
private AdvertiseRefsHook advertiseRefsHook;
@@ -119,8 +120,8 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
private RevCommit A, B, unreachableCommit;
- public SmartClientSmartServerTest(TestParameters params) {
- super(params);
+ public SmartClientSmartServerTest(HttpConnectionFactory cf) {
+ super(cf);
}
@Override
@@ -131,12 +132,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
final TestRepository<Repository> src = createTestRepository();
final String srcName = src.getRepository().getDirectory().getName();
src.getRepository()
- .getConfig().setBoolean(ConfigConstants.CONFIG_CORE_SECTION,
- null, ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES,
- true);
- if (enableProtocolV2) {
- src.getRepository().getConfig().setInt("protocol", null, "version", 2);
- }
+ .getConfig()
+ .setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_LOGALLREFUPDATES, true);
GitServlet gs = new GitServlet();
gs.setUploadPackFactory((HttpServletRequest req, Repository db) -> {
@@ -450,7 +448,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(B, map.get(Constants.HEAD).getObjectId());
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 2 : 1, requests.size());
+ assertEquals(1, requests.size());
AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
@@ -460,22 +458,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement", info
.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- } else {
- AccessEvent lsRefs = requests.get(1);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
}
@Test
@@ -593,10 +576,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 3 : 2, requests.size());
+ assertEquals(2, requests.size());
- int requestNumber = 0;
- AccessEvent info = requests.get(requestNumber++);
+ AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
assertEquals(join(remoteURI, "info/refs"), info.getPath());
assertEquals(1, info.getParameters().size());
@@ -604,24 +586,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement", info
.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- } else {
- AccessEvent lsRefs = requests.get(requestNumber++);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- AccessEvent service = requests.get(requestNumber);
+ AccessEvent service = requests.get(1);
assertEquals("POST", service.getMethod());
assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
assertEquals(0, service.getParameters().size());
@@ -661,8 +628,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals((enableProtocolV2 ? 3 : 2) + nofRedirects,
- requests.size());
+ assertEquals(2 + nofRedirects, requests.size());
int n = 0;
while (n < nofRedirects) {
@@ -678,22 +644,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- } else {
- AccessEvent lsRefs = requests.get(n++);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
AccessEvent service = requests.get(n++);
assertEquals("POST", service.getMethod());
@@ -805,7 +756,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 4 : 3, requests.size());
+ assertEquals(3, requests.size());
AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
@@ -815,27 +766,24 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
AccessEvent redirect = requests.get(1);
assertEquals("POST", redirect.getMethod());
assertEquals(301, redirect.getStatus());
- for (int i = 2; i < requests.size(); i++) {
- AccessEvent service = requests.get(i);
- assertEquals("POST", service.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
- assertEquals(0, service.getParameters().size());
- assertNotNull("has content-length",
- service.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- service.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals(200, service.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- service.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ AccessEvent service = requests.get(2);
+ assertEquals("POST", service.getMethod());
+ assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
+ assertEquals(0, service.getParameters().size());
+ assertNotNull("has content-length",
+ service.getRequestHeader(HDR_CONTENT_LENGTH));
+ assertNull("not chunked",
+ service.getRequestHeader(HDR_TRANSFER_ENCODING));
+
+ assertEquals(200, service.getStatus());
+ assertEquals("application/x-git-upload-pack-result",
+ service.getResponseHeader(HDR_CONTENT_TYPE));
}
@Test
@@ -882,7 +830,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 4 : 3, requests.size());
+ assertEquals(3, requests.size());
AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
@@ -896,24 +844,20 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- for (int i = 2; i < requests.size(); i++) {
- AccessEvent service = requests.get(i);
- assertEquals("POST", service.getMethod());
- assertEquals(join(authURI, "git-upload-pack"), service.getPath());
- assertEquals(0, service.getParameters().size());
- assertNotNull("has content-length",
- service.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- service.getRequestHeader(HDR_TRANSFER_ENCODING));
-
- assertEquals(200, service.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- service.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ AccessEvent service = requests.get(2);
+ assertEquals("POST", service.getMethod());
+ assertEquals(join(authURI, "git-upload-pack"), service.getPath());
+ assertEquals(0, service.getParameters().size());
+ assertNotNull("has content-length",
+ service.getRequestHeader(HDR_CONTENT_LENGTH));
+ assertNull("not chunked",
+ service.getRequestHeader(HDR_TRANSFER_ENCODING));
+
+ assertEquals(200, service.getStatus());
+ assertEquals("application/x-git-upload-pack-result",
+ service.getResponseHeader(HDR_CONTENT_TYPE));
}
@Test
@@ -993,20 +937,19 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 5 : 4, requests.size());
+ assertEquals(4, requests.size());
- int requestNumber = 0;
- AccessEvent redirect = requests.get(requestNumber++);
+ AccessEvent redirect = requests.get(0);
assertEquals("GET", redirect.getMethod());
assertEquals(join(cloneFrom, "info/refs"), redirect.getPath());
assertEquals(301, redirect.getStatus());
- AccessEvent info = requests.get(requestNumber++);
+ AccessEvent info = requests.get(1);
assertEquals("GET", info.getMethod());
assertEquals(join(authURI, "info/refs"), info.getPath());
assertEquals(401, info.getStatus());
- info = requests.get(requestNumber++);
+ info = requests.get(2);
assertEquals("GET", info.getMethod());
assertEquals(join(authURI, "info/refs"), info.getPath());
assertEquals(1, info.getParameters().size());
@@ -1014,24 +957,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- } else {
- AccessEvent lsRefs = requests.get(requestNumber++);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(authURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- AccessEvent service = requests.get(requestNumber);
+ AccessEvent service = requests.get(3);
assertEquals("POST", service.getMethod());
assertEquals(join(authURI, "git-upload-pack"), service.getPath());
assertEquals(0, service.getParameters().size());
@@ -1059,7 +987,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
}
List<AccessEvent> requests = getRequests();
- assertEquals(enableProtocolV2 ? 4 : 3, requests.size());
+ assertEquals(3, requests.size());
AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
@@ -1069,30 +997,25 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals(200, info.getStatus());
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (!enableProtocolV2) {
- assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
- }
+ assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING));
AccessEvent service = requests.get(1);
assertEquals("POST", service.getMethod());
assertEquals(join(authOnPostURI, "git-upload-pack"), service.getPath());
assertEquals(401, service.getStatus());
- for (int i = 2; i < requests.size(); i++) {
- service = requests.get(i);
- assertEquals("POST", service.getMethod());
- assertEquals(join(authOnPostURI, "git-upload-pack"),
- service.getPath());
- assertEquals(0, service.getParameters().size());
- assertNotNull("has content-length",
- service.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- service.getRequestHeader(HDR_TRANSFER_ENCODING));
-
- assertEquals(200, service.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- service.getResponseHeader(HDR_CONTENT_TYPE));
- }
+ service = requests.get(2);
+ assertEquals("POST", service.getMethod());
+ assertEquals(join(authOnPostURI, "git-upload-pack"), service.getPath());
+ assertEquals(0, service.getParameters().size());
+ assertNotNull("has content-length",
+ service.getRequestHeader(HDR_CONTENT_LENGTH));
+ assertNull("not chunked",
+ service.getRequestHeader(HDR_TRANSFER_ENCODING));
+
+ assertEquals(200, service.getStatus());
+ assertEquals("application/x-git-upload-pack-result",
+ service.getResponseHeader(HDR_CONTENT_TYPE));
}
@Test
@@ -1129,11 +1052,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
List<AccessEvent> requests = getRequests();
requests.removeAll(cloneRequests);
+ assertEquals(2, requests.size());
- assertEquals(enableProtocolV2 ? 3 : 2, requests.size());
-
- int requestNumber = 0;
- AccessEvent info = requests.get(requestNumber++);
+ AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
assertEquals(join(remoteURI, "info/refs"), info.getPath());
assertEquals(1, info.getParameters().size());
@@ -1142,24 +1063,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals("application/x-git-upload-pack-advertisement",
info.getResponseHeader(HDR_CONTENT_TYPE));
- if (enableProtocolV2) {
- AccessEvent lsRefs = requests.get(requestNumber++);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
-
// We should have needed one request to perform the fetch.
//
- AccessEvent service = requests.get(requestNumber);
+ AccessEvent service = requests.get(1);
assertEquals("POST", service.getMethod());
assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
assertEquals(0, service.getParameters().size());
@@ -1210,10 +1116,9 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
List<AccessEvent> requests = getRequests();
requests.removeAll(cloneRequests);
- assertEquals(enableProtocolV2 ? 4 : 3, requests.size());
+ assertEquals(3, requests.size());
- int requestNumber = 0;
- AccessEvent info = requests.get(requestNumber++);
+ AccessEvent info = requests.get(0);
assertEquals("GET", info.getMethod());
assertEquals(join(remoteURI, "info/refs"), info.getPath());
assertEquals(1, info.getParameters().size());
@@ -1222,25 +1127,10 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals("application/x-git-upload-pack-advertisement", info
.getResponseHeader(HDR_CONTENT_TYPE));
- if (enableProtocolV2) {
- AccessEvent lsRefs = requests.get(requestNumber++);
- assertEquals("POST", lsRefs.getMethod());
- assertEquals(join(remoteURI, "git-upload-pack"), lsRefs.getPath());
- assertEquals(0, lsRefs.getParameters().size());
- assertNotNull("has content-length",
- lsRefs.getRequestHeader(HDR_CONTENT_LENGTH));
- assertNull("not chunked",
- lsRefs.getRequestHeader(HDR_TRANSFER_ENCODING));
- assertEquals("version=2", lsRefs.getRequestHeader("Git-Protocol"));
- assertEquals(200, lsRefs.getStatus());
- assertEquals("application/x-git-upload-pack-result",
- lsRefs.getResponseHeader(HDR_CONTENT_TYPE));
- }
-
// We should have needed two requests to perform the fetch
// due to the high number of local unknown commits.
//
- AccessEvent service = requests.get(requestNumber++);
+ AccessEvent service = requests.get(1);
assertEquals("POST", service.getMethod());
assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
assertEquals(0, service.getParameters().size());
@@ -1253,7 +1143,7 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
assertEquals("application/x-git-upload-pack-result", service
.getResponseHeader(HDR_CONTENT_TYPE));
- service = requests.get(requestNumber);
+ service = requests.get(2);
assertEquals("POST", service.getMethod());
assertEquals(join(remoteURI, "git-upload-pack"), service.getPath());
assertEquals(0, service.getParameters().size());
@@ -1539,4 +1429,5 @@ public class SmartClientSmartServerTest extends AllProtocolsHttpTestCase {
cfg.setBoolean("http", null, "receivepack", true);
cfg.save();
}
+
}