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

Rewrite everything #187

Merged
merged 56 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8a2ff12
very early work
Yvand Jul 21, 2023
b81e386
continue work
Yvand Jul 24, 2023
4f959fc
in progress
Yvand Jul 24, 2023
d8a9cb8
in progress
Yvand Jul 24, 2023
c164a58
in progress
Yvand Jul 24, 2023
88dc67b
in progress
Yvand Jul 24, 2023
3180a46
in progress
Yvand Jul 24, 2023
0a0462f
in progress
Yvand Jul 24, 2023
48fb870
in progress
Yvand Jul 25, 2023
21695cd
in progress
Yvand Jul 25, 2023
15d25df
in progress
Yvand Jul 25, 2023
c22458b
in progress
Yvand Jul 25, 2023
3e065bd
in progress
Yvand Jul 25, 2023
a469372
reorganize structure of admin pages and features
Yvand Jul 26, 2023
8744832
in progress
Yvand Jul 26, 2023
32b18b9
in progress
Yvand Jul 26, 2023
dd5e905
in progress
Yvand Jul 26, 2023
e94c2be
in progress
Yvand Jul 27, 2023
557f52a
in progress
Yvand Jul 27, 2023
9f1ff74
Update AzureCPSE.cs
Yvand Jul 27, 2023
1510326
rename properties
Yvand Jul 27, 2023
6074acd
in progress
Yvand Jul 27, 2023
9168bc5
rename class GlobalSettings to GlobalSettingsUserControl
Yvand Jul 27, 2023
8ac03b3
in progress
Yvand Jul 27, 2023
493fd13
fix tests
Yvand Jul 27, 2023
d47f51f
update tests
Yvand Jul 28, 2023
16536a5
update tests
Yvand Jul 28, 2023
0bcf2dd
in progress
Yvand Jul 28, 2023
af11c87
in progress
Yvand Jul 28, 2023
bedd715
in progress
Yvand Jul 31, 2023
ef84f95
fix extension attributes
Yvand Aug 1, 2023
cb54ebd
update logging
Yvand Aug 2, 2023
f2f8762
in progress
Yvand Aug 2, 2023
b10ff5a
update design of tests
Yvand Aug 2, 2023
f6c8832
update tests
Yvand Aug 2, 2023
1077b22
rewrite tests
Yvand Aug 3, 2023
e8900dd
update tests
Yvand Aug 3, 2023
0a35649
Update AzureADEntityProvider.cs
Yvand Aug 3, 2023
28ed999
update tests
Yvand Aug 3, 2023
2246ec0
Update AzureADEntityProvider.cs
Yvand Aug 3, 2023
fb7d911
in progress
Yvand Aug 3, 2023
b633e66
update tests
Yvand Aug 7, 2023
c1b7598
rename class
Yvand Aug 7, 2023
61d8164
Update GuestAccountsUPNTests.cs
Yvand Aug 7, 2023
9758eb4
update Microsoft.Graph
Yvand Aug 7, 2023
f13d77f
improve BuildFilter
Yvand Aug 7, 2023
e6063bb
Improve BuildFilter
Yvand Aug 7, 2023
492e0f3
Update AzureADEntityProvider.cs
Yvand Aug 7, 2023
57d6dc5
update the copy of persisted objects
Yvand Aug 8, 2023
f724500
in progress
Yvand Aug 8, 2023
640a40a
Move the generic class on the persisted object directly (#190)
Yvand Aug 14, 2023
0cfe7e2
in progress
Yvand Aug 14, 2023
b7b6c49
update Microsoft.Graph to 5.22.0
Yvand Aug 14, 2023
b2e21c7
update tests
Yvand Aug 15, 2023
b22537d
in progress
Yvand Aug 15, 2023
abb697b
update code
Yvand Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions AzureCP.Tests/AzureCP.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<ProjectGuid>{DB8C79E5-F7F7-4841-8A8C-A9832A9CAE88}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AzureCP.Tests</RootNamespace>
<AssemblyName>AzureCP.Tests</AssemblyName>
<RootNamespace>Yvand.ClaimsProviders.Tests</RootNamespace>
<AssemblyName>AzureCPSE.Tests</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -47,17 +47,16 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExcludeAllUserAccountsTests.cs" />
<Compile Include="BasicTests.cs" />
<Compile Include="ExcludeAUserTypeTests.cs" />
<Compile Include="EntityTestsBase.cs" />
<Compile Include="ExcludeMemberUserAccountsTests.cs" />
<Compile Include="ExcludeGuestUserAccountsTests.cs" />
<Compile Include="GuestAccountsUPNTests.cs" />
<Compile Include="BackupCurrentConfig.cs" />
<Compile Include="RequireExactMatchTests.cs" />
<Compile Include="UnitTestsHelper.cs" />
<Compile Include="CustomConfigTests.cs" />
<Compile Include="ModifyConfigTests.cs" />
<Compile Include="CustomizeConfigTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WrongConfigTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="local.runsettings" />
Expand Down
46 changes: 0 additions & 46 deletions AzureCP.Tests/BackupCurrentConfig.cs

This file was deleted.

66 changes: 66 additions & 0 deletions AzureCP.Tests/BasicTests.cs
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
}
}
82 changes: 33 additions & 49 deletions AzureCP.Tests/CustomConfigTests.cs
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();
// }
//}
}
}
Loading
Loading