Skip to content

Commit 1db125f

Browse files
author
Lee Fine
committed
initial-integration-tests
1 parent 09f9bae commit 1db125f

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

RemoteFileIntegrationTests/BaseTest.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-

1+
using Moq;
22
using System.Runtime.CompilerServices;
33
using Renci.SshNet;
4+
using Keyfactor.Orchestrators.Extensions.Interfaces;
5+
using static Org.BouncyCastle.Math.EC.ECCurve;
6+
using Keyfactor.Orchestrators.Extensions;
47

58
namespace RemoteFileIntegrationTests
69
{
@@ -77,6 +80,19 @@ public void Dispose()
7780

7881
public abstract void TearDown();
7982

83+
internal Mock<IPAMSecretResolver> GetMockSecretResolver(JobConfiguration config)
84+
{
85+
Mock<IPAMSecretResolver> secretResolver = new Mock<IPAMSecretResolver>();
86+
secretResolver
87+
.Setup(p => p.Resolve(It.Is<string>(q => q == config.ServerUsername)))
88+
.Returns(config.ServerUsername);
89+
secretResolver
90+
.Setup(p => p.Resolve(It.Is<string>(q => q == config.ServerPassword)))
91+
.Returns(config.ServerPassword);
92+
93+
return secretResolver;
94+
}
95+
8096
private void CreateFileLinux(string fileName, byte[] contents)
8197
{
8298
using (ScpClient client = new ScpClient(Connection))

RemoteFileIntegrationTests/RFPEMInventoryTests.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
using Keyfactor.Extensions.Orchestrator.RemoteFile.PEM;
12
using Keyfactor.Orchestrators.Extensions;
3+
using Keyfactor.Orchestrators.Extensions.Interfaces;
4+
using Moq;
25

36
namespace RemoteFileIntegrationTests
47
{
@@ -7,7 +10,19 @@ public class RFPEMInventoryTests : BaseRFPEMTest
710
[Fact]
811
public void RFPEM_Inventory_InternalPrivateKey_EmptyStore_Linux_Test0001()
912
{
10-
InventoryJobConfiguration config = BuildBaseInvConfig();
13+
InventoryJobConfiguration config = BuildBaseInventoryConfig();
14+
config.CertificateStoreDetails.ClientMachine = Environment.GetEnvironmentVariable("LinuxServer");
15+
config.CertificateStoreDetails.StorePath = Environment.GetEnvironmentVariable("LinuxStorePath");
16+
config.CertificateStoreDetails.Properties = "{}";
17+
//config.CertificateStoreDetails.Properties = JsonConvert.SerializeObject(new Dictionary<string, string?>() { { "SeparatePrivateKeyFilePath", Environment.GetEnvironmentVariable("LinuxStorePath") + "Test0001.key" } });
18+
config.CertificateStoreDetails.ClientMachine = Environment.GetEnvironmentVariable("LinuxServer");
19+
20+
Mock<IPAMSecretResolver> secretResolver = GetMockSecretResolver(config);
21+
22+
Mock<SubmitInventoryUpdate> submitInventoryUpdate = new Mock<SubmitInventoryUpdate>();
23+
24+
Inventory inventory = new Inventory(secretResolver.Object);
25+
inventory.ProcessJob()
1126
}
1227

1328
public override void SetUp()
@@ -26,14 +41,17 @@ public override void TearDown()
2641
RemoveStore("Test0004", true, STORE_ENVIRONMENT_ENUM.LINUX);
2742
}
2843

29-
private InventoryJobConfiguration BuildBaseInvConfig()
44+
private InventoryJobConfiguration BuildBaseInventoryConfig()
3045
{
3146
InventoryJobConfiguration config = new InventoryJobConfiguration();
3247
config.Capability = "Inventory";
3348
config.CertificateStoreDetails = new CertificateStore();
3449
config.JobId = new Guid();
3550
config.JobProperties = new Dictionary<string, object>();
36-
51+
config.ServerUsername = Environment.GetEnvironmentVariable("LinuxUserId");
52+
config.ServerPassword = Environment.GetEnvironmentVariable("LinuxUserPassword");
53+
54+
return config;
3755
}
3856
}
3957
}

RemoteFileIntegrationTests/RemoteFileIntegrationTests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
<PackageReference Include="coverlet.collector" Version="6.0.0" />
1515
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="0.7.0" />
1616
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
17+
<PackageReference Include="Moq" Version="4.20.72" />
1718
<PackageReference Include="SSH.NET" Version="2024.0.0" />
1819
<PackageReference Include="xunit" Version="2.5.3" />
1920
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
2021
</ItemGroup>
2122

23+
<ItemGroup>
24+
<ProjectReference Include="..\RemoteFile\RemoteFile.csproj" />
25+
</ItemGroup>
26+
2227
<ItemGroup>
2328
<Using Include="Xunit" />
2429
</ItemGroup>

0 commit comments

Comments
 (0)