public void SetPasswordViaPlainTextString() { var password = new Password("secret"); var cred = new UserCredentials { Password = password }; Assert.AreEqual(password.ToString(), cred.Password.ToString()); }
public void SetAndGetObfuscatedPassword() { string passwd = "Test"; string obfuscated = new Password(passwd).ObfuscatedPassword; Password password = new Password { ObfuscatedPassword = obfuscated }; Assert.NotNull(password.ObfuscatedPassword); Assert.AreEqual(obfuscated, password.ObfuscatedPassword); Assert.AreEqual(passwd, password.ToString()); }
/// <summary> /// Creates a cmis Atom Pub session with the given credentials. /// </summary> /// <returns> /// The session. /// </returns> /// <param name='user'> /// User. /// </param> /// <param name='password'> /// Password. /// </param> /// <param name='url'> /// URL. /// </param> /// <param name='repoId'> /// Repo identifier. /// </param> public static ISession CreateSession( string user, Password password, string url, string repoId, string binding) { Dictionary<string, string> cmisParameters = new Dictionary<string, string>(); if (binding.Equals(BindingType.AtomPub, StringComparison.OrdinalIgnoreCase)) { cmisParameters[SessionParameter.BindingType] = BindingType.AtomPub; cmisParameters[SessionParameter.AtomPubUrl] = url; } else if (binding.Equals(BindingType.Browser, StringComparison.OrdinalIgnoreCase)) { cmisParameters[SessionParameter.BindingType] = BindingType.Browser; cmisParameters[SessionParameter.BrowserUrl] = url; } cmisParameters[SessionParameter.User] = user; cmisParameters[SessionParameter.Password] = password.ToString(); cmisParameters[SessionParameter.RepositoryId] = repoId; // Sets the Connect Timeout to 60 secs cmisParameters[SessionParameter.ConnectTimeout] = "60000"; ISession session = SessionFactory.NewInstance().CreateSession(cmisParameters); HashSet<string> filters = new HashSet<string>(); filters.Add(PropertyIds.ObjectId); filters.Add(PropertyIds.Name); filters.Add(PropertyIds.ContentStreamFileName); filters.Add(PropertyIds.ContentStreamLength); filters.Add(PropertyIds.LastModificationDate); filters.Add(PropertyIds.CreationDate); filters.Add(PropertyIds.Path); filters.Add(PropertyIds.ChangeToken); filters.Add(PropertyIds.SecondaryObjectTypeIds); filters.Add(PropertyIds.IsVersionSeriesCheckedOut); filters.Add(PropertyIds.VersionSeriesCheckedOutId); HashSet<string> renditions = new HashSet<string>(); renditions.Add("cmis:none"); session.DefaultContext = session.CreateOperationContext(filters, false, true, false, IncludeRelationshipsFlag.None, null, true, null, true, 100); return session; }
public void ConstructorTakingAPaintextPassword() { string passwd = "Test"; var password = new Password(passwd); Assert.NotNull(password.ObfuscatedPassword); Assert.AreEqual(passwd, password.ToString()); }
public void DefaultConstructor() { var password = new Password(); Assert.IsNull(password.ObfuscatedPassword); Assert.IsNull(password.ToString()); }
public void CreateMultipleServerCredentialsBasedOnTheGivenOne() { var userName = "******"; var originalUrl = "https://demo.deutsche-wolke.de/wrongStuff"; var password = new Password(Guid.NewGuid().ToString()); var originalCredentials = new ServerCredentials { Address = new Uri(originalUrl), Password = password, Binding = BindingType.Browser, UserName = userName }; var list = originalCredentials.CreateFuzzyCredentials(); Assert.That(list, Is.Not.Null); Assert.That(list, Is.Not.Empty); Assert.That(list.First().Credentials, Is.EqualTo(originalCredentials)); Assert.That(list[1].Credentials.Address.ToString(), Is.EqualTo(originalCredentials.Address.ToString())); Assert.That(list[1].Credentials.Binding, Is.Not.EqualTo(originalCredentials.Binding)); foreach (var entry in list) { Assert.That(entry.Credentials.Password.ToString(), Is.EqualTo(password.ToString())); Assert.That(entry.Credentials.UserName, Is.EqualTo(userName)); Console.WriteLine(entry); } }