Classify SGU accounts into AD role groups
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using SGU.AuthBroker.Options;
|
||||
using SGU.AuthBroker.Core.Identity;
|
||||
using Xunit;
|
||||
|
||||
namespace SGU.AuthBroker.Tests;
|
||||
@@ -28,4 +29,31 @@ public sealed class BrokerOptionsTests
|
||||
|
||||
Assert.Contains("thumbprint", exception.Message, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(InstitutionalRole.Student, "CN=SGU-Alumnos,OU=Usuarios-SGU,DC=lci,DC=lasalle,DC=mx")]
|
||||
[InlineData(InstitutionalRole.Administrative, "CN=SGU-Administrativos,OU=Usuarios-SGU,DC=lci,DC=lasalle,DC=mx")]
|
||||
[InlineData(InstitutionalRole.Professor, "CN=SGU-Docentes,OU=Usuarios-SGU,DC=lci,DC=lasalle,DC=mx")]
|
||||
public void DefaultRoleGroupMappingsMatchInstitutionalPrefixes(InstitutionalRole role, string expectedGroupDn)
|
||||
{
|
||||
ActiveDirectoryOptions options = new();
|
||||
|
||||
Assert.Equal(expectedGroupDn, options.GetGroupDn(role));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidateRejectsARoleGroupOutsideTheConfiguredDirectoryBase()
|
||||
{
|
||||
BrokerOptions options = new()
|
||||
{
|
||||
Directory = new ActiveDirectoryOptions
|
||||
{
|
||||
StudentGroupDn = "CN=SGU-Alumnos,DC=example,DC=invalid"
|
||||
}
|
||||
};
|
||||
|
||||
InvalidOperationException exception = Assert.Throws<InvalidOperationException>(options.Validate);
|
||||
|
||||
Assert.Contains("security-group", exception.Message, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user