SubjectValidator validates for supported attributes and OID
This commit is contained in:
21
certmgrTest/SubjectValidatorTest.cs
Normal file
21
certmgrTest/SubjectValidatorTest.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using CertMgr.CertGen.Utils;
|
||||
using CertMgr.Core.Validation;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace certmgrTest;
|
||||
|
||||
public class SubjectValidatorTest
|
||||
{
|
||||
[TestCase("CN=www.example.com, O=Example Corp, OU=IT Department, L=Prague, ST=Czech Republic, C=CZ", true)]
|
||||
[TestCase("CN=John Doe + OU=Engineering", true)]
|
||||
[TestCase("1.2.3.4=John Doe", true)]
|
||||
[TestCase("OID.1.2.3.4=John Doe", true)]
|
||||
[TestCase("OID.1.2=John Doe", false)]
|
||||
public async Task First(string subj, bool expectedSuccess)
|
||||
{
|
||||
SubjectValidator validator = new SubjectValidator("TestSetting");
|
||||
ValidationResult result = await validator.ValidateAsync(subj, CancellationToken.None);
|
||||
Assert.That(result.IsValid, Is.EqualTo(expectedSuccess), result.Justification);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user