diff options
author | Dave Borowitz <dborowitz@google.com> | 2015-07-01 11:44:09 -0700 |
---|---|---|
committer | Dave Borowitz <dborowitz@google.com> | 2015-07-09 11:05:45 -0700 |
commit | 8293c770b5289eb89753a319c3c22217627200a0 (patch) | |
tree | 7c8383c1b83f548134d64fdf9fc919bafe197399 /org.eclipse.jgit.test | |
parent | f22f33f5bfbfb616a59006ac7bcb3810fdac4619 (diff) | |
download | jgit-8293c770b5289eb89753a319c3c22217627200a0.tar.gz jgit-8293c770b5289eb89753a319c3c22217627200a0.zip |
PushCertificateParser: Make pushee optional
When pushing to an HTTP server using the C git client, I observed a
certificate lacking a pushee field. Handle this gracefully in the
parser.
Change-Id: I7f3c5fa78f2e35172a93180036e679687415cac4
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java index 26b4d88f5f..3a4b00d876 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java @@ -334,6 +334,26 @@ public class PushCertificateParserTest { assertNull(PushCertificateParser.fromReader(reader)); } + @Test + public void testMissingPusheeField() throws Exception { + // Omit pushee line from existing cert. (This means the signature would not + // match, but we're not verifying it here.) + String input = INPUT.replace("0024pushee git://localhost/repo.git\n", ""); + assertFalse(input.contains(PushCertificateParser.PUSHEE)); + + PacketLineIn pckIn = newPacketLineIn(input); + PushCertificateParser parser = + new PushCertificateParser(db, newEnabledConfig()); + parser.receiveHeader(pckIn, false); + parser.addCommand(pckIn.readString()); + assertEquals(PushCertificateParser.BEGIN_SIGNATURE, pckIn.readString()); + parser.receiveSignature(pckIn); + + PushCertificate cert = parser.build(); + assertEquals("0.1", cert.getVersion()); + assertNull(cert.getPushee()); + } + private static String concatPacketLines(String input, int begin, int end) throws IOException { StringBuilder result = new StringBuilder(); |