예제 #1
0
 //$NON-NLS-1$
 public override bool CanHandle(URIish uri, Repository local, string remoteName)
 {
     if (uri.GetPath() == null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
             () != null || uri.GetHost() != null || (uri.GetScheme() != null && !this.GetSchemes
                                                         ().Contains(uri.GetScheme())))
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
			public override bool CanHandle(URIish uri, Repository local, string remoteName)
			{
				if (uri.GetPath() == null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
					() != null || uri.GetHost() != null || (uri.GetScheme() != null && !this.GetSchemes
					().Contains(uri.GetScheme())))
				{
					return false;
				}
				return true;
			}
예제 #3
0
 internal static bool CanHandle(URIish uri, FS fs)
 {
     if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
             () != null || uri.GetPath() == null)
     {
         return(false);
     }
     if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
     {
         return(fs.Resolve(new FilePath(PWD), uri.GetPath()).IsDirectory());
     }
     return(false);
 }
		internal static bool CanHandle(URIish uri, FS fs)
		{
			if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
				() != null || uri.GetPath() == null)
			{
				return false;
			}
			if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
			{
				FilePath f = fs.Resolve(new FilePath("."), uri.GetPath());
				return f.IsFile() || f.GetName().EndsWith(".bundle");
			}
			return false;
		}
예제 #5
0
 internal static bool CanHandle(URIish uri, FS fs)
 {
     if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
             () != null || uri.GetPath() == null)
     {
         return(false);
     }
     if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
     {
         FilePath f = fs.Resolve(new FilePath("."), uri.GetPath());
         return(f.IsFile() || f.GetName().EndsWith(".bundle"));
     }
     return(false);
 }
예제 #6
0
        internal static bool CanHandle(URIish uri)
        {
            if (!uri.IsRemote())
            {
                return(false);
            }
            string scheme = uri.GetScheme();

            if ("ssh".Equals(scheme))
            {
                return(true);
            }
            if ("ssh+git".Equals(scheme))
            {
                return(true);
            }
            if ("git+ssh".Equals(scheme))
            {
                return(true);
            }
            if (scheme == null && uri.GetHost() != null && uri.GetPath() != null)
            {
                return(true);
            }
            return(false);
        }
예제 #7
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestFileProtocol()
        {
            // as defined by git docu
            URIish u = new URIish("file:///a/b.txt");

            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.IsNull(u.GetHost());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.IsNull(u.GetUser());
            NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
            FilePath tmp = FilePath.CreateTempFile("jgitUnitTest", ".tmp");

            u = new URIish(tmp.ToURI().ToString());
            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.IsNull(u.GetHost());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.IsTrue(u.GetPath().Contains("jgitUnitTest"));
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.IsNull(u.GetUser());
            NUnit.Framework.Assert.IsTrue(u.GetHumanishName().StartsWith("jgitUnitTest"));
            u = new URIish("file:/a/b.txt");
            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.IsNull(u.GetHost());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.IsNull(u.GetUser());
            NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
        }
예제 #8
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestFileProtocol()
 {
     // as defined by git docu
     URIish u = new URIish("file:///a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
     FilePath tmp = FilePath.CreateTempFile("jgitUnitTest", ".tmp");
     u = new URIish(tmp.ToURI().ToString());
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.IsTrue(u.GetPath().Contains("jgitUnitTest"));
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsTrue(u.GetHumanishName().StartsWith("jgitUnitTest"));
     u = new URIish("file:/a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
 }
        public virtual void TestGetSet()
        {
            string str = "ssh://DOMAIN\\user:[email protected]:33/some/p ath%20";
            URIish u   = new URIish(str);

            u = u.SetHost(u.GetHost());
            u = u.SetPass(u.GetPass());
            u = u.SetPort(u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            u = u.SetRawPath(u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath%20", u.GetRawPath());
            u = u.SetPath(u.GetPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("DOMAIN\\user", u.GetUser());
            NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p ath "
                                            , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p%20ath%20"
                                            , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                                                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestUserPasswordAndPort()
        {
            string str = "http://*****:*****@host.xy:80/some/path";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("http", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/path", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/path", u.GetPath());
            NUnit.Framework.Assert.AreEqual("host.xy", u.GetHost());
            NUnit.Framework.Assert.AreEqual(80, u.GetPort());
            NUnit.Framework.Assert.AreEqual("user", u.GetUser());
            NUnit.Framework.Assert.AreEqual("secret", u.GetPass());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
            str = "http://*****:*****@[email protected]:80/some/path";
            u   = new URIish(str);
            NUnit.Framework.Assert.AreEqual("http", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/path", u.GetPath());
            NUnit.Framework.Assert.AreEqual("host.xy", u.GetHost());
            NUnit.Framework.Assert.AreEqual(80, u.GetPort());
            NUnit.Framework.Assert.AreEqual("user", u.GetUser());
            NUnit.Framework.Assert.AreEqual("secret@pass", u.GetPass());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #11
0
		internal static bool CanHandle(URIish uri)
		{
			if (!uri.IsRemote())
			{
				return false;
			}
			string scheme = uri.GetScheme();
			if ("ssh".Equals(scheme))
			{
				return true;
			}
			if ("ssh+git".Equals(scheme))
			{
				return true;
			}
			if ("git+ssh".Equals(scheme))
			{
				return true;
			}
			if (scheme == null && uri.GetHost() != null && uri.GetPath() != null)
			{
				return true;
			}
			return false;
		}
예제 #12
0
 internal static bool CanHandle(URIish uri)
 {
     if (!uri.IsRemote())
     {
         return(false);
     }
     return(S3_SCHEME.Equals(uri.GetScheme()));
 }
예제 #13
0
 public override bool CanHandle(URIish uri, Repository local, string remoteName)
 {
     if (uri.GetScheme() == null)
     {
         // scp-style URI "host:path" does not have scheme.
         return(uri.GetHost() != null && uri.GetPath() != null && uri.GetHost().Length !=
                0 && uri.GetPath().Length != 0);
     }
     return(base.CanHandle(uri, local, remoteName));
 }
예제 #14
0
        //$NON-NLS-1$
        //$NON-NLS-1$
        internal static bool CanHandle(URIish uri)
        {
            if (!uri.IsRemote())
            {
                return(false);
            }
            string s = uri.GetScheme();

            return("http".Equals(s) || "https".Equals(s) || "ftp".Equals(s));
        }
예제 #15
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestWindowsFile2()
        {
            string str = "D:\\m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual("D:/m y", u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #16
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestRelativePath()
        {
            string str = "../../foo/bar";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual(str, u.GetPath());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #17
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestFileProtoWindows()
        {
            string str = "file:///D:/m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #18
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestUNC()
        {
            string str = "\\\\some\\place";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("//some/place", u.GetPath());
            NUnit.Framework.Assert.AreEqual("//some/place", u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #19
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestUnixFile()
        {
            string str = "/home/m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual(str, u.GetPath());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #20
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestGitProtoUnix()
        {
            string str = "git://example.com/home/m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("/home/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #21
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestSshProto()
        {
            string str = "ssh://example.com/some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #22
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestScpStyleWithoutUserAbsolutePath()
        {
            string str = "example.com:/some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestFileProtoUnix()
        {
            string str = "file:///home/m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/home/m y", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/home/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual("file:///home/m y", u.ToString());
            NUnit.Framework.Assert.AreEqual("file:///home/m%20y", u.ToASCIIString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestURIEncode_unicode()
        {
            string str = "file:///home/m%c3%a5y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/home/m%c3%a5y", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/home/m\u00e5y", u.GetPath());
            NUnit.Framework.Assert.AreEqual("file:///home/m%c3%a5y", u.ToString());
            NUnit.Framework.Assert.AreEqual("file:///home/m%c3%a5y", u.ToASCIIString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestGitProtoWindows()
        {
            string str = "git://example.com/D:/m y";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("D:/m y", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual("git://example.com/D:/m y", u.ToString());
            NUnit.Framework.Assert.AreEqual("git://example.com/D:/m%20y", u.ToASCIIString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #26
0
 /// <exception cref="System.NotSupportedException"></exception>
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public override NGit.Transport.Transport Open(URIish uri, Repository local, string
                                               remoteName)
 {
     if ("bundle".Equals(uri.GetScheme()))
     {
         FilePath path = local.FileSystem.Resolve(new FilePath("."), uri.GetPath());
         return(new NGit.Transport.TransportBundleFile(local, uri, path));
     }
     // This is an ambiguous reference, it could be a bundle file
     // or it could be a Git repository. Allow TransportLocal to
     // resolve the path and figure out which type it is by testing
     // the target.
     //
     return(TransportLocal.PROTO_LOCAL.Open(uri, local, remoteName));
 }
예제 #27
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestSshProtoWithUserAndPort()
        {
            string str = "ssh://[email protected]:33/some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("user", u.GetUser());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestScpStyleNoURIDecoding()
        {
            string str = "example.com:some/p%20ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("some/p%20ath", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("some/p%20ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToString());
            NUnit.Framework.Assert.AreEqual(str, u.ToASCIIString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #29
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestFileWithNoneUserHomeWithTilde()
        {
            string str = "/~some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.IsNull(u.GetScheme());
            NUnit.Framework.Assert.IsFalse(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/~some/p ath", u.GetPath());
            NUnit.Framework.Assert.IsNull(u.GetHost());
            NUnit.Framework.Assert.IsNull(u.GetUser());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #30
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestGitWithUserHome()
        {
            string str = "git://example.com/~some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("~some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.IsNull(u.GetUser());
            NUnit.Framework.Assert.IsNull(u.GetPass());
            NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
            NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestURIEncodeDecode()
        {
            string str = "ssh://%3ax%25:%40%[email protected]:33/some%c3%a5/p%20a th";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some%c3%a5/p%20a th", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some\u00e5/p a th", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual(":x%", u.GetUser());
            NUnit.Framework.Assert.AreEqual("@Ax", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a th"
                                            , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a%20th"
                                            , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                                                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
        public virtual void TestSshProtoWithEscapedADUserPassAndPort()
        {
            string str = "ssh://DOMAIN%5c\u00fcser:[email protected]:33/some/p ath";
            URIish u   = new URIish(str);

            NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
            NUnit.Framework.Assert.IsTrue(u.IsRemote());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
            NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
            NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
            NUnit.Framework.Assert.AreEqual("DOMAIN\\\u00fcser", u.GetUser());
            NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
            NUnit.Framework.Assert.AreEqual(33, u.GetPort());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\\u00fcser:[email protected]:33/some/p ath"
                                            , u.ToPrivateString());
            NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\%c3%bcser:[email protected]:33/some/p%20ath"
                                            , u.ToPrivateASCIIString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
            NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
                                                ());
            NUnit.Framework.Assert.AreEqual(u, new URIish(str));
        }
예제 #33
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestFileProtoWindows()
 {
     string str = "file:///D:/m y";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #34
0
			public override bool CanHandle(URIish uri, Repository local, string remoteName)
			{
				if (uri.GetScheme() == null)
				{
					// scp-style URI "host:path" does not have scheme.
					return uri.GetHost() != null && uri.GetPath() != null && uri.GetHost().Length != 
						0 && uri.GetPath().Length != 0;
				}
				return base.CanHandle(uri, local, remoteName);
			}
예제 #35
0
        /// <summary>Determine if this protocol can handle a particular URI.</summary>
        /// <remarks>
        /// Determine if this protocol can handle a particular URI.
        /// <p/>
        /// Implementations should try to avoid looking at the local filesystem, but
        /// may look at implementation specific configuration options in the remote
        /// block of
        /// <code>local.getConfig()</code>
        /// using
        /// <code>remoteName</code>
        /// if the name
        /// is non-null.
        /// <p/>
        /// The default implementation of this method matches the scheme against
        /// <see cref="GetSchemes()">GetSchemes()</see>
        /// , required fields against
        /// <see cref="GetRequiredFields()">GetRequiredFields()</see>
        /// , and optional fields against
        /// <see cref="GetOptionalFields()">GetOptionalFields()</see>
        /// , returning true only if all of the fields
        /// match the specification.
        /// </remarks>
        /// <param name="uri">address of the Git repository; never null.</param>
        /// <param name="local">
        /// the local repository that will communicate with the other Git
        /// repository. May be null if the caller is only asking about a
        /// specific URI and does not have a local Repository.
        /// </param>
        /// <param name="remoteName">
        /// name of the remote, if the remote as configured in
        /// <code>local</code>
        /// ; otherwise null.
        /// </param>
        /// <returns>true if this protocol can handle this URI; false otherwise.</returns>
        public virtual bool CanHandle(URIish uri, Repository local, string remoteName)
        {
            if (!GetSchemes().IsEmpty() && !GetSchemes().Contains(uri.GetScheme()))
            {
                return false;
            }
            foreach (TransportProtocol.URIishField field in GetRequiredFields())
            {
                switch (field)
                {
                    case TransportProtocol.URIishField.USER:
                    {
                        if (uri.GetUser() == null || uri.GetUser().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PASS:
                    {
                        if (uri.GetPass() == null || uri.GetPass().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.HOST:
                    {
                        if (uri.GetHost() == null || uri.GetHost().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PORT:
                    {
                        if (uri.GetPort() <= 0)
                        {
                            return false;
                        }
                        break;
                    }

                    case TransportProtocol.URIishField.PATH:
                    {
                        if (uri.GetPath() == null || uri.GetPath().Length == 0)
                        {
                            return false;
                        }
                        break;
                    }

                    default:
                    {
                        return false;
                        break;
                    }
                }
            }
            ICollection<TransportProtocol.URIishField> canHave = EnumSet.CopyOf(GetRequiredFields
                ());
            Sharpen.Collections.AddAll(canHave, GetOptionalFields());
            if (uri.GetUser() != null && !canHave.Contains(TransportProtocol.URIishField.USER
                ))
            {
                return false;
            }
            if (uri.GetPass() != null && !canHave.Contains(TransportProtocol.URIishField.PASS
                ))
            {
                return false;
            }
            if (uri.GetHost() != null && !canHave.Contains(TransportProtocol.URIishField.HOST
                ))
            {
                return false;
            }
            if (uri.GetPort() > 0 && !canHave.Contains(TransportProtocol.URIishField.PORT))
            {
                return false;
            }
            if (uri.GetPath() != null && !canHave.Contains(TransportProtocol.URIishField.PATH
                ))
            {
                return false;
            }
            return true;
        }
예제 #36
0
		internal static bool CanHandle(URIish uri)
		{
			return "git".Equals(uri.GetScheme());
		}
예제 #37
0
		public virtual void TestGetSet()
		{
			string str = "ssh://DOMAIN\\user:[email protected]:33/some/p ath%20";
			URIish u = new URIish(str);
			u = u.SetHost(u.GetHost());
			u = u.SetPass(u.GetPass());
			u = u.SetPort(u.GetPort());
			NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			u = u.SetRawPath(u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath%20", u.GetRawPath());
			u = u.SetPath(u.GetPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath ", u.GetPath());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual("DOMAIN\\user", u.GetUser());
			NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
			NUnit.Framework.Assert.AreEqual(33, u.GetPort());
			NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p ath "
				, u.ToPrivateString());
			NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\user:[email protected]:33/some/p%20ath%20"
				, u.ToPrivateASCIIString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
				());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
        public virtual void TestALot()
        {
            // user pass host port path
            // 1 2 3 4 5
            string[][] tests = new string[][] { 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" } };

            for (int i = 0; i < tests.Length; i++)
            {
                for (int j = 0; j < tests [i].Length; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        if (tests[i][j] != null)
                        {
                            tests [i][j] = tests[i][j].Replace("%" + k + "$s", "{" + (k - 1) + "}");
                        }
                    }
                }
            }

            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" };
            foreach (string[] test in tests)
            {
                string fmt = test[0];
                foreach (string scheme in schemes)
                {
                    foreach (string user in users)
                    {
                        foreach (string pass in passes)
                        {
                            foreach (string host in hosts)
                            {
                                foreach (string port in ports)
                                {
                                    foreach (string path in 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);
                                        NUnit.Framework.Assert.AreEqual(expect[1], urIish.GetScheme(), url);
                                        NUnit.Framework.Assert.AreEqual(expect[2], urIish.GetUser(), url);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #39
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestUserPasswordAndPort()
 {
     string str = "http://*****:*****@host.xy:80/some/path";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("http", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/path", u.GetPath());
     NUnit.Framework.Assert.AreEqual("host.xy", u.GetHost());
     NUnit.Framework.Assert.AreEqual(80, u.GetPort());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("secret", u.GetPass());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
     str = "http://*****:*****@[email protected]:80/some/path";
     u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("http", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/path", u.GetPath());
     NUnit.Framework.Assert.AreEqual("host.xy", u.GetHost());
     NUnit.Framework.Assert.AreEqual(80, u.GetPort());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("secret@pass", u.GetPass());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #40
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestUNC()
 {
     string str = "\\\\some\\place";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("\\\\some\\place", u.GetPath());
     NUnit.Framework.Assert.AreEqual("\\\\some\\place", u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #41
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestUnixFile()
 {
     string str = "/home/m y";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual(str, u.GetPath());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #42
0
			/// <exception cref="System.NotSupportedException"></exception>
			/// <exception cref="NGit.Errors.TransportException"></exception>
			public override NGit.Transport.Transport Open(URIish uri, Repository local, string
				 remoteName)
			{
				if ("bundle".Equals(uri.GetScheme()))
				{
					FilePath path = local.FileSystem.Resolve(new FilePath("."), uri.GetPath());
					return new NGit.Transport.TransportBundleFile(local, uri, path);
				}
				// This is an ambiguous reference, it could be a bundle file
				// or it could be a Git repository. Allow TransportLocal to
				// resolve the path and figure out which type it is by testing
				// the target.
				//
				return TransportLocal.PROTO_LOCAL.Open(uri, local, remoteName);
			}
예제 #43
0
		public virtual void TestURIEncode_unicode()
		{
			string str = "file:///home/m%c3%a5y";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
			NUnit.Framework.Assert.IsFalse(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("/home/m%c3%a5y", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/home/m\u00e5y", u.GetPath());
			NUnit.Framework.Assert.AreEqual("file:///home/m%c3%a5y", u.ToString());
			NUnit.Framework.Assert.AreEqual("file:///home/m%c3%a5y", u.ToASCIIString());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #44
0
		public virtual void TestScpStyleWithoutUserAbsolutePath()
		{
			string str = "example.com:/some/p ath";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.IsNull(u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
			NUnit.Framework.Assert.AreEqual(str, u.ToString());
			NUnit.Framework.Assert.AreEqual(str, u.ToASCIIString());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #45
0
 internal static bool CanHandle(URIish uri, FS fs)
 {
     if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
         () != null || uri.GetPath() == null)
     {
         return false;
     }
     if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
     {
         return fs.Resolve(new FilePath(PWD), uri.GetPath()).IsDirectory();
     }
     return false;
 }
예제 #46
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestWindowsFile2()
 {
     string str = "D:\\m y";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("D:\\m y", u.GetPath());
     NUnit.Framework.Assert.AreEqual("D:\\m y", u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #47
0
		public virtual void TestALot()
		{
			// user pass host port path
			// 1 2 3 4 5
			string[][] tests = new string[][] { 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" } };
			
			for (int i = 0; i < tests.Length; i++) {
				for (int j = 0; j < tests [i].Length; j++) {
					for (int k = 0; k < 10; k++) {
						if (tests[i][j] != null)
							tests [i][j] = tests[i][j].Replace ("%" + k + "$s", "{" + (k - 1) + "}");
					}
				}
			}
			
			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" };
			foreach (string[] test in tests)
			{
				string fmt = test[0];
				foreach (string scheme in schemes)
				{
					foreach (string user in users)
					{
						foreach (string pass in passes)
						{
							foreach (string host in hosts)
							{
								foreach (string port in ports)
								{
									foreach (string path in 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);
										NUnit.Framework.Assert.AreEqual(expect[1], urIish.GetScheme(), url);
										NUnit.Framework.Assert.AreEqual(expect[2], urIish.GetUser(), url);
									}
								}
							}
						}
					}
				}
			}
		}
예제 #48
0
		public virtual void TestURIEncodeDecode()
		{
			string str = "ssh://%3ax%25:%40%[email protected]:33/some%c3%a5/p%20a th";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("/some%c3%a5/p%20a th", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some\u00e5/p a th", u.GetPath());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual(":x%", u.GetUser());
			NUnit.Framework.Assert.AreEqual("@Ax", u.GetPass());
			NUnit.Framework.Assert.AreEqual(33, u.GetPort());
			NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a th"
				, u.ToPrivateString());
			NUnit.Framework.Assert.AreEqual("ssh://%3ax%25:%[email protected]:33/some%c3%a5/p%20a%20th"
				, u.ToPrivateASCIIString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
				());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #49
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestGitWithUserHome()
 {
     string str = "git://example.com/~some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("~some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
     NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #50
0
		public virtual void TestSshProtoWithEscapedADUserPassAndPort()
		{
			string str = "ssh://DOMAIN%5c\u00fcser:[email protected]:33/some/p ath";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual("DOMAIN\\\u00fcser", u.GetUser());
			NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
			NUnit.Framework.Assert.AreEqual(33, u.GetPort());
			NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\\u00fcser:[email protected]:33/some/p ath"
				, u.ToPrivateString());
			NUnit.Framework.Assert.AreEqual("ssh://DOMAIN\\%c3%bcser:[email protected]:33/some/p%20ath"
				, u.ToPrivateASCIIString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
			NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateASCIIString(), u.ToASCIIString
				());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #51
0
		public virtual void TestSshProtoWithUserAndPort()
		{
			string str = "ssh://[email protected]:33/some/p ath";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual("user", u.GetUser());
			NUnit.Framework.Assert.IsNull(u.GetPass());
			NUnit.Framework.Assert.AreEqual(33, u.GetPort());
			NUnit.Framework.Assert.AreEqual("ssh://[email protected]:33/some/p ath", u.ToString
				());
			NUnit.Framework.Assert.AreEqual("ssh://[email protected]:33/some/p%20ath", u.ToASCIIString
				());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #52
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestRelativePath()
 {
     string str = "../../foo/bar";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual(str, u.GetPath());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #53
0
		internal static bool CanHandle(URIish uri)
		{
			if (!uri.IsRemote())
			{
				return false;
			}
			return S3_SCHEME.Equals(uri.GetScheme());
		}
예제 #54
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestScpStyleWithUser()
 {
     string str = "[email protected]:some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #55
0
		public virtual void TestGitProtoUnixPort()
		{
			string str = "git://example.com:333/home/m y";
			URIish u = new URIish(str);
			NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
			NUnit.Framework.Assert.IsTrue(u.IsRemote());
			NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
			NUnit.Framework.Assert.AreEqual("/home/m y", u.GetRawPath());
			NUnit.Framework.Assert.AreEqual("/home/m y", u.GetPath());
			NUnit.Framework.Assert.AreEqual(333, u.GetPort());
			NUnit.Framework.Assert.AreEqual("git://example.com:333/home/m y", u.ToString());
			NUnit.Framework.Assert.AreEqual("git://example.com:333/home/m%20y", u.ToASCIIString
				());
			NUnit.Framework.Assert.AreEqual(u, new URIish(str));
		}
예제 #56
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestSshProto()
 {
     string str = "ssh://example.com/some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #57
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestFileWithNoneUserHomeWithTilde()
 {
     string str = "/~some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.IsNull(u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/~some/p ath", u.GetPath());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
     NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #58
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestSshProtoWithUserPassAndPort()
 {
     string str = "ssh://*****:*****@example.com:33/some/p ath";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("ssh", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("/some/p ath", u.GetPath());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual("user", u.GetUser());
     NUnit.Framework.Assert.AreEqual("pass", u.GetPass());
     NUnit.Framework.Assert.AreEqual(33, u.GetPort());
     NUnit.Framework.Assert.AreEqual(str, u.ToPrivateString());
     NUnit.Framework.Assert.AreEqual(u.SetPass(null).ToPrivateString(), u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }
예제 #59
0
        /// <summary>Determine if this protocol can handle a particular URI.</summary>
        /// <remarks>
        /// Determine if this protocol can handle a particular URI.
        /// <p>
        /// Implementations should try to avoid looking at the local filesystem, but
        /// may look at implementation specific configuration options in the remote
        /// block of
        /// <code>local.getConfig()</code>
        /// using
        /// <code>remoteName</code>
        /// if the name
        /// is non-null.
        /// <p>
        /// The default implementation of this method matches the scheme against
        /// <see cref="GetSchemes()">GetSchemes()</see>
        /// , required fields against
        /// <see cref="GetRequiredFields()">GetRequiredFields()</see>
        /// , and optional fields against
        /// <see cref="GetOptionalFields()">GetOptionalFields()</see>
        /// , returning true only if all of the fields
        /// match the specification.
        /// </remarks>
        /// <param name="uri">address of the Git repository; never null.</param>
        /// <param name="local">
        /// the local repository that will communicate with the other Git
        /// repository. May be null if the caller is only asking about a
        /// specific URI and does not have a local Repository.
        /// </param>
        /// <param name="remoteName">
        /// name of the remote, if the remote as configured in
        /// <code>local</code>
        /// ; otherwise null.
        /// </param>
        /// <returns>true if this protocol can handle this URI; false otherwise.</returns>
        public virtual bool CanHandle(URIish uri, Repository local, string remoteName)
        {
            if (!GetSchemes().IsEmpty() && !GetSchemes().Contains(uri.GetScheme()))
            {
                return(false);
            }
            foreach (TransportProtocol.URIishField field in GetRequiredFields())
            {
                switch (field)
                {
                case TransportProtocol.URIishField.USER:
                {
                    if (uri.GetUser() == null || uri.GetUser().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PASS:
                {
                    if (uri.GetPass() == null || uri.GetPass().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.HOST:
                {
                    if (uri.GetHost() == null || uri.GetHost().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PORT:
                {
                    if (uri.GetPort() <= 0)
                    {
                        return(false);
                    }
                    break;
                }

                case TransportProtocol.URIishField.PATH:
                {
                    if (uri.GetPath() == null || uri.GetPath().Length == 0)
                    {
                        return(false);
                    }
                    break;
                }

                default:
                {
                    return(false);

                    break;
                }
                }
            }
            ICollection <TransportProtocol.URIishField> canHave = EnumSet.CopyOf(GetRequiredFields
                                                                                     ());

            Sharpen.Collections.AddAll(canHave, GetOptionalFields());
            if (uri.GetUser() != null && !canHave.Contains(TransportProtocol.URIishField.USER
                                                           ))
            {
                return(false);
            }
            if (uri.GetPass() != null && !canHave.Contains(TransportProtocol.URIishField.PASS
                                                           ))
            {
                return(false);
            }
            if (uri.GetHost() != null && !canHave.Contains(TransportProtocol.URIishField.HOST
                                                           ))
            {
                return(false);
            }
            if (uri.GetPort() > 0 && !canHave.Contains(TransportProtocol.URIishField.PORT))
            {
                return(false);
            }
            if (uri.GetPath() != null && !canHave.Contains(TransportProtocol.URIishField.PATH
                                                           ))
            {
                return(false);
            }
            return(true);
        }
예제 #60
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestGitProtoWindowsPort()
 {
     string str = "git://example.com:338/D:/m y";
     URIish u = new URIish(str);
     NUnit.Framework.Assert.AreEqual("git", u.GetScheme());
     NUnit.Framework.Assert.IsTrue(u.IsRemote());
     NUnit.Framework.Assert.AreEqual("D:/m y", u.GetPath());
     NUnit.Framework.Assert.AreEqual(338, u.GetPort());
     NUnit.Framework.Assert.AreEqual("example.com", u.GetHost());
     NUnit.Framework.Assert.AreEqual(str, u.ToString());
     NUnit.Framework.Assert.AreEqual(u, new URIish(str));
 }