-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve tests (#222) * bump NUnit * start work * Create Populate-ActiveDirectory.ps1 * update tests * Update Populate-ActiveDirectory.ps1 * Update Populate-ActiveDirectory.ps1 * Update Populate-ActiveDirectory.ps1 * Update Populate-ActiveDirectory.ps1 * Update Populate-ActiveDirectory.ps1 * Update UnitTestsHelper.cs * work * work * work * work * Update UseSidAttributeForPermissionTests.cs * work * Update UnitTestsHelper.cs * Update Populate-ActiveDirectory.ps1 * Update Populate-ActiveDirectory.ps1 * work * Update CHANGELOG.md * Update Populate-ActiveDirectory.ps1 * work * simplify the setup of tests * Fix init error if the identifier claim type is not well-known by LDAPCP (#223) * fix error if identifier claim type is unknown * Update CHANGELOG.md * update workflows * update workflow * Update UseSidAttributeForPermissionTests.cs * Update Yvand.LDAPCPSE.Tests.csproj * update build settings * Update CHANGELOG.md
- Loading branch information
Showing
16 changed files
with
969 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
@@ -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 | ||
} | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
} | ||
|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
//{ | ||
|
@@ -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); | ||
|
Oops, something went wrong.