add context tests for injecting system cert stores, related to delta-barth/delta-barth-py#34
This commit is contained in:
parent
1b99564fa9
commit
feb91abf32
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user