From 644276562dcadd65fcb0e9a7c06c704cdda36423 Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Sat, 6 Jul 2024 21:03:57 +1000 Subject: Group Add/Remove working. Local group membership Add/Remove working, however with BUILTIN local system groups .NET doesn't appear to locate them as either groups nor basic security Principals. Still needs work to fix the test for nested groups. Ideally with some way to test for domain groups. Signed-off-by: Bevan Weiss --- src/test/burn/WixTestTools/UserGroupVerifier.cs | 24 +++++++++++++++++++--- .../ProductCommentFail/product_fail.wxs | 2 +- .../ProductFail/product_fail.wxs | 2 +- .../ProductNestedGroups/product.wxs | 6 ++---- .../UtilExtensionGroupTests.cs | 8 ++++---- 5 files changed, 29 insertions(+), 13 deletions(-) (limited to 'src/test') diff --git a/src/test/burn/WixTestTools/UserGroupVerifier.cs b/src/test/burn/WixTestTools/UserGroupVerifier.cs index 2f874057..52a1a6bf 100644 --- a/src/test/burn/WixTestTools/UserGroupVerifier.cs +++ b/src/test/burn/WixTestTools/UserGroupVerifier.cs @@ -151,7 +151,7 @@ namespace WixTestTools /// list of groups to check for membership private static void IsMemberOf(string domainName, string memberName, bool shouldBeMember, params string[] groupNames) { - GroupPrincipal group = GetGroup(domainName, memberName); + Principal group = GetPrincipal(domainName, memberName); Assert.False(null == group, String.Format("Group '{0}' was not found under domain '{1}'.", memberName, domainName)); bool missedAGroup = false; @@ -186,11 +186,29 @@ namespace WixTestTools { if (String.IsNullOrEmpty(domainName)) { - return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Machine), IdentityType.Name, groupName); + return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Machine), groupName); } else { - return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain,domainName), IdentityType.Name, groupName); + return GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain,domainName), groupName); + } + } + + /// + /// Returns the Principal object for a given name + /// + /// Domain name to look under, if Empty the LocalMachine is assumed as the domain + /// + /// Principal Object if found, or null other wise + private static Principal GetPrincipal(string domainName, string name) + { + if (String.IsNullOrEmpty(domainName)) + { + return Principal.FindByIdentity(new PrincipalContext(ContextType.Machine), name); + } + else + { + return Principal.FindByIdentity(new PrincipalContext(ContextType.Domain, domainName), name); } } } diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs index 29b908da..4e70717f 100644 --- a/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductCommentFail/product_fail.wxs @@ -8,7 +8,7 @@ - + diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs index fb35bc1e..3013e5a0 100644 --- a/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductFail/product_fail.wxs @@ -11,7 +11,7 @@ - + diff --git a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs index 191d605c..15328cb3 100644 --- a/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs +++ b/src/test/msi/TestData/UtilExtensionGroupTests/ProductNestedGroups/product.wxs @@ -12,11 +12,11 @@ - + - + @@ -26,8 +26,6 @@ - - diff --git a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs index 796c4ecd..d7cf3168 100644 --- a/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs +++ b/src/test/msi/WixToolsetTest.MsiE2E/UtilExtensionGroupTests.cs @@ -256,11 +256,11 @@ namespace WixToolsetTest.MsiE2E productNestedGroups.InstallProduct(MSIExec.MSIExecReturnCode.SUCCESS); // Verify group nested membership - UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Administrators", new string[] { "testName1", "testName2" }); - UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Power Users", new string[] { "testName1" }); + UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Authenticated Users", new string[] { "testName1", "testName2" }); + UserGroupVerifier.VerifyIsMemberOf(String.Empty, "Everyone", new string[] { "testName1" }); - UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Administrators", new string[] { "testName3" }); - UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Power Users", new string[] { "testName2", "testName3" }); + UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Authenticated Users", new string[] { "testName3" }); + UserGroupVerifier.VerifyIsNotMemberOf(String.Empty, "Everyone", new string[] { "testName2", "testName3" }); // clean up UserGroupVerifier.DeleteLocalGroup("testName1"); -- cgit v1.2.3-55-g6feb