Compare commits

...

1 Commits

View File

@ -6,6 +6,8 @@ namespace dopt.DeltaBarth.Tests
{ {
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Python.Runtime;
internal class Config internal class Config
{ {
public string apiUrl; public string apiUrl;
@ -56,6 +58,41 @@ namespace dopt.DeltaBarth.Tests
{ {
base.Setup(datenPfad, basisApiUrl); 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] [TestClass]
public sealed class PluginTest public sealed class PluginTest
@ -267,5 +304,19 @@ namespace dopt.DeltaBarth.Tests
Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code); Assert.AreEqual((int)StatusCodes.VerbindungTimeout, res.status.code);
test.Dispose(); 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();
}
} }
} }