Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct config print output #152

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 +235,12 @@
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";
processor.ComputerStatusEvent += async status => {

Check warning on line 243 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.

Check warning on line 243 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);
};
var results = await processor.ReadUserSessions("primary.testlab.local", machineDomainSid, "testlab.local",
Expand All @@ -252,14 +249,26 @@
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.

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
Loading