@@ -734,6 +734,78 @@ public async Task ACLProcessor_ProcessACL_Self() {
734734 Assert . False ( actual . IsInherited ) ;
735735 Assert . Equal ( actual . RightName , expectedRightName ) ;
736736 }
737+
738+ [ Fact ]
739+ public async Task ACLProcessor_ProcessACL_Self_AllGuid ( ) {
740+ var expectedPrincipalType = Label . Group ;
741+ var expectedPrincipalSID = "S-1-5-21-3130019616-2776909439-2417379446-512" ;
742+ var expectedRightName = EdgeNames . AddSelf ;
743+
744+ var mockLDAPUtils = new Mock < ILdapUtils > ( ) ;
745+ var mockSecurityDescriptor = new Mock < ActiveDirectorySecurityDescriptor > ( MockBehavior . Loose , null ) ;
746+ var mockRule = new Mock < ActiveDirectoryRuleDescriptor > ( MockBehavior . Loose , null ) ;
747+ var collection = new List < ActiveDirectoryRuleDescriptor > ( ) ;
748+ mockRule . Setup ( x => x . AccessControlType ( ) ) . Returns ( AccessControlType . Allow ) ;
749+ mockRule . Setup ( x => x . IsAceInheritedFrom ( It . IsAny < string > ( ) ) ) . Returns ( true ) ;
750+ mockRule . Setup ( x => x . IdentityReference ( ) ) . Returns ( expectedPrincipalSID ) ;
751+ mockRule . Setup ( x => x . ActiveDirectoryRights ( ) ) . Returns ( ActiveDirectoryRights . Self ) ;
752+ mockRule . Setup ( x => x . ObjectType ( ) ) . Returns ( new Guid ( ACEGuids . AllGuid ) ) ;
753+ collection . Add ( mockRule . Object ) ;
754+
755+ mockSecurityDescriptor . Setup ( m => m . GetAccessRules ( It . IsAny < bool > ( ) , It . IsAny < bool > ( ) , It . IsAny < Type > ( ) ) )
756+ . Returns ( collection ) ;
757+ mockSecurityDescriptor . Setup ( m => m . GetOwner ( It . IsAny < Type > ( ) ) ) . Returns ( ( string ) null ) ;
758+ mockLDAPUtils . Setup ( x => x . MakeSecurityDescriptor ( ) ) . Returns ( mockSecurityDescriptor . Object ) ;
759+ mockLDAPUtils . Setup ( x => x . ResolveIDAndType ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) )
760+ . ReturnsAsync ( ( true , new TypedPrincipal ( expectedPrincipalSID , expectedPrincipalType ) ) ) ;
761+ var mockData = new [ ] { LdapResult < IDirectoryObject > . Fail ( ) } ;
762+ mockLDAPUtils . Setup ( x => x . PagedQuery ( It . IsAny < LdapQueryParameters > ( ) , It . IsAny < CancellationToken > ( ) ) )
763+ . Returns ( mockData . ToAsyncEnumerable ( ) ) ;
764+
765+ var processor = new ACLProcessor ( mockLDAPUtils . Object ) ;
766+ var bytes = Utils . B64ToBytes ( AddMemberSecurityDescriptor ) ;
767+ var result = await processor . ProcessACL ( bytes , _testDomainName , Label . Group , false ) . ToArrayAsync ( ) ;
768+
769+ Assert . Single ( result ) ;
770+ var actual = result . First ( ) ;
771+ Assert . Equal ( actual . PrincipalType , expectedPrincipalType ) ;
772+ Assert . Equal ( actual . PrincipalSID , expectedPrincipalSID ) ;
773+ Assert . False ( actual . IsInherited ) ;
774+ Assert . Equal ( actual . RightName , expectedRightName ) ;
775+ }
776+
777+ [ Fact ]
778+ public async Task ACLProcessor_ProcessACL_NoAddSelfEdge ( ) {
779+ var expectedPrincipalType = Label . Group ;
780+ var expectedPrincipalSID = "S-1-5-21-3130019616-2776909439-2417379446-512" ;
781+
782+ var mockLDAPUtils = new Mock < ILdapUtils > ( ) ;
783+ var mockSecurityDescriptor = new Mock < ActiveDirectorySecurityDescriptor > ( MockBehavior . Loose , null ) ;
784+ var mockRule = new Mock < ActiveDirectoryRuleDescriptor > ( MockBehavior . Loose , null ) ;
785+ var collection = new List < ActiveDirectoryRuleDescriptor > ( ) ;
786+ mockRule . Setup ( x => x . AccessControlType ( ) ) . Returns ( AccessControlType . Allow ) ;
787+ mockRule . Setup ( x => x . IsAceInheritedFrom ( It . IsAny < string > ( ) ) ) . Returns ( true ) ;
788+ mockRule . Setup ( x => x . IdentityReference ( ) ) . Returns ( expectedPrincipalSID ) ;
789+ mockRule . Setup ( x => x . ActiveDirectoryRights ( ) ) . Returns ( ActiveDirectoryRights . Self ) ;
790+ mockRule . Setup ( x => x . ObjectType ( ) ) . Returns ( new Guid ( ACEGuids . WriteAllowedToAct ) ) ;
791+ collection . Add ( mockRule . Object ) ;
792+
793+ mockSecurityDescriptor . Setup ( m => m . GetAccessRules ( It . IsAny < bool > ( ) , It . IsAny < bool > ( ) , It . IsAny < Type > ( ) ) )
794+ . Returns ( collection ) ;
795+ mockSecurityDescriptor . Setup ( m => m . GetOwner ( It . IsAny < Type > ( ) ) ) . Returns ( ( string ) null ) ;
796+ mockLDAPUtils . Setup ( x => x . MakeSecurityDescriptor ( ) ) . Returns ( mockSecurityDescriptor . Object ) ;
797+ mockLDAPUtils . Setup ( x => x . ResolveIDAndType ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ) )
798+ . ReturnsAsync ( ( true , new TypedPrincipal ( expectedPrincipalSID , expectedPrincipalType ) ) ) ;
799+ var mockData = new [ ] { LdapResult < IDirectoryObject > . Fail ( ) } ;
800+ mockLDAPUtils . Setup ( x => x . PagedQuery ( It . IsAny < LdapQueryParameters > ( ) , It . IsAny < CancellationToken > ( ) ) )
801+ . Returns ( mockData . ToAsyncEnumerable ( ) ) ;
802+
803+ var processor = new ACLProcessor ( mockLDAPUtils . Object ) ;
804+ var bytes = Utils . B64ToBytes ( AddMemberSecurityDescriptor ) ;
805+ var result = await processor . ProcessACL ( bytes , _testDomainName , Label . Group , false ) . ToArrayAsync ( ) ;
806+
807+ Assert . Empty ( result ) ;
808+ }
737809
738810 [ Fact ]
739811 public async Task ACLProcessor_ProcessACL_ExtendedRight_Domain_Unmatched ( ) {
0 commit comments