From 094ee161a77e62089b4cc9279e79d8e7783887f2 Mon Sep 17 00:00:00 2001 From: Alex Nemeth <80649445+definitelynotagoblin@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:39:00 -0700 Subject: [PATCH] Correct config print output (#152) * Correct config print output * Ldap config print output keys should match with json config keys --------- Co-authored-by: Rohan Vazarkar --- src/CommonLib/LdapConfig.cs | 6 +++--- test/unit/ComputerSessionProcessorTest.cs | 25 +++++++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/CommonLib/LdapConfig.cs b/src/CommonLib/LdapConfig.cs index 69c9a17e..3f3e84e4 100644 --- a/src/CommonLib/LdapConfig.cs +++ b/src/CommonLib/LdapConfig.cs @@ -38,9 +38,9 @@ public int GetGCPort(bool ssl) public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"Server: {Server}"); - sb.AppendLine($"Port: {Port}"); - sb.AppendLine($"SSLPort: {GetPort(true)}"); - sb.AppendLine($"ForceSSL: {GetPort(false)}"); + sb.AppendLine($"LdapPort: {GetPort(false)}"); + sb.AppendLine($"LdapSSLPort: {GetPort(true)}"); + sb.AppendLine($"ForceSSL: {ForceSSL}"); sb.AppendLine($"AuthType: {AuthType.ToString()}"); sb.AppendLine($"MaxConcurrentQueries: {MaxConcurrentQueries}"); if (!string.IsNullOrWhiteSpace(Username)) { diff --git a/test/unit/ComputerSessionProcessorTest.cs b/test/unit/ComputerSessionProcessorTest.cs index b8b3406f..db8111b3 100644 --- a/test/unit/ComputerSessionProcessorTest.cs +++ b/test/unit/ComputerSessionProcessorTest.cs @@ -235,11 +235,8 @@ public async Task ComputerSessionProcessor_ReadUserSessionsPrivileged_FilteringW public async Task ComputerSessionProcessor_TestTimeout() { var nativeMethods = new Mock(); nativeMethods.Setup(x => x.NetSessionEnum(It.IsAny())).Callback(() => { - Thread.Sleep(200); + Task.Delay(1000).Wait(); }).Returns(Array.Empty()); - nativeMethods.Setup(x => x.NetWkstaUserEnum(It.IsAny())).Callback(() => { - Thread.Sleep(200); - }).Returns(Array.Empty()); var processor = new ComputerSessionProcessor(new MockLdapUtils(),"", nativeMethods.Object); var receivedStatus = new List(); var machineDomainSid = $"{Consts.MockDomainSid}-1000"; @@ -252,14 +249,26 @@ public async Task ComputerSessionProcessor_TestTimeout() { Assert.Single(receivedStatus); var status = receivedStatus[0]; Assert.Equal("Timeout", status.Status); + } + + [Fact] + public async Task ComputerSessionProcessor_TestTimeoutPrivileged() { + var nativeMethods = new Mock(); + nativeMethods.Setup(x => x.NetWkstaUserEnum(It.IsAny())).Callback(() => { + Task.Delay(1000).Wait(); + }).Returns(Array.Empty()); + var processor = new ComputerSessionProcessor(new MockLdapUtils(),"", nativeMethods.Object); + var receivedStatus = new List(); + var machineDomainSid = $"{Consts.MockDomainSid}-1000"; + processor.ComputerStatusEvent += async status => { + receivedStatus.Add(status); + }; - receivedStatus.Clear(); - - results = await processor.ReadUserSessionsPrivileged("primary.testlab.local", machineDomainSid, "testlab.local", + var results = await processor.ReadUserSessionsPrivileged("primary.testlab.local", machineDomainSid, "testlab.local", TimeSpan.FromMilliseconds(1)); Assert.Empty(results.Results); Assert.Single(receivedStatus); - status = receivedStatus[0]; + var status = receivedStatus[0]; Assert.Equal("Timeout", status.Status); } }