[JGIT PATCH] Add test for OpenSshConfig separator parsing
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
.../spearce/jgit/transport/OpenSshConfigTest.java | 22 ++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
Gilion Goudsmit <ggoudsmit@shebang.nl> 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@shebang.nl>
A small test for this bug and FWIW:
Tested-by: Jonas Fonseca <fonseca@diku.dk>
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