Skip to content

Commit

Permalink
Add support integration tests on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
harrison314 committed Jul 14, 2023
1 parent 6bde8ed commit 6a7735c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
22 changes: 20 additions & 2 deletions src/Test/BouncyHsm.Pkcs11IntegrationTests/AssemblyTestConstants.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
namespace BouncyHsm.Pkcs11IntegrationTests;
using System.Runtime.InteropServices;

namespace BouncyHsm.Pkcs11IntegrationTests;

internal static class AssemblyTestConstants
{
public const string P11LibPath = "BouncyHsm.Pkcs11Lib.dll";
public static string P11LibPath
{
get
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return "BouncyHsm.Pkcs11Lib.dll";
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return "BouncyHsm.Pkcs11Lib-x64.so";
}

throw new PlatformNotSupportedException();
}
}

public const string UserPin = "123456";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
<PackageReference Include="PkcsExtensions" Version="1.2.2" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="Exists('../../x64/Debug/BouncyHsm.Pkcs11Lib.dll')">
<None Include="../../x64/Debug/BouncyHsm.Pkcs11Lib.dll">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Condition="Exists('../../../build_linux/BouncyHsm.Pkcs11Lib-x64.so')">
<None Include="../../build_linux/BouncyHsm.Pkcs11Lib-x64.so">
<Link>%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
13 changes: 10 additions & 3 deletions src/Test/BouncyHsm.Pkcs11IntegrationTests/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## How to run unit test

1. Create empty slot if not exists with following parameters:
1. Build native library
1.1 On WIndows using Vusial Studio
1.2 On Debian/Ubuntu use makefile
2. Run Bouncy Hsm on localhost.
3. Create empty slot if not exists with following parameters:

```json
{
Expand All @@ -19,5 +23,8 @@
}
```

2. Run Bouncy Hsm on localhost.
3. Run tests.
3. Run tests using:
```
dotnet clean
dotnet test
```

0 comments on commit 6a7735c

Please sign in to comment.