You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/11/15 06:51:51 UTC

[ignite] branch gg-34169 updated: RawSecureSocketTest done with two modes - with and without client auth

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch gg-34169
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/gg-34169 by this push:
     new e313435  RawSecureSocketTest done with two modes - with and without client auth
e313435 is described below

commit e313435b1d02f3a1096be92c202f35acd3fe53bd
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 15 09:51:30 2021 +0300

    RawSecureSocketTest done with two modes - with and without client auth
---
 .../Apache.Ignite.Core.Tests.DotNetCore.csproj     |  3 +++
 .../Client/RawSecureSocketTest.cs                  | 28 +++++++++++++++++-----
 ...-ssl.xml => server-with-ssl-no-client-auth.xml} |  6 ++---
 .../Config/Client/server-with-ssl.xml              |  2 +-
 4 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.DotNetCore.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.DotNetCore.csproj
index f32f5bc..e66e469 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.DotNetCore.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.DotNetCore.csproj
@@ -110,6 +110,9 @@
     <None Update="Examples\ExpectedOutput\**">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Update="Config\Client\server-with-ssl-no-client-auth.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
 
   <ItemGroup>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSecureSocketTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSecureSocketTest.cs
index 2d74d07..3a748a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSecureSocketTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSecureSocketTest.cs
@@ -33,12 +33,20 @@ namespace Apache.Ignite.Core.Tests.Client
         [TestFixtureSetUp]
         public void FixtureSetUp()
         {
-            var igniteConfiguration = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
                 SpringConfigUrl = Path.Combine("Config", "Client", "server-with-ssl.xml")
             };
 
-            Ignition.Start(igniteConfiguration);
+            Ignition.Start(cfg);
+
+            var cfgNoClientAuth = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                SpringConfigUrl = Path.Combine("Config", "Client", "server-with-ssl-no-client-auth.xml"),
+                AutoGenerateIgniteInstanceName = true
+            };
+
+            Ignition.Start(cfgNoClientAuth);
         }
 
         [TestFixtureTearDown]
@@ -54,7 +62,7 @@ namespace Apache.Ignite.Core.Tests.Client
         public void TestHandshake([Values(true, false)] bool clientCert)
         {
             const string host = "127.0.0.1";
-            const int port = 11110;
+            var port = clientCert ? 11110 : 11120;
 
             using (var client = new TcpClient(host, port))
             using (var sslStream = new SslStream(client.GetStream(), false, ValidateServerCertificate, null))
@@ -62,7 +70,14 @@ namespace Apache.Ignite.Core.Tests.Client
                 var certsCollection = new X509CertificateCollection(new X509Certificate[] { LoadCertificateFile() });
 
 #if !NETCOREAPP
-                sslStream.AuthenticateAsClient(host, certsCollection, SslProtocols.Tls, false);
+                if (clientCert)
+                {
+                    sslStream.AuthenticateAsClient(host, certsCollection, SslProtocols.Tls, false);
+                }
+                else
+                {
+                    sslStream.AuthenticateAsClient(host);
+                }
 #else
                 if (clientCert)
                 {
@@ -142,7 +157,9 @@ namespace Apache.Ignite.Core.Tests.Client
         private static byte[] ReceiveMessage(Stream sock)
         {
             var buf = new byte[4];
-            sock.Read(buf, 0, 4);
+            var read = sock.Read(buf, 0, 4);
+
+            Assert.AreEqual(4, read);
 
             using (var stream = new BinaryHeapStream(buf))
             {
@@ -169,6 +186,5 @@ namespace Apache.Ignite.Core.Tests.Client
                 sock.Write(stream.GetArray(), 0, stream.Position);
             }
         }
-
     }
 }
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl-no-client-auth.xml
similarity index 95%
copy from modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml
copy to modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl-no-client-auth.xml
index d5e41fb..e8d5cca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl-no-client-auth.xml
@@ -30,11 +30,11 @@
         <property name="clientConnectorConfiguration">
             <bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
                 <property name="host" value="127.0.0.1"/>
-                <property name="port" value="11110"/>
+                <property name="port" value="11120"/>
                 <property name="portRange" value="10"/>
                 <property name="sslEnabled" value="true"/>
                 <property name="useIgniteSslContextFactory" value="false"/>
-                <property name="sslClientAuth" value="true"/>
+                <property name="sslClientAuth" value="false"/>
 
                 <property name="sslContextFactory">
                     <bean class="org.apache.ignite.ssl.SslContextFactory">
@@ -63,4 +63,4 @@
             </bean>
         </property>
     </bean>
-</beans>
\ No newline at end of file
+</beans>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml
index d5e41fb..93c9580 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/server-with-ssl.xml
@@ -63,4 +63,4 @@
             </bean>
         </property>
     </bean>
-</beans>
\ No newline at end of file
+</beans>