public void CanStartContainerHost() { IContainerHostClient client = null; try { client = Service.StartContainerHost(ContainerId, Directory, JobObject, new NetworkCredential("username", "password")); ProcessRunner.Received(1).Run( Arg.Is <ProcessRunSpec>(actual => actual.ExecutablePath == @"C:\Containers\handle\bin\IronFrame.Host.exe" && actual.Arguments.SequenceEqual(new[] { ContainerId }) && actual.WorkingDirectory == @"C:\Containers\handle\user\" && (actual.Credentials != null && actual.Credentials.UserName == "username" && actual.Credentials.Password == "password") && actual.BufferedInputOutput == true ) ); } finally { if (client != null) { client.Shutdown(); } } }
public void Dispose() { if (hostClient != null) { hostClient.Dispose(); hostClient = null; } }
public ConstrainedProcessRunner(IContainerHostClient hostClient) { this.hostClient = hostClient; hostClient.Exited += (o, e) => { this.hostClient = null; }; }
public ConstrainedProcess( IContainerHostClient hostClient, Guid key, int id, Dictionary <string, string> environment) { this.hostClient = hostClient; this.key = key; this.id = id; this.Environment = environment; }
public ConstrainedProcess( IContainerHostClient hostClient, Guid key, int id, Dictionary<string,string> environment) { this.hostClient = hostClient; this.key = key; this.id = id; this.Environment = environment; }
public void CopiesDependenciesToContainerBinDirectory() { IContainerHostClient client = null; try { client = Service.StartContainerHost(ContainerId, Directory, JobObject, null); FileSystem.Received(1).CopyFile(@"C:\Path\To\IronFrame.Host.exe", @"C:\Containers\handle\bin\IronFrame.Host.exe"); FileSystem.Received(1).CopyFile(@"C:\Path\To\IronFrame.Host.exe.config", @"C:\Containers\handle\bin\IronFrame.Host.exe.config"); FileSystem.Received(1).CopyFile(@"C:\Path\To\IronFrame.Shared.dll", @"C:\Containers\handle\bin\IronFrame.Shared.dll"); } finally { if (client != null) { client.Shutdown(); } } }
public void WhenContainerHostFailsToStart_Throws() { Process.StandardError.Returns(new StringReader("Error message returned from IronFrame.Host.exe\n")); IContainerHostClient client = null; try { var ex = Record.Exception(() => client = Service.StartContainerHost("", Directory, JobObject, null)); Assert.NotNull(ex); Assert.Contains("Error message returned from IronFrame.Host.exe", ex.Message); } finally { if (client != null) { client.Shutdown(); } } }
public void WhenCredentialsAreInvalid_Throws() { ProcessRunner.Run(null).ThrowsForAnyArgs(new SecurityException()); IContainerHostClient client = null; try { var invalidCredentials = new NetworkCredential("InvalidUserName", "WrongPassword", Environment.MachineName); var ex = Record.Exception(() => client = Service.StartContainerHost(ContainerId, Directory, JobObject, invalidCredentials)); Assert.IsAssignableFrom <SecurityException>(ex); } finally { if (client != null) { client.Shutdown(); } } }
public ConstrainedProcessRunnerTests() { Client = Substitute.For <IContainerHostClient>(); Client.CreateProcess(null).ReturnsForAnyArgs(new CreateProcessResult()); }