mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 03:49:23 +08:00
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System;
|
|
using mRemoteNG.Security;
|
|
using mRemoteNG.Security.PasswordCreation;
|
|
using NUnit.Framework;
|
|
|
|
|
|
namespace mRemoteNGTests.Security.PasswordCreation
|
|
{
|
|
public class PasswordIncludesNumbersConstraintTests
|
|
{
|
|
private PasswordIncludesNumbersConstraint _includesNumbersConstraint;
|
|
|
|
[Test]
|
|
public void PasswordWithANumberPassesConstraint()
|
|
{
|
|
var password = "hello1".ConvertToSecureString();
|
|
_includesNumbersConstraint = new PasswordIncludesNumbersConstraint();
|
|
Assert.That(_includesNumbersConstraint.Validate(password), Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void PasswordWithFewerThanTheMinimumCountOfNumbersFailsConstraint()
|
|
{
|
|
var password = "hello1".ConvertToSecureString();
|
|
_includesNumbersConstraint = new PasswordIncludesNumbersConstraint(2);
|
|
Assert.That(_includesNumbersConstraint.Validate(password), Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void PasswordWithoutNumbersFailsConstraint()
|
|
{
|
|
var password = "hello".ConvertToSecureString();
|
|
_includesNumbersConstraint = new PasswordIncludesNumbersConstraint();
|
|
Assert.That(_includesNumbersConstraint.Validate(password), Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void CountOfNumbersToRequireMustBeAPositiveValue()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => new PasswordIncludesNumbersConstraint(-1));
|
|
}
|
|
}
|
|
} |