Skip to content

Commit

Permalink
Correct config print output (#152)
Browse files Browse the repository at this point in the history
* Correct config print output

* Ldap config print output keys should match with json config keys

---------

Co-authored-by: Rohan Vazarkar <[email protected]>
  • Loading branch information
definitelynotagoblin and rvazarkar authored Aug 15, 2024
1 parent 5feaed1 commit 094ee16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/CommonLib/LdapConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
25 changes: 17 additions & 8 deletions test/unit/ComputerSessionProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,8 @@ public async Task ComputerSessionProcessor_ReadUserSessionsPrivileged_FilteringW
public async Task ComputerSessionProcessor_TestTimeout() {
var nativeMethods = new Mock<NativeMethods>();
nativeMethods.Setup(x => x.NetSessionEnum(It.IsAny<string>())).Callback(() => {
Thread.Sleep(200);
Task.Delay(1000).Wait();
}).Returns(Array.Empty<NetSessionEnumResults>());
nativeMethods.Setup(x => x.NetWkstaUserEnum(It.IsAny<string>())).Callback(() => {
Thread.Sleep(200);
}).Returns(Array.Empty<NetWkstaUserEnumResults>());
var processor = new ComputerSessionProcessor(new MockLdapUtils(),"", nativeMethods.Object);
var receivedStatus = new List<CSVComputerStatus>();
var machineDomainSid = $"{Consts.MockDomainSid}-1000";
Expand All @@ -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>();
nativeMethods.Setup(x => x.NetWkstaUserEnum(It.IsAny<string>())).Callback(() => {
Task.Delay(1000).Wait();
}).Returns(Array.Empty<NetWkstaUserEnumResults>());
var processor = new ComputerSessionProcessor(new MockLdapUtils(),"", nativeMethods.Object);
var receivedStatus = new List<CSVComputerStatus>();
var machineDomainSid = $"{Consts.MockDomainSid}-1000";
processor.ComputerStatusEvent += async status => {

Check warning on line 263 in test/unit/ComputerSessionProcessorTest.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
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);
}
}
Expand Down

0 comments on commit 094ee16

Please sign in to comment.