aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2019-01-17 23:04:46 +0100
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-01-22 01:49:03 -0500
commit55966dc592b2e45596b8f041680b5e73f616b4ad (patch)
tree50630d20cae2d9f7d2478570bdc94e960c689add /org.eclipse.jgit.test/tst/org/eclipse
parent39b8f43dcd28b4f767d6ef0087810079b6563fee (diff)
downloadjgit-55966dc592b2e45596b8f041680b5e73f616b4ad.tar.gz
jgit-55966dc592b2e45596b8f041680b5e73f616b4ad.zip
Handle premature EOF in BundleFetchConnection
BundleFetchConnection.readLine() must abort on EOF, otherwise it gets stuck in an endless loop. Bug: 543390 Change-Id: I4cb3428560277888af114b928950d620bb6564f9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
index 7b31bfa3ad..dce9db572e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java
@@ -77,10 +77,38 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
public class BundleWriterTest extends SampleDataRepositoryTestCase {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testEmptyBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo, new byte[0]);
+ }
+
+ @Test
+ public void testNonBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo, "Not a bundle file".getBytes(UTF_8));
+ }
+
+ @Test
+ public void testGarbageBundleFails() throws Exception {
+ Repository newRepo = createBareRepository();
+ thrown.expect(TransportException.class);
+ fetchFromBundle(newRepo,
+ (TransportBundle.V2_BUNDLE_SIGNATURE + '\n' + "Garbage")
+ .getBytes(UTF_8));
+ }
+
@Test
public void testWriteSingleRef() throws Exception {
// Create a tiny bundle, (well one of) the first commits only