Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void TestOnStartThenStop()
controller.WaitForStatus(ServiceControllerStatus.Stopped);
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/34801")]
[ConditionalFact(nameof(IsProcessElevated))]
public void TestOnStartWithArgsThenStop()
{
Expand Down Expand Up @@ -175,9 +176,8 @@ public void TestOnContinueBeforePause()
public void LogWritten()
{
string serviceName = Guid.NewGuid().ToString();
// The default username for installing the service is NT AUTHORITY\\LocalService which does not have access to EventLog.
// If the username is null, then the service is created under LocalSystem Account which have access to EventLog.
var testService = new TestServiceProvider(serviceName, userName: null);
var testService = new TestServiceProvider(serviceName);
Assert.True(EventLog.SourceExists(serviceName));
testService.DeleteTestServices();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace System.ServiceProcess.Tests
internal sealed class TestServiceProvider
{
private const int readTimeout = 60000;
public const string LocalServiceName = "NT AUTHORITY\\LocalService";

private static readonly Lazy<bool> s_runningWithElevatedPrivileges = new Lazy<bool>(
() => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator));
Expand Down Expand Up @@ -48,7 +47,6 @@ public NamedPipeClientStream Client
public readonly string TestMachineName;
public readonly TimeSpan ControlTimeout;
public readonly string TestServiceName;
public readonly string Username;
public readonly string TestServiceDisplayName;

private readonly TestServiceProvider _dependentServices;
Expand All @@ -65,14 +63,13 @@ public TestServiceProvider()
CreateTestServices();
}

public TestServiceProvider(string serviceName, string userName = LocalServiceName)
public TestServiceProvider(string serviceName)
{
TestMachineName = ".";
ControlTimeout = TimeSpan.FromSeconds(120);
TestServiceName = serviceName;
TestServiceDisplayName = "Test Service " + TestServiceName;
Username = userName;


// Create the service
CreateTestServices();
}
Expand All @@ -95,7 +92,7 @@ private void CreateTestServices()
testServiceInstaller.ServiceName = TestServiceName;
testServiceInstaller.DisplayName = TestServiceDisplayName;
testServiceInstaller.Description = "__Dummy Test Service__";
testServiceInstaller.Username = Username;
testServiceInstaller.Username = null;

if (_dependentServices != null)
{
Expand Down