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);
|
||||
}
|
||||
}
|
||||
19
certmgrTest/certmgrTest.csproj
Normal file
19
certmgrTest/certmgrTest.csproj
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
|
||||
<PackageReference Include="NUnit" Version="4.4.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\certmgr\certmgr.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user