mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
RootNodeInfo.PasswordString will now return either a custom password (if one is set) otherwise the default password
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using mRemoteNG.Tree.Root;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
||||
@@ -18,12 +17,12 @@ namespace mRemoteNGTests.Tree
|
||||
[Test]
|
||||
public void DefaultPasswordReturnsExpectedValue()
|
||||
{
|
||||
var defaultPassword = _rootNodeInfo.DefaultPassword.ConvertToUnsecureString();
|
||||
var defaultPassword = _rootNodeInfo.DefaultPassword;
|
||||
Assert.That(defaultPassword, Is.EqualTo("mR3m"));
|
||||
}
|
||||
|
||||
[TestCase("a", true)]
|
||||
[TestCase("mR3m", true)]
|
||||
[TestCase("mR3m", false)]
|
||||
[TestCase("", false)]
|
||||
[TestCase(null, false)]
|
||||
public void PasswordPropertyReflectsWhetherACustomPasswordIsInUse(string password, bool expected)
|
||||
@@ -31,5 +30,21 @@ namespace mRemoteNGTests.Tree
|
||||
_rootNodeInfo.PasswordString = password;
|
||||
Assert.That(_rootNodeInfo.Password, Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(null)]
|
||||
public void PasswordStringReturnsDefaultPasswordWhenNoCustomOneIsSet(string password)
|
||||
{
|
||||
_rootNodeInfo.PasswordString = password;
|
||||
Assert.That(_rootNodeInfo.PasswordString, Is.EqualTo(_rootNodeInfo.DefaultPassword));
|
||||
}
|
||||
|
||||
[TestCase("a")]
|
||||
[TestCase("1234")]
|
||||
public void PasswordStringReturnsCustomPassword(string password)
|
||||
{
|
||||
_rootNodeInfo.PasswordString = password;
|
||||
Assert.That(_rootNodeInfo.PasswordString, Is.EqualTo(password));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,23 +41,19 @@ namespace mRemoteNG.Tree.Root
|
||||
[Browsable(false)]
|
||||
public string PasswordString
|
||||
{
|
||||
get { return _customPassword; }
|
||||
get
|
||||
{
|
||||
return Password ? _customPassword : DefaultPassword;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
_customPassword = value;
|
||||
Password = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Password = false;
|
||||
}
|
||||
_customPassword = value;
|
||||
Password = !string.IsNullOrEmpty(value) && _customPassword != DefaultPassword;
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public SecureString DefaultPassword { get; } = "mR3m".ConvertToSecureString();
|
||||
public string DefaultPassword { get; } = "mR3m";
|
||||
|
||||
[Browsable(false)]
|
||||
public RootNodeType Type {get; set;}
|
||||
|
||||
Reference in New Issue
Block a user