Skip to content

Commit

Permalink
chore: more mock fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Jul 9, 2024
1 parent 8ec0cae commit fbc281b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/unit/ACLProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public async Task ACLProcessor_ProcessACL_Yields_Owns_ACE()
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedSID, expectedPrincipalType)));

var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
var result = await processor.ProcessACL(bytes, _testDomainName, Label.User, false).ToArrayAsync();
Expand Down Expand Up @@ -394,6 +398,9 @@ public async Task ACLProcessor_ProcessACL_GenericAll_Unmatched_Guid()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true,new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down Expand Up @@ -425,6 +432,9 @@ public async Task ACLProcessor_ProcessACL_GenericAll()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down Expand Up @@ -462,6 +472,9 @@ public async Task ACLProcessor_ProcessACL_WriteDacl()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down Expand Up @@ -499,6 +512,9 @@ public async Task ACLProcessor_ProcessACL_WriteOwner()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down Expand Up @@ -536,6 +552,9 @@ public async Task ACLProcessor_ProcessACL_Self()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(AddMemberSecurityDescriptor);
Expand Down Expand Up @@ -572,6 +591,9 @@ public async Task ACLProcessor_ProcessACL_ExtendedRight_Domain_Unmatched()
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down Expand Up @@ -678,6 +700,9 @@ public async Task ACLProcessor_ProcessACL_ExtendedRight_Domain_DSReplicationGetC
mockLDAPUtils.Setup(x => x.MakeSecurityDescriptor()).Returns(mockSecurityDescriptor.Object);
mockLDAPUtils.Setup(x => x.ResolveIDAndType(It.IsAny<string>(), It.IsAny<string>()))
.ReturnsAsync((true, new TypedPrincipal(expectedPrincipalSID, expectedPrincipalType)));
var mockData = new[] { LdapResult<ISearchResultEntry>.Fail() };
mockLDAPUtils.Setup(x => x.Query(It.IsAny<LdapQueryParameters>(), It.IsAny<CancellationToken>()))
.Returns(mockData.ToAsyncEnumerable());

var processor = new ACLProcessor(mockLDAPUtils.Object);
var bytes = Helpers.B64ToBytes(UnProtectedUserNtSecurityDescriptor);
Expand Down

0 comments on commit fbc281b

Please sign in to comment.