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

Merge changes for EntraCP v27.0 to release branch #282

Merged
merged 23 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Verify PRs and commits
name: Build solution

on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
branches:
- dev
- 'releases/**'
pull_request:
branches: [ "master", "dev" ]
branches: [ "dev", "master", "releases/**" ]

jobs:
call-build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ jobs:
dtl-env-addAzureBastion: ${{ vars.dtl_addAzureBastion == 'true' }}
test-prepareSharePointVmScriptUris: ${{ vars.DTL_PrepareSharePointVmScriptUris }}
test-claimsProviderPackageUri: ${{ vars.DTL_ClaimsProviderPackageUri }}
unittestfiles-storageAccountSourceRelativePath: ${{ vars.unittestfiles_storageAccountSourceRelativePath }}
unittestfiles_azure_storage_share_relative_path: ${{ vars.unittestfiles_azure_storage_share_relative_path }}
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
azdevops-pat-registerAgent: ${{ secrets.dtl_azdevopsPassword }}
dtl-env-accountsPassword: ${{ secrets.dtl_accountsPassword }}
unittestfiles-storageAccountEndpoint: ${{ secrets.unittestfiles_storageAccountEndpoint }}
unittestfiles-storageAccountShareName: ${{ secrets.unittestfiles_storageAccountShareName }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ADO_PAT_REGISTERAGENT: ${{ secrets.ADO_PAT_REGISTERAGENT }}
DTL_ACCOUNTSPASSWORD: ${{ secrets.DTL_ACCOUNTSPASSWORD }}
UNITTESTFILES_AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.UNITTESTFILES_AZURE_STORAGE_CONNECTION_STRING }}
UNITTESTFILES_AZURE_STORAGE_SHARE_NAME: ${{ secrets.UNITTESTFILES_AZURE_STORAGE_SHARE_NAME }}
11 changes: 8 additions & 3 deletions .github/workflows/reusable-prepare-dtl-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ on:
required: true
description: 'Azure storage account file share name where unit test files are located'

permissions:
id-token: write

jobs:
create-test-environment:
if: inputs.skip-create-environment != true
Expand All @@ -94,9 +97,11 @@ jobs:
dtl_provisionSharePoint2016: ${{ contains(inputs.sharepoint-versions, '2016') }}
steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Create DevTest Labs environment
uses: azure/CLI@v1
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/run-tests-on-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Run Visual Studio tests
on: workflow_dispatch
jobs:
call-workflow-run-tests:
uses: Yvand/EntraCP/.github/workflows/reusaable-run-tests-on-runner.yml@master
with:
test_project_folder_name: 'Yvand.EntraCP-unit-tests'
8 changes: 4 additions & 4 deletions .github/workflows/stale.yaml → .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

permissions:
issues: write
pull-requests: write

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change log for ~~AzureCP~~ EntraCP

## EntraCP v27.0 - Unreleased

* Ensure that restrict searchable users feature works for all members, instead of only 100 members maximum - https://github.com/Yvand/EntraCP/issues/264
* Update the script that provisions tenant with test users and groups, to be more reliable and provision 999 users (instead of 50), so tests are more realistics
* Improve tests
* Publish a sample project that developers can use to create a custom version of EntraCP, for specific needs
* Add a [Bruno](https://www.usebruno.com/) collection to replay the requests sent to Microsoft Graph by EntraCP

## EntraCP v26.0.20240627.35 enhancements & bug-fixes - Published in June 27, 2024

* Fix an NullReferenceException in a very rare scenario where ClaimsPrincipal.Identity is null
Expand Down
41 changes: 21 additions & 20 deletions Yvand.EntraCP.Tests/BasicConfigurationTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NUnit.Framework;
using System;
using System.Linq;

namespace Yvand.EntraClaimsProvider.Tests
{
Expand All @@ -20,32 +19,33 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

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

[Test]
public void TestRandomTestGroups([Random(0, UnitTestsHelper.TestGroupsCount - 1, 5)] int idx)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
EntraIdTestGroup group = EntraIdTestGroupsSource.Groups[idx];
TestSearchAndValidateForEntraIDGroup(group);
}

[Test, TestCaseSource(typeof(EntraIdTestUsersSource), nameof(EntraIdTestUsersSource.GetTestData), null)]
public void TestAllTestUsers(EntraIdTestUser user)
{
base.TestSearchAndValidateForEntraIDUser(user);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

[Test]
public void TestRandomTestUsers([Random(0, UnitTestsHelper.TestUsersCount - 1, 5)] int idx)
public void TestAGuestUser()
{
var user = EntraIdTestUsersSource.Users[idx];
base.TestSearchAndValidateForEntraIDUser(user);
TestUser user = TestEntitySourceManager.GetOneUser(UserType.Guest);
base.TestSearchAndValidateForTestUser(user);
}

//[Test]
//public void TestRandomUsers([Random(0, UnitTestsHelper.TotalNumberTestUsers - 1, 5)] int idx)
//{
// var user = EntraIdTestUsersSource.Users[idx];
// base.TestSearchAndValidateForTestUser(user);
//}

[Test]
[Repeat(5)]
public override void TestAugmentationOfGoldUsersAgainstRandomGroups()
Expand All @@ -55,11 +55,12 @@ public override void TestAugmentationOfGoldUsersAgainstRandomGroups()

#if DEBUG
[TestCase("testEntraCPUser_001")]
[TestCase("testEntraCPUser_020")]
[TestCase("testEntraCPUser_326")]
public void DebugTestUser(string upnPrefix)
{
EntraIdTestUser user = EntraIdTestUsersSource.Users.Find(x => x.UserPrincipalName.StartsWith(upnPrefix));
base.TestSearchAndValidateForEntraIDUser(user);
TestUser user = TestEntitySourceManager.FindUser(upnPrefix);
base.TestSearchAndValidateForTestUser(user);
base.TestAugmentationAgainst1RandomGroup(user);
}

[TestCase(@"testentracp", 30, "")]
Expand Down
39 changes: 19 additions & 20 deletions Yvand.EntraCP.Tests/BypassDirectoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using Microsoft.SharePoint.Administration.Claims;
using NUnit.Framework;
using System.Security.Claims;
using Yvand.EntraClaimsProvider.Configuration;

namespace Yvand.EntraClaimsProvider.Tests
{
[TestFixture]
[Parallelizable(ParallelScope.Children)]
public class BypassDirectoryOnClaimTypesTests : ClaimsProviderTestsBase
{
string PrefixBypassUserSearch = "bypass-user:";
string PrefixBypassGroupSearch = "bypass-group:";
const string PrefixBypassUserSearch = "bypass-user:";
const string PrefixBypassGroupSearch = "bypass-group:";
public override void InitializeSettings()
{
base.InitializeSettings();
Expand All @@ -26,28 +25,28 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

[Test, TestCaseSource(typeof(EntraIdTestUsersSource), nameof(EntraIdTestUsersSource.GetTestData), null)]
public void TestAllEntraIDUsers(EntraIdTestUser user)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestSearchAndValidateForEntraIDUser(user);
base.TestSearchAndValidateForTestUser(user);
user.UserPrincipalName = user.DisplayName;
user.Mail = user.DisplayName;
user.DisplayName = $"{PrefixBypassUserSearch}{user.DisplayName}";
base.TestSearchAndValidateForEntraIDUser(user);
base.TestSearchAndValidateForTestUser(user);
}

[Test, TestCaseSource(typeof(EntraIdTestGroupsSource), nameof(EntraIdTestGroupsSource.GetTestData), new object[] { true })]
public void TestAllEntraIDGroups(EntraIdTestGroup group)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeGroups), new object[] { TestEntitySourceManager.MaxNumberOfGroupsToTest, true })]
public void TestGroups(TestGroup group)
{
TestSearchAndValidateForEntraIDGroup(group);
TestSearchAndValidateForTestGroup(group);
group.Id = group.DisplayName;
group.DisplayName = $"{PrefixBypassGroupSearch}{group.DisplayName}";
TestSearchAndValidateForEntraIDGroup(group);
TestSearchAndValidateForTestGroup(group);
}

[TestCase("bypass-user:[email protected]", 1, "[email protected]")]
[TestCase("bypass-user:", 0, "")]
[TestCase("bypass-group:", 0, "")]
[TestCase(PrefixBypassUserSearch + "[email protected]", 1, "[email protected]")]
[TestCase(PrefixBypassUserSearch, 0, "")]
[TestCase(PrefixBypassGroupSearch, 0, "")]
public void TestBypassDirectoryByClaimType(string inputValue, int expectedCount, string expectedClaimValue)
{
TestSearchOperation(inputValue, expectedCount, expectedClaimValue);
Expand Down Expand Up @@ -77,16 +76,16 @@ public override void CheckSettingsTest()
base.CheckSettingsTest();
}

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

[Test, TestCaseSource(typeof(EntraIdTestUsersSource), nameof(EntraIdTestUsersSource.GetTestData), null)]
public void TestAllEntraIDUsers(EntraIdTestUser user)
[Test, TestCaseSource(typeof(TestEntitySourceManager), nameof(TestEntitySourceManager.GetSomeUsers), new object[] { TestEntitySourceManager.MaxNumberOfUsersToTest })]
public void TestUsers(TestUser user)
{
base.TestSearchAndValidateForEntraIDUser(user);
base.TestSearchAndValidateForTestUser(user);
}

[Test]
Expand Down
Loading
Loading