-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from Yvand/update-graph
move AzureCP SE to dev
- Loading branch information
Showing
54 changed files
with
4,562 additions
and
4,458 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Yvand.ClaimsProviders.Tests | ||
{ | ||
[TestFixture] | ||
[Parallelizable(ParallelScope.Children)] | ||
internal class BasicTests : EntityTestsBase | ||
{ | ||
[Test, TestCaseSource(typeof(SearchEntityDataSource), "GetTestData", new object[] { EntityDataSourceType.AllAccounts })] | ||
[Repeat(UnitTestsHelper.TestRepeatCount)] | ||
public override void SearchEntities(SearchEntityData registrationData) | ||
{ | ||
base.SearchEntities(registrationData); | ||
} | ||
|
||
[Test, TestCaseSource(typeof(ValidateEntityDataSource), "GetTestData", new object[] { EntityDataSourceType.AllAccounts })] | ||
[MaxTime(UnitTestsHelper.MaxTime)] | ||
[Repeat(UnitTestsHelper.TestRepeatCount)] | ||
public override void ValidateClaim(ValidateEntityData registrationData) | ||
{ | ||
base.ValidateClaim(registrationData); | ||
} | ||
|
||
[Test, TestCaseSource(typeof(ValidateEntityDataSource), "GetTestData", new object[] { EntityDataSourceType.AllAccounts })] | ||
[Repeat(UnitTestsHelper.TestRepeatCount)] | ||
public override void AugmentEntity(ValidateEntityData registrationData) | ||
{ | ||
base.AugmentEntity(registrationData); | ||
} | ||
|
||
#if DEBUG | ||
////[TestCaseSource(typeof(SearchEntityDataSourceCollection))] | ||
//public void DEBUG_SearchEntitiesFromCollection(string inputValue, string expectedCount, string expectedClaimValue) | ||
//{ | ||
// if (!TestSearch) { return; } | ||
|
||
// TestSearchOperation(inputValue, Convert.ToInt32(expectedCount), expectedClaimValue); | ||
//} | ||
|
||
[TestCase(@"AADGroup1130", 1, "e86ace87-37ba-4ee1-8087-ecd783728233")] | ||
[TestCase(@"xyzguest", 0, "[email protected]")] | ||
[TestCase(@"AzureGr}", 1, "ef7d18e6-5c4d-451a-9663-a976be81c91e")] | ||
[TestCase(@"aad", 30, "")] | ||
[TestCase(@"AADGroup", 30, "")] | ||
public override void SearchEntities(string inputValue, int expectedResultCount, string expectedEntityClaimValue) | ||
{ | ||
base.SearchEntities(inputValue, expectedResultCount, expectedEntityClaimValue); | ||
} | ||
|
||
[TestCase("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", "ef7d18e6-5c4d-451a-9663-a976be81c91e", true)] | ||
[TestCase("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn", "[email protected]", false)] | ||
[TestCase("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", "FakeGuest.com#EXT#@XXX.onmicrosoft.com", false)] | ||
[TestCase("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn", "FakeGuest.com#EXT#@XXX.onmicrosoft.com", false)] | ||
public override void ValidateClaim(string claimType, string claimValue, bool shouldValidate) | ||
{ | ||
base.ValidateClaim(claimType, claimValue, shouldValidate); | ||
} | ||
|
||
[TestCase("[email protected]", false)] | ||
public override void AugmentEntity(string claimValue, bool shouldHavePermissions) | ||
{ | ||
base.AugmentEntity(claimValue, shouldHavePermissions); | ||
} | ||
#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 |
---|---|---|
@@ -1,94 +1,78 @@ | ||
using azurecp; | ||
using Microsoft.SharePoint.Administration.Claims; | ||
using Microsoft.SharePoint.Administration.Claims; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using Yvand.ClaimsProviders.AzureAD; | ||
using Yvand.ClaimsProviders.Config; | ||
|
||
namespace AzureCP.Tests | ||
namespace Yvand.ClaimsProviders.Tests | ||
{ | ||
[TestFixture] | ||
public class CustomConfigTests : BackupCurrentConfig | ||
public class CustomConfigTestsBase : EntityTestsBase | ||
{ | ||
public static string GroupsClaimType = ClaimsProviderConstants.DefaultMainGroupClaimType; | ||
|
||
public override void InitializeConfiguration() | ||
{ | ||
base.InitializeConfiguration(); | ||
|
||
// Extra initialization for current test class | ||
Config.EnableAugmentation = true; | ||
Config.ClaimTypes.GetByClaimType(UnitTestsHelper.SPTrust.IdentityClaimTypeInformation.MappedClaimType).PrefixToBypassLookup = "bypass-user:"; | ||
Config.ClaimTypes.GetByClaimType(UnitTestsHelper.TrustedGroupToAdd_ClaimType).PrefixToBypassLookup = "bypass-group:"; | ||
Config.Update(); | ||
Settings.EnableAugmentation = true; | ||
Settings.ClaimTypes.GetByClaimType(UnitTestsHelper.SPTrust.IdentityClaimTypeInformation.MappedClaimType).PrefixToBypassLookup = "bypass-user:"; | ||
Settings.ClaimTypes.GetByClaimType(UnitTestsHelper.TrustedGroupToAdd_ClaimType).PrefixToBypassLookup = "bypass-group:"; | ||
ClaimTypeConfig ctConfigExtensionAttribute = new ClaimTypeConfig | ||
{ | ||
ClaimType = TestContext.Parameters["MultiPurposeCustomClaimType"], | ||
ClaimTypeDisplayName = "extattr1", | ||
EntityProperty = DirectoryObjectProperty.extensionAttribute1, | ||
SharePointEntityType = "FormsRole", | ||
}; | ||
Settings.ClaimTypes.Add(ctConfigExtensionAttribute); | ||
GlobalConfiguration.ApplySettings(Settings, true); | ||
} | ||
} | ||
|
||
[TestFixture] | ||
[Parallelizable(ParallelScope.Children)] | ||
public class CustomConfigTests : CustomConfigTestsBase | ||
{ | ||
[TestCase("bypass-user:[email protected]", 1, "[email protected]")] | ||
[TestCase("[email protected]", 0, "")] | ||
[TestCase("bypass-user:", 0, "")] | ||
public void BypassLookupOnIdentityClaimTest(string inputValue, int expectedCount, string expectedClaimValue) | ||
{ | ||
UnitTestsHelper.TestSearchOperation(inputValue, expectedCount, expectedClaimValue); | ||
TestSearchOperation(inputValue, expectedCount, expectedClaimValue); | ||
|
||
if (expectedCount > 0) | ||
{ | ||
SPClaim inputClaim = new SPClaim(UnitTestsHelper.SPTrust.IdentityClaimTypeInformation.MappedClaimType, expectedClaimValue, ClaimValueTypes.String, SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, UnitTestsHelper.SPTrust.Name)); | ||
UnitTestsHelper.TestValidationOperation(inputClaim, true, expectedClaimValue); | ||
TestValidationOperation(inputClaim, true, expectedClaimValue); | ||
} | ||
} | ||
|
||
[TestCase(@"bypass-group:domain\groupValue", 1, @"domain\groupValue")] | ||
[TestCase(@"domain\groupValue", 0, "")] | ||
[TestCase("bypass-group:", 0, "")] | ||
public void BypassLookupOnGroupClaimTest(string inputValue, int expectedCount, string expectedClaimValue) | ||
[TestCase("val", 1, "value1")] // Extension attribute configuration | ||
public override void SearchEntities(string inputValue, int expectedResultCount, string expectedEntityClaimValue) | ||
{ | ||
UnitTestsHelper.TestSearchOperation(inputValue, expectedCount, expectedClaimValue); | ||
|
||
if (expectedCount > 0) | ||
{ | ||
SPClaim inputClaim = new SPClaim(UnitTestsHelper.TrustedGroupToAdd_ClaimType, expectedClaimValue, ClaimValueTypes.String, SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, UnitTestsHelper.SPTrust.Name)); | ||
UnitTestsHelper.TestValidationOperation(inputClaim, true, expectedClaimValue); | ||
} | ||
base.SearchEntities(inputValue, expectedResultCount, expectedEntityClaimValue); | ||
} | ||
|
||
[Test] | ||
[NonParallelizable] | ||
public void BypassServer() | ||
{ | ||
Config.AlwaysResolveUserInput = true; | ||
Config.Update(); | ||
|
||
Settings.AlwaysResolveUserInput = true; | ||
GlobalConfiguration.ApplySettings(Settings, true); | ||
try | ||
{ | ||
UnitTestsHelper.TestSearchOperation(UnitTestsHelper.RandomClaimValue, 2, UnitTestsHelper.RandomClaimValue); | ||
TestSearchOperation(UnitTestsHelper.RandomClaimValue, 3, UnitTestsHelper.RandomClaimValue); | ||
|
||
SPClaim inputClaim = new SPClaim(UnitTestsHelper.SPTrust.IdentityClaimTypeInformation.MappedClaimType, UnitTestsHelper.RandomClaimValue, ClaimValueTypes.String, SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, UnitTestsHelper.SPTrust.Name)); | ||
UnitTestsHelper.TestValidationOperation(inputClaim, true, UnitTestsHelper.RandomClaimValue); | ||
TestValidationOperation(inputClaim, true, UnitTestsHelper.RandomClaimValue); | ||
} | ||
finally | ||
{ | ||
Config.AlwaysResolveUserInput = false; | ||
Config.Update(); | ||
Settings.AlwaysResolveUserInput = false; | ||
GlobalConfiguration.ApplySettings(Settings, true); | ||
} | ||
} | ||
|
||
//[Test, TestCaseSource(typeof(ValidateEntityDataSource), "GetTestData", new object[] { EntityDataSourceType.AllAccounts })] | ||
////[Repeat(UnitTestsHelper.TestRepeatCount)] | ||
//public void RequireExactMatchDuringSearch(ValidateEntityData registrationData) | ||
//{ | ||
// Config.FilterExactMatchOnly = true; | ||
// Config.Update(); | ||
|
||
// try | ||
// { | ||
// int expectedCount = registrationData.ShouldValidate ? 1 : 0; | ||
// UnitTestsHelper.TestSearchOperation(registrationData.ClaimValue, expectedCount, registrationData.ClaimValue); | ||
// } | ||
// finally | ||
// { | ||
// Config.FilterExactMatchOnly = false; | ||
// Config.Update(); | ||
// } | ||
//} | ||
} | ||
} |
Oops, something went wrong.