Use new protocol version constants

Change-Id: Icd6b876e392c55a7322a990ac7f618250b732b4b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2020-11-30 16:44:05 +01:00
parent 180dfdefa4
commit 85ac3c5996
1 changed files with 25 additions and 13 deletions

View File

@ -437,8 +437,9 @@ private ByteArrayInputStream uploadPackV2(
Consumer<UploadPack> postConstructionSetup,
String... inputLines)
throws Exception {
ByteArrayInputStream recvStream =
uploadPackSetup("2", postConstructionSetup, inputLines);
ByteArrayInputStream recvStream = uploadPackSetup(
TransferConfig.ProtocolVersion.V2.version(),
postConstructionSetup, inputLines);
PacketLineIn pckIn = new PacketLineIn(recvStream);
// drain capabilities
@ -478,9 +479,11 @@ public void onFetch(FetchV2Request req) {
@Test
public void testV2Capabilities() throws Exception {
TestV2Hook hook = new TestV2Hook();
ByteArrayInputStream recvStream = uploadPackSetup( "2",
(UploadPack up) -> {up.setProtocolV2Hook(hook);},
PacketLineIn.end());
ByteArrayInputStream recvStream = uploadPackSetup(
TransferConfig.ProtocolVersion.V2.version(),
(UploadPack up) -> {
up.setProtocolV2Hook(hook);
}, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(hook.capabilitiesRequest, notNullValue());
assertThat(pckIn.readString(), is("version 2"));
@ -500,8 +503,9 @@ public void testV2Capabilities() throws Exception {
private void checkAdvertisedIfAllowed(String configSection, String configName,
String fetchCapability) throws Exception {
server.getConfig().setBoolean(configSection, null, configName, true);
ByteArrayInputStream recvStream =
uploadPackSetup("2", null, PacketLineIn.end());
ByteArrayInputStream recvStream = uploadPackSetup(
TransferConfig.ProtocolVersion.V2.version(), null,
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -524,8 +528,9 @@ private void checkAdvertisedIfAllowed(String configSection, String configName,
private void checkUnadvertisedIfUnallowed(String configSection,
String configName, String fetchCapability) throws Exception {
server.getConfig().setBoolean(configSection, null, configName, false);
ByteArrayInputStream recvStream =
uploadPackSetup("2", null, PacketLineIn.end());
ByteArrayInputStream recvStream = uploadPackSetup(
TransferConfig.ProtocolVersion.V2.version(), null,
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -576,8 +581,9 @@ public void testV2CapabilitiesAdvertiseSidebandAll() throws Exception {
public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() throws Exception {
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true);
server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false);
ByteArrayInputStream recvStream =
uploadPackSetup("2", null, PacketLineIn.end());
ByteArrayInputStream recvStream = uploadPackSetup(
TransferConfig.ProtocolVersion.V2.version(), null,
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -741,7 +747,10 @@ public void testV2LsRefsServerOptions() throws Exception {
PacketLineIn.end() };
TestV2Hook testHook = new TestV2Hook();
uploadPackSetup("2", (UploadPack up) -> {up.setProtocolV2Hook(testHook);}, lines);
uploadPackSetup(TransferConfig.ProtocolVersion.V2.version(),
(UploadPack up) -> {
up.setProtocolV2Hook(testHook);
}, lines);
LsRefsV2Request req = testHook.lsRefsRequest;
assertEquals(2, req.getServerOptions().size());
@ -1561,7 +1570,10 @@ public void testV2FetchServerOptions() throws Exception {
PacketLineIn.end() };
TestV2Hook testHook = new TestV2Hook();
uploadPackSetup("2", (UploadPack up) -> {up.setProtocolV2Hook(testHook);}, lines);
uploadPackSetup(TransferConfig.ProtocolVersion.V2.version(),
(UploadPack up) -> {
up.setProtocolV2Hook(testHook);
}, lines);
FetchV2Request req = testHook.fetchRequest;
assertNotNull(req);