summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2011-11-04 13:10:47 -0400
committerCode Review <codereview-daemon@eclipse.org>2011-11-04 13:10:47 -0400
commit1783c8a831f56802f97e7bb0dfb36cbdcaf1d688 (patch)
tree5fd0c4d8c019178c665e338b8c8a50f2fda865e3 /org.eclipse.jgit.test
parentede88c60a50db05717fcd65d326df59ba2f85c22 (diff)
parentafd4f3b0cf7aefa2e5988db1d81cb2c0f10efe10 (diff)
downloadjgit-1783c8a831f56802f97e7bb0dfb36cbdcaf1d688.tar.gz
jgit-1783c8a831f56802f97e7bb0dfb36cbdcaf1d688.zip
Merge "Allow '\' in user names in URI-ish"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
index 9b4ebf90d8..d797dd435e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
@@ -321,6 +321,22 @@ public class URIishTest {
}
@Test
+ public void testSshProtoWithADUserPassAndPort() throws Exception {
+ final String str = "ssh://DOMAIN\\user:pass@example.com:33/some/p ath";
+ URIish u = new URIish(str);
+ assertEquals("ssh", u.getScheme());
+ assertTrue(u.isRemote());
+ assertEquals("/some/p ath", u.getPath());
+ assertEquals("example.com", u.getHost());
+ assertEquals("DOMAIN\\user", u.getUser());
+ assertEquals("pass", u.getPass());
+ assertEquals(33, u.getPort());
+ assertEquals(str, u.toPrivateString());
+ assertEquals(u.setPass(null).toPrivateString(), u.toString());
+ assertEquals(u, new URIish(str));
+ }
+
+ @Test
public void testGitWithUserHome() throws Exception {
final String str = "git://example.com/~some/p ath";
URIish u = new URIish(str);
@@ -582,4 +598,54 @@ public class URIishTest {
URIish u = new URIish(incorrectSshUrl);
assertFalse(TransportGitSsh.PROTO_SSH.canHandle(u));
}
+
+ @Test
+ public void testALot() throws URISyntaxException {
+ // user pass host port path
+ // 1 2 3 4 5
+ String[][] tests = {
+ new String[] { "%1$s://%2$s:%3$s@%4$s:%5$s/%6$s", "%1$s",
+ "%2$s", "%3$s", "%4$s", "%5$s", "%6$s" },
+ new String[] { "%1$s://%2$s@%4$s:%5$s/%6$s", "%1$s", "%2$s",
+ null, "%4$s", "%5$s", "%6$s" },
+ new String[] { "%1$s://%2$s@%4$s/%6$s", "%1$s", "%2$s", null,
+ "%4$s", null, "%6$s" },
+ new String[] { "%1$s://%4$s/%6$s", "%1$s", null, null, "%4$s",
+ null, "%6$s" }, };
+ String[] schemes = new String[] { "ssh", "ssh+git", "http", "https" };
+ String[] users = new String[] { "me", "l usr\\example.com",
+ "lusr\\example" };
+ String[] passes = new String[] { "wtf", };
+ String[] hosts = new String[] { "example.com", "1.2.3.4" };
+ String[] ports = new String[] { "1234", "80" };
+ String[] paths = new String[] { "/", "/abc", "D:/x", "D:\\x" };
+ for (String[] test : tests) {
+ String fmt = test[0];
+ for (String scheme : schemes) {
+ for (String user : users) {
+ for (String pass : passes) {
+ for (String host : hosts) {
+ for (String port : ports) {
+ for (String path : paths) {
+ String url = String.format(fmt, scheme,
+ user, pass, host, port, path);
+ String[] expect = new String[test.length];
+ for (int i = 1; i < expect.length; ++i)
+ if (test[i] != null)
+ expect[i] = String.format(test[i],
+ scheme, user, pass, host,
+ port, path);
+ URIish urIish = new URIish(url);
+ assertEquals(url, expect[1],
+ urIish.getScheme());
+ assertEquals(url, expect[2],
+ urIish.getUser());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}