Skip to content

Commit a2fe4fb

Browse files
CopilotYvand
andauthored
Simplify InvalidGroupIdentifier test using UpdateGroupIdentifier API (#343)
* Initial plan * Add unit test for invalid GroupIdentifierConfig.EntityProperty validation Co-authored-by: Yvand <8788631+Yvand@users.noreply.github.com> * Refactor: Move InvalidGroupIdentifier test to CustomizeConfigTests Co-authored-by: Yvand <8788631+Yvand@users.noreply.github.com> * Shorten assertion message in InvalidGroupIdentifier test Co-authored-by: Yvand <8788631+Yvand@users.noreply.github.com> * Simplify InvalidGroupIdentifier test using UpdateGroupIdentifier method Co-authored-by: Yvand <8788631+Yvand@users.noreply.github.com> * Update CustomizeConfigTests.cs --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Yvand <8788631+Yvand@users.noreply.github.com> Co-authored-by: Yvan Duhamel <yvandev@outlook.fr>
1 parent 2d57809 commit a2fe4fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Yvand.EntraCP.Tests/CustomizeConfigTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,20 @@ public void ModifyUserIdentifier()
173173
configUpdated = Settings.ClaimTypes.UpdateIdentifierForGuestUsers(backupIdentityCTConfig.DirectoryObjectPropertyForGuestUsers);
174174
Assert.That(configUpdated, Is.False, $"Update user identifier of Guest UserType with the same DirectoryObjectProperty should not change anything and return false");
175175
}
176+
177+
[Test]
178+
public void InvalidGroupIdentifier()
179+
{
180+
if (Settings.ClaimTypes.GroupIdentifierConfig != null)
181+
{
182+
DirectoryObjectProperty backupGroupIdentifier = Settings.ClaimTypes.GroupIdentifierConfig.EntityProperty;
183+
// Update GroupIdentifierConfig to use UserPrincipalName, which exists for User but not Group
184+
Settings.ClaimTypes.UpdateGroupIdentifier(DirectoryObjectProperty.UserPrincipalName);
185+
186+
// ValidateConfiguration should throw InvalidOperationException because the group identifier property is invalid
187+
Assert.Throws<InvalidOperationException>(() => UnitTestsHelper.PersistedConfiguration.ApplySettings(Settings, true), "ValidateConfiguration should throw when GroupIdentifierConfig.EntityProperty doesn't exist for Group");
188+
Settings.ClaimTypes.UpdateGroupIdentifier(backupGroupIdentifier);
189+
}
190+
}
176191
}
177192
}

0 commit comments

Comments
 (0)