Files
mRemoteNG/mRemoteNGTests/Security/PasswordCreation/PasswordIncludesLowerCaseConstraintTests.cs
2017-01-28 13:35:28 -07:00

51 lines
1.7 KiB
C#

using System;
using mRemoteNG.Security;
using mRemoteNG.Security.PasswordCreation;
using NUnit.Framework;
namespace mRemoteNGTests.Security.PasswordCreation
{
public class PasswordIncludesLowerCaseConstraintTests
{
private PasswordIncludesLowerCaseConstraint _lowerCaseConstraint;
[Test]
public void PasswordThatExceedsMinimumLowerCasePassesValidation()
{
var password = "hello".ConvertToSecureString();
_lowerCaseConstraint = new PasswordIncludesLowerCaseConstraint();
Assert.That(_lowerCaseConstraint.Validate(password), Is.True);
}
[Test]
public void PasswordThatMeetsMinimumLowerCasePassesValidation()
{
var password = "hello".ConvertToSecureString();
_lowerCaseConstraint = new PasswordIncludesLowerCaseConstraint(5);
Assert.That(_lowerCaseConstraint.Validate(password), Is.True);
}
[Test]
public void PasswordWithFewerThanMinimumLowerCaseFailsValidation()
{
var password = "hELLO".ConvertToSecureString();
_lowerCaseConstraint = new PasswordIncludesLowerCaseConstraint(2);
Assert.That(_lowerCaseConstraint.Validate(password), Is.False);
}
[Test]
public void PasswordWithoutLowerCaseFailsValidation()
{
var password = "HELLO".ConvertToSecureString();
_lowerCaseConstraint = new PasswordIncludesLowerCaseConstraint();
Assert.That(_lowerCaseConstraint.Validate(password), Is.False);
}
[Test]
public void CountToRequireMustBeAPositiveValue()
{
Assert.Throws<ArgumentException>(() => new PasswordIncludesLowerCaseConstraint(-1));
}
}
}