Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish LDAPCPSE v19.0 #227

Merged
merged 12 commits into from
Aug 23, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log for LDAPCP

## LDAPCP Second Edition v19.0 - Unreleased

* Fix error when creating the configuration if the trust uses an identifier claim type that is not well-known by LDAPCP - https://github.com/Yvand/LDAPCP/issues/221
* Improve tests, to make them much easier to replay from a new test environment, and with many more users and groups

## LDAPCP Second Edition v18.0.20240513.3 - Published in May 13, 2024

* Fix error when creating the configuration, due to case-sensitive test in the claim types - https://github.com/Yvand/LDAPCP/issues/204
Expand Down
165 changes: 103 additions & 62 deletions Yvand.LDAPCPSE.Tests/AugmentationTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yvand.LdapClaimsProvider.Tests
{
Expand All @@ -22,26 +18,38 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public virtual void TestAugmentationOperation(ValidateEntityData registrationData)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetUsersMembersOfNestedGroups), null)]
public void TestUsersMembersOfNestedGroups(TestUser user)
{
TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestAugmentationAgainstGroupsWithNestedGroupsAsMembers(user);
}

[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

#if DEBUG
[TestCase("[email protected]", true, @"contoso.local\testLdapcpseGroup_2")]
public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}

#if DEBUG
//[TestCase("[email protected]", true, @"contoso.local\testLdapcpseGroup_2")]
//public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
//{
// base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
//}
#endif
}

Expand All @@ -62,27 +70,31 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public virtual void TestAugmentationOperation(ValidateEntityData registrationData)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetUsersMembersOfNestedGroups), null)]
public void TestUsersMembersOfNestedGroups(TestUser user)
{
TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestAugmentationAgainstGroupsWithNestedGroupsAsMembers(user);
}

[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

#if DEBUG
[TestCase("[email protected]", true, @"contoso.local\testLdapcpseGroup_2")]
public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}
#endif
}

public class AugmentUsingCustomConnectionAndUsingHelperTestss : ClaimsProviderTestsBase
Expand All @@ -100,27 +112,31 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public virtual void TestAugmentationOperation(ValidateEntityData registrationData)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetUsersMembersOfNestedGroups), null)]
public void TestUsersMembersOfNestedGroups(TestUser user)
{
TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestAugmentationAgainstGroupsWithNestedGroupsAsMembers(user);
}

[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

#if DEBUG
[TestCase("[email protected]", true, @"contoso.local\testLdapcpseGroup_2")]
public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}
#endif
}

public class AugmentUsingDefaultConnectionAndUsingHelperTestss : ClaimsProviderTestsBase
Expand All @@ -140,25 +156,39 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public virtual void TestAugmentationOperation(ValidateEntityData registrationData)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetUsersMembersOfNestedGroups), null)]
public void TestUsersMembersOfNestedGroups(TestUser user)
{
TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestAugmentationAgainstGroupsWithNestedGroupsAsMembers(user);
}

[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}

#if DEBUG
[TestCase("[email protected]", true, @"contoso.local\testLdapcpseGroup_2")]
public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
[TestCase("testLdapcpUser_040", "testLdapcpGroup_022")]
public void DebugTestUser(string upnPrefix, string groupName)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
TestUser user = TestEntitySourceManager.FindUser(upnPrefix);
TestGroup group = TestEntitySourceManager.FindGroup(groupName);
TestAugmentationAgainstGroup(user, group);
}
#endif
}
Expand All @@ -180,19 +210,30 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

#if DEBUG
[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetUsersMembersOfNestedGroups), null)]
public void TestUsersMembersOfNestedGroups(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupSid);
base.TestAugmentationAgainstGroupsWithNestedGroupsAsMembers(user);
}

[TestCase("[email protected]", true, @"S-1-5-21-2647467245-1611586658-188888215-110602")] // testLdapcpseGroup_2
public void TestAugmentationOperationGroupRecursive(string claimValue, bool isMemberOfTrustedGroup, string groupValue)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, groupValue);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}
#endif
}
}
73 changes: 52 additions & 21 deletions Yvand.LDAPCPSE.Tests/BasicConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,70 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(SearchEntityDataSource), nameof(SearchEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest })]
public void TestGroups(TestGroup group)
{
TestSearchAndValidateForTestGroup(group);
}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
{
base.TestAugmentationOfGoldUsersAgainstRandomGroups();
}

#if DEBUG
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.AllSearchEntities), null)]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public void TestSearch(SearchEntityData registrationData)
public void TestSearch(SearchEntityScenario registrationData)
{
base.TestSearchOperation(registrationData.Input, registrationData.SearchResultCount, registrationData.SearchResultSingleEntityClaimValue);
}

[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.AllValidationEntities), null)]
[MaxTime(UnitTestsHelper.MaxTime)]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public void TestValidation(ValidateEntityData registrationData)
public void TestValidation(ValidateEntityScenario registrationData)
{
base.TestValidationOperation(registrationData);
}
#endif

/// <summary>
/// Tests if the augmentation works as expected.
/// </summary>
/// <param name="registrationData"></param>
[Test, TestCaseSource(typeof(ValidateEntityDataSource), nameof(ValidateEntityDataSource.GetTestData), new object[] { EntityDataSourceType.AllAccounts })]
[Repeat(UnitTestsHelper.TestRepeatCount)]
public virtual void TestAugmentationOperation(ValidateEntityData registrationData)
{
TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
}
///// <summary>
///// Tests if the augmentation works as expected.
///// </summary>
///// <param name="registrationData"></param>
//[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.AllValidationEntities), null)]
//[Repeat(UnitTestsHelper.TestRepeatCount)]
//public virtual void TestAugmentationOperation(ValidateEntityScenario registrationData)
//{
// TestAugmentationOperation(registrationData.ClaimValue, registrationData.IsMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
//}

[TestCase("FakeAccount", false)]
[TestCase("[email protected]", true)]
public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
//[TestCase("FakeAccount", false)]
//[TestCase("[email protected]", true)]
//public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedGroup)
//{
// base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
//}

#if DEBUG
[TestCase("testLdapcpUser_001")]
[TestCase("testLdapcpUser_007")]
public void DebugTestUser(string upnPrefix)
{
base.TestAugmentationOperation(claimValue, isMemberOfTrustedGroup, UnitTestsHelper.ValidGroupName);
TestUser user = TestEntitySourceManager.FindUser(upnPrefix);
base.TestSearchAndValidateForTestUser(user);
}

#if DEBUG
////[TestCaseSource(typeof(SearchEntityDataSourceCollection))]
//public void DEBUG_SearchEntitiesFromCollection(string inputValue, string expectedCount, string expectedClaimValue)
//{
Expand All @@ -61,9 +91,10 @@ public void TestAugmentationOperation(string claimValue, bool isMemberOfTrustedG
//}

//[TestCase(@"group\ch", 1, @"contoso.local\group\chartest")]
[TestCase(@"test_special)", 1, @"[email protected]")]
[TestCase(@"test_special)", 1, @"[email protected]")]
[TestCase(@"firstname_002", 1, @"[email protected]")]
//[TestCase(@"group\ch", 1, @"group\chartest")]
[TestCase(@"testLdapcpseUser_001", 1, @"testLdapcpseUser_001@contoso.local")]
[TestCase(@"testLdapcpUser_001", 1, @"testLdapcpUser_001@contoso.local")]
public void TestSearch(string inputValue, int expectedResultCount, string expectedEntityClaimValue)
{
base.TestSearchOperation(inputValue, expectedResultCount, expectedEntityClaimValue);
Expand Down
Loading
Loading