mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
created a password-has-numbers constraint
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user