|
|
|
@ -13,17 +13,17 @@
|
|
|
|
|
* conditions are met: |
|
|
|
|
* |
|
|
|
|
* - Redistributions of source code must retain the above copyright |
|
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
|
|
|
* |
|
|
|
|
* - Redistributions in binary form must reproduce the above |
|
|
|
|
* copyright notice, this list of conditions and the following |
|
|
|
|
* disclaimer in the documentation and/or other materials provided |
|
|
|
|
* with the distribution. |
|
|
|
|
* copyright notice, this list of conditions and the following |
|
|
|
|
* disclaimer in the documentation and/or other materials provided |
|
|
|
|
* with the distribution. |
|
|
|
|
* |
|
|
|
|
* - Neither the name of the Eclipse Foundation, Inc. nor the |
|
|
|
|
* names of its contributors may be used to endorse or promote |
|
|
|
|
* products derived from this software without specific prior |
|
|
|
|
* written permission. |
|
|
|
|
* names of its contributors may be used to endorse or promote |
|
|
|
|
* products derived from this software without specific prior |
|
|
|
|
* written permission. |
|
|
|
|
* |
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
|
|
@ -43,7 +43,9 @@
|
|
|
|
|
package org.eclipse.jgit.transport; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
import static org.junit.Assert.fail; |
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.PackProtocolException; |
|
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
@ -57,14 +59,34 @@ public class BaseReceivePackTest {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void parseCommand() { |
|
|
|
|
String input = "0000000000000000000000000000000000000000" |
|
|
|
|
+ " deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" |
|
|
|
|
+ " refs/heads/master"; |
|
|
|
|
ReceiveCommand cmd = BaseReceivePack.parseCommand(input); |
|
|
|
|
public void parseCommand() throws Exception { |
|
|
|
|
String o = "0000000000000000000000000000000000000000"; |
|
|
|
|
String n = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"; |
|
|
|
|
String r = "refs/heads/master"; |
|
|
|
|
ReceiveCommand cmd = BaseReceivePack.parseCommand(o + " " + n + " " + r); |
|
|
|
|
assertEquals(ObjectId.zeroId(), cmd.getOldId()); |
|
|
|
|
assertEquals("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef", |
|
|
|
|
cmd.getNewId().name()); |
|
|
|
|
assertEquals("refs/heads/master", cmd.getRefName()); |
|
|
|
|
|
|
|
|
|
assertParseCommandFails(null); |
|
|
|
|
assertParseCommandFails(""); |
|
|
|
|
assertParseCommandFails(o.substring(35) + " " + n.substring(35) |
|
|
|
|
+ " " + r + "\n"); |
|
|
|
|
assertParseCommandFails(o + " " + n + " " + r + "\n"); |
|
|
|
|
assertParseCommandFails(o + " " + n + " " + "refs^foo"); |
|
|
|
|
assertParseCommandFails(o + " " + n.substring(10) + " " + r); |
|
|
|
|
assertParseCommandFails(o.substring(10) + " " + n + " " + r); |
|
|
|
|
assertParseCommandFails("X" + o.substring(1) + " " + n + " " + r); |
|
|
|
|
assertParseCommandFails(o + " " + "X" + n.substring(1) + " " + r); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void assertParseCommandFails(String input) { |
|
|
|
|
try { |
|
|
|
|
BaseReceivePack.parseCommand(input); |
|
|
|
|
fail(); |
|
|
|
|
} catch (PackProtocolException e) { |
|
|
|
|
// Expected.
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|