[JGIT PATCH] Add test for OpenSshConfig separator parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx>
---
 .../spearce/jgit/transport/OpenSshConfigTest.java  |   22 ++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

 Gilion Goudsmit <ggoudsmit@xxxxxxxxxx> wrote Sat, Sep 20, 2008:
 > Having only tab-characters separating a key and value in the
 > users ~/.ssh/config would cause the config-parser to fail with
 > a "String index out of range: -1" exception. Also simplified
 > the line parsing code my using a two argument split.
 > 
 > Signed-off-by: Gilion Goudsmit <ggoudsmit@xxxxxxxxxx>

 A small test for this bug and FWIW:

 Tested-by: Jonas Fonseca <fonseca@xxxxxxx>

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
index 959b6b7..927c350 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/OpenSshConfigTest.java
@@ -81,6 +81,28 @@ public void testNoConfig() {
 		assertNull(h.getIdentityFile());
 	}
 
+	public void testSeparatorParsing() throws Exception {
+		config("Host\tfirst\n" +
+		       "\tHostName\tfirst.tld\n" +
+		       "\n" +
+		       "Host second\n" +
+		       " HostName\tsecond.tld\n" +
+		       "Host=third\n" +
+		       "HostName=third.tld\n\n\n" +
+		       "\t Host = fourth\n\n\n" +
+		       " \t HostName\t=fourth.tld\n" +
+		       "Host\t =     last\n" +
+		       "HostName  \t    last.tld");
+		assertNotNull(osc.lookup("first"));
+		assertEquals("first.tld", osc.lookup("first").getHostName());
+		assertNotNull(osc.lookup("second"));
+		assertEquals("second.tld", osc.lookup("second").getHostName());
+		assertNotNull(osc.lookup("third"));
+		assertEquals("third.tld", osc.lookup("third").getHostName());
+		assertNotNull(osc.lookup("last"));
+		assertEquals("last.tld", osc.lookup("last").getHostName());
+	}
+
 	public void testAlias_DoesNotMatch() throws Exception {
 		config("Host orcz\n" + "\tHostName repo.or.cz\n");
 		final Host h = osc.lookup("repo.or.cz");
-- 
1.6.0.1.451.gc8d31


-- 
Jonas Fonseca
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux