3 Commits

2 changed files with 53 additions and 2 deletions

View File

@@ -6,6 +6,8 @@ namespace dopt.DeltaBarth.Tests
{
using System.Text.Encodings.Web;
using Microsoft.Extensions.Configuration;
using Python.Runtime;
internal class Config
{
public string apiUrl;
@@ -56,6 +58,41 @@ namespace dopt.DeltaBarth.Tests
{
base.Setup(datenPfad, basisApiUrl);
}
public void TruststoreInjected()
{
using (Py.GIL())
{
string code = @"
import pip_system_certs.wrapt_requests
pip_system_certs.wrapt_requests.inject_truststore()
import ssl
var1 = str(ssl.create_default_context())
var2 = str(ssl.get_default_verify_paths())
";
dynamic pyScope = Py.CreateScope();
pyScope.Exec(code);
dynamic var1 = pyScope.Get("var1");
dynamic var2 = pyScope.Get("var2");
Console.WriteLine($"Retrieved from Python: {var1}, {var2}");
}
}
public void TruststoreDefault()
{
using (Py.GIL())
{
string code = @"
import ssl
var1 = str(ssl.create_default_context())
var2 = str(ssl.get_default_verify_paths())
";
dynamic pyScope = Py.CreateScope();
pyScope.Exec(code);
dynamic var1 = pyScope.Get("var1");
dynamic var2 = pyScope.Get("var2");
Console.WriteLine($"Retrieved from Python: {var1}, {var2}");
}
}
}
[TestClass]
public sealed class PluginTest
@@ -267,5 +304,19 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code);
test.Dispose();
}
[TestMethod]
public void Set_SSLCertPaths_Inject_Test()
{
var test = new TPlugin();
test.TruststoreInjected();
test.Dispose();
}
[TestMethod]
public void Set_SSLCertPaths_Default_Test()
{
var test = new TPlugin();
test.TruststoreDefault();
test.Dispose();
}
}
}

View File

@@ -6,12 +6,12 @@
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
<Version>0.4.0</Version>
<Version>0.4.1</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="dopt.SharpPython" Version="0.4.2" />
<PackageReference Include="dopt.SharpPython" Version="0.4.4" />
</ItemGroup>
</Project>