Use new protocol version constants
Change-Id: Icd6b876e392c55a7322a990ac7f618250b732b4b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
180dfdefa4
commit
85ac3c5996
|
@ -437,8 +437,9 @@ private ByteArrayInputStream uploadPackV2(
|
||||||
Consumer<UploadPack> postConstructionSetup,
|
Consumer<UploadPack> postConstructionSetup,
|
||||||
String... inputLines)
|
String... inputLines)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
ByteArrayInputStream recvStream =
|
ByteArrayInputStream recvStream = uploadPackSetup(
|
||||||
uploadPackSetup("2", postConstructionSetup, inputLines);
|
TransferConfig.ProtocolVersion.V2.version(),
|
||||||
|
postConstructionSetup, inputLines);
|
||||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
// drain capabilities
|
// drain capabilities
|
||||||
|
@ -478,9 +479,11 @@ public void onFetch(FetchV2Request req) {
|
||||||
@Test
|
@Test
|
||||||
public void testV2Capabilities() throws Exception {
|
public void testV2Capabilities() throws Exception {
|
||||||
TestV2Hook hook = new TestV2Hook();
|
TestV2Hook hook = new TestV2Hook();
|
||||||
ByteArrayInputStream recvStream = uploadPackSetup( "2",
|
ByteArrayInputStream recvStream = uploadPackSetup(
|
||||||
(UploadPack up) -> {up.setProtocolV2Hook(hook);},
|
TransferConfig.ProtocolVersion.V2.version(),
|
||||||
PacketLineIn.end());
|
(UploadPack up) -> {
|
||||||
|
up.setProtocolV2Hook(hook);
|
||||||
|
}, PacketLineIn.end());
|
||||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
assertThat(hook.capabilitiesRequest, notNullValue());
|
assertThat(hook.capabilitiesRequest, notNullValue());
|
||||||
assertThat(pckIn.readString(), is("version 2"));
|
assertThat(pckIn.readString(), is("version 2"));
|
||||||
|
@ -500,8 +503,9 @@ public void testV2Capabilities() throws Exception {
|
||||||
private void checkAdvertisedIfAllowed(String configSection, String configName,
|
private void checkAdvertisedIfAllowed(String configSection, String configName,
|
||||||
String fetchCapability) throws Exception {
|
String fetchCapability) throws Exception {
|
||||||
server.getConfig().setBoolean(configSection, null, configName, true);
|
server.getConfig().setBoolean(configSection, null, configName, true);
|
||||||
ByteArrayInputStream recvStream =
|
ByteArrayInputStream recvStream = uploadPackSetup(
|
||||||
uploadPackSetup("2", null, PacketLineIn.end());
|
TransferConfig.ProtocolVersion.V2.version(), null,
|
||||||
|
PacketLineIn.end());
|
||||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
assertThat(pckIn.readString(), is("version 2"));
|
assertThat(pckIn.readString(), is("version 2"));
|
||||||
|
@ -524,8 +528,9 @@ private void checkAdvertisedIfAllowed(String configSection, String configName,
|
||||||
private void checkUnadvertisedIfUnallowed(String configSection,
|
private void checkUnadvertisedIfUnallowed(String configSection,
|
||||||
String configName, String fetchCapability) throws Exception {
|
String configName, String fetchCapability) throws Exception {
|
||||||
server.getConfig().setBoolean(configSection, null, configName, false);
|
server.getConfig().setBoolean(configSection, null, configName, false);
|
||||||
ByteArrayInputStream recvStream =
|
ByteArrayInputStream recvStream = uploadPackSetup(
|
||||||
uploadPackSetup("2", null, PacketLineIn.end());
|
TransferConfig.ProtocolVersion.V2.version(), null,
|
||||||
|
PacketLineIn.end());
|
||||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
assertThat(pckIn.readString(), is("version 2"));
|
assertThat(pckIn.readString(), is("version 2"));
|
||||||
|
@ -576,8 +581,9 @@ public void testV2CapabilitiesAdvertiseSidebandAll() throws Exception {
|
||||||
public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() throws Exception {
|
public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() throws Exception {
|
||||||
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true);
|
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true);
|
||||||
server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false);
|
server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false);
|
||||||
ByteArrayInputStream recvStream =
|
ByteArrayInputStream recvStream = uploadPackSetup(
|
||||||
uploadPackSetup("2", null, PacketLineIn.end());
|
TransferConfig.ProtocolVersion.V2.version(), null,
|
||||||
|
PacketLineIn.end());
|
||||||
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
assertThat(pckIn.readString(), is("version 2"));
|
assertThat(pckIn.readString(), is("version 2"));
|
||||||
|
@ -741,7 +747,10 @@ public void testV2LsRefsServerOptions() throws Exception {
|
||||||
PacketLineIn.end() };
|
PacketLineIn.end() };
|
||||||
|
|
||||||
TestV2Hook testHook = new TestV2Hook();
|
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;
|
LsRefsV2Request req = testHook.lsRefsRequest;
|
||||||
assertEquals(2, req.getServerOptions().size());
|
assertEquals(2, req.getServerOptions().size());
|
||||||
|
@ -1561,7 +1570,10 @@ public void testV2FetchServerOptions() throws Exception {
|
||||||
PacketLineIn.end() };
|
PacketLineIn.end() };
|
||||||
|
|
||||||
TestV2Hook testHook = new TestV2Hook();
|
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;
|
FetchV2Request req = testHook.fetchRequest;
|
||||||
assertNotNull(req);
|
assertNotNull(req);
|
||||||
|
|
Loading…
Reference in New Issue