public override bool Get (URIish uri, params CredentialItem[] items) { bool result = false; CredentialItem.Password passwordItem = null; CredentialItem.StringType passphraseItem = null; // We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even // if the password store contains an invalid password/no password if (TryGetUsernamePassword (uri, items, out passwordItem) || TryGetPassphrase (uri, items, out passphraseItem)) { // If the password store has a password and we already tried using it, it could be incorrect. // If this happens, do not return true and ask the user for a new password. if (!HasReset) { return true; } } DispatchService.GuiSyncDispatch (delegate { CredentialsDialog dlg = new CredentialsDialog (uri, items); try { result = MessageService.ShowCustomDialog (dlg) == (int)Gtk.ResponseType.Ok; } finally { dlg.Destroy (); } }); HasReset = false; if (result) { if (passwordItem != null) { PasswordService.AddWebPassword (new Uri (uri.ToString ()), new string (passwordItem.GetValue ())); } else if (passphraseItem != null) { PasswordService.AddWebPassword (new Uri (uri.ToString ()), passphraseItem.GetValue ()); } } return result; }
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 CredentialsDialog (URIish uri, IEnumerable<CredentialItem> credentials) { this.Build (); this.credentials = credentials; labelTop.Text = string.Format (labelTop.Text, uri.ToString ()); Gtk.Table table = new Gtk.Table (0, 0, false); table.ColumnSpacing = 6; vbox.PackStart (table, true, true, 0); uint r = 0; Widget firstEditor = null; foreach (CredentialItem c in credentials) { Label lab = new Label (c.GetPromptText () + ":"); lab.Xalign = 0; table.Attach (lab, 0, 1, r, r + 1); Table.TableChild tc = (Table.TableChild) table [lab]; tc.XOptions = AttachOptions.Shrink; Widget editor = null; if (c is CredentialItem.YesNoType) { CredentialItem.YesNoType cred = (CredentialItem.YesNoType) c; CheckButton btn = new CheckButton (); editor = btn; btn.Toggled += delegate { cred.SetValue (btn.Active); }; } else if (c is CredentialItem.StringType || c is CredentialItem.CharArrayType) { CredentialItem cred = c; Entry e = new Entry (); editor = e; e.ActivatesDefault = true; if (cred.IsValueSecure ()) e.Visibility = false; e.Changed += delegate { if (cred is CredentialItem.StringType) ((CredentialItem.StringType)cred).SetValue (e.Text); else ((CredentialItem.CharArrayType)cred).SetValue (e.Text.ToCharArray ()); }; } if (editor != null) { table.Attach (editor, 1, 2, r, r + 1); tc = (Table.TableChild) table [lab]; tc.XOptions = AttachOptions.Fill; if (firstEditor == null) firstEditor = editor; } r++; } table.ShowAll (); Focus = firstEditor; Default = buttonOk; }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public virtual void TestAddURI() { ReadConfig(string.Empty); URIish uri = new URIish("/some/dir"); RemoteConfig rc = new RemoteConfig(config, "backup"); NUnit.Framework.Assert.AreEqual(0, rc.URIs.Count); NUnit.Framework.Assert.IsTrue(rc.AddURI(uri)); NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count); NUnit.Framework.Assert.AreSame(uri, rc.URIs[0]); NUnit.Framework.Assert.IsFalse(rc.AddURI(new URIish(uri.ToString()))); NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count); }
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 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 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)); }
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 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 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)); }
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)); }
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)); }
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)); }
/// <exception cref="System.IO.IOException"></exception> internal virtual void Write(TextWriter pw) { string type; string name; if (sourceName.StartsWith(Constants.R_HEADS)) { type = "branch"; name = Sharpen.Runtime.Substring(sourceName, Constants.R_HEADS.Length); } else { if (sourceName.StartsWith(Constants.R_TAGS)) { type = "tag"; name = Sharpen.Runtime.Substring(sourceName, Constants.R_TAGS.Length); } else { if (sourceName.StartsWith(Constants.R_REMOTES)) { type = "remote branch"; name = Sharpen.Runtime.Substring(sourceName, Constants.R_REMOTES.Length); } else { type = string.Empty; name = sourceName; } } } pw.Write(newValue.Name); pw.Write('\t'); if (notForMerge) { pw.Write("not-for-merge"); } pw.Write('\t'); pw.Write(type); pw.Write(" '"); pw.Write(name); pw.Write("' of "); pw.Write(sourceURI.ToString()); pw.Write("\n"); }
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)); }
/// <exception cref="System.NotSupportedException"></exception> protected internal TransportHttp(Repository local, URIish uri) : base(local, uri) { try { string uriString = uri.ToString(); if (!uriString.EndsWith("/")) { //$NON-NLS-1$ uriString += "/"; } //$NON-NLS-1$ baseUrl = new Uri(uriString); objectsUrl = new Uri(baseUrl, "objects/"); } catch (UriFormatException e) { //$NON-NLS-1$ throw new NotSupportedException(MessageFormat.Format(JGitText.Get().invalidURL, uri ), e); } http = local.GetConfig().Get(HTTP_KEY); proxySelector = ProxySelector.GetDefault(); }
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)); }
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)); }
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)); }
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)); }
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)); }
static bool TryGetPassphrase (URIish uri, CredentialItem[] items, out CredentialItem.StringType passphraseItem) { var actualUrl = new Uri (uri.ToString ()); var passphrase = (CredentialItem.StringType) items.FirstOrDefault (i => i is CredentialItem.StringType); if (items.Length == 1 && passphrase != null) { passphraseItem = passphrase; var passphraseValue = PasswordService.GetWebPassword (actualUrl); if (passphraseValue != null) { passphrase.SetValue (passphraseValue); return true; } } else { passphraseItem = null; } return false; }
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)); }
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)); }
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)); }
static bool TryGetUsernamePassword (URIish uri, CredentialItem[] items, out CredentialItem.Password passwordItem) { var actualUrl = new Uri (uri.ToString ()); var username = (CredentialItem.Username) items.FirstOrDefault (i => i is CredentialItem.Username); var password = (CredentialItem.Password) items.FirstOrDefault (i => i is CredentialItem.Password); if (items.Length == 2 && username != null && password != null) { passwordItem = password; var cred = PasswordService.GetWebUserNameAndPassword (actualUrl); if (cred != null) { username.SetValue (cred.Item1); password.SetValueNoCopy (cred.Item2.ToArray ()); return true; } } else { passwordItem = null; } return false; }