Skip to content

Commit 281d21c

Browse files
authored
Refactor SSH client to enable support for both SshClient as well as ScpClient operations. (#547)
1 parent 5d6f28c commit 281d21c

28 files changed

+1720
-584
lines changed

src/VirtualClient/VirtualClient.Actions.FunctionalTests/WorkloadAssert.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,31 @@ public static void CommandsExecuted(DependencyFixture fixture, params string[] c
7373
/// </summary>
7474
public static void SSHCommandsExecuted(DependencyFixture fixture, params string[] commands)
7575
{
76-
List<ISshCommandProxy> sshCommands = new List<ISshCommandProxy>();
77-
List<ISshCommandProxy> sshCommandsConfirmed = new List<ISshCommandProxy>();
78-
foreach (InMemorySshClient sshClient in fixture.SshClientManager.SshClients)
76+
List<string> sshCommands = new List<string>();
77+
78+
foreach (InMemorySshClient sshClient in fixture.SshClientFactory.SshClients)
7979
{
80-
sshCommands.AddRange(sshClient.SshCommands);
80+
sshCommands.AddRange(sshClient.CommandsExecuted);
8181
}
8282

8383
foreach (string command in commands)
8484
{
85-
ISshCommandProxy matchingProcess = null;
85+
string matchingCommand = null;
86+
8687
try
8788
{
8889
// Try to match regex
89-
matchingProcess = sshCommands.FirstOrDefault(
90-
sshCommand => Regex.IsMatch($"{sshCommand.CommandText}".Trim(), command, RegexOptions.IgnoreCase)
91-
&& !sshCommandsConfirmed.Any(otherProc => object.ReferenceEquals(sshCommand, otherProc)));
90+
matchingCommand = sshCommands.FirstOrDefault(
91+
cmd => Regex.IsMatch($"{cmd}".Trim(), command, RegexOptions.IgnoreCase));
9292
}
9393
catch
9494
{
9595
}
9696

9797
// Or command exact match
98-
matchingProcess = matchingProcess ?? sshCommands.FirstOrDefault(
99-
sshCommand => $"{sshCommand.CommandText}".Trim() == command
100-
&& !sshCommandsConfirmed.Any(otherProc => object.ReferenceEquals(sshCommand, otherProc)));
98+
matchingCommand = matchingCommand ?? sshCommands.FirstOrDefault(cmd => $"{cmd}".Trim() == command);
10199

102-
Assert.IsNotNull(matchingProcess, $"The command '{command}' was not executed.");
103-
sshCommandsConfirmed.Add(matchingProcess);
100+
Assert.IsNotNull(matchingCommand, $"The command '{command}' was not executed.");
104101
}
105102
}
106103

src/VirtualClient/VirtualClient.Common.UnitTests/SshClientManagerTests.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/ISshClientManager.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/ISshClientProxy.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/ISshCommandProxy.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/SshClientManager.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/SshClientProxy.cs

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/VirtualClient/VirtualClient.Common/SshClient/SshCommandProxy.cs

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)