You've already forked linux-packaging-mono
Imported Upstream version 4.4.0.182
Former-commit-id: ea38b2115ac3af9a394fe6cddf2be2acd11bc002
This commit is contained in:
parent
ee13743634
commit
180e8b1935
@@ -93,80 +93,6 @@ public class SslStreamTest {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClientCipherSuitesCallback ()
|
||||
{
|
||||
try {
|
||||
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
|
||||
};
|
||||
// client will only offers AES 128 - that's fine since the server support it (and many more ciphers)
|
||||
AuthenticateClientAndServer_ClientSendsNoData ();
|
||||
}
|
||||
finally {
|
||||
ServicePointManager.ClientCipherSuitesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ServerCipherSuitesCallback ()
|
||||
{
|
||||
try {
|
||||
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
|
||||
};
|
||||
// server only accept AES 256 - that's fine since the client support it (and many more ciphers)
|
||||
AuthenticateClientAndServer_ClientSendsNoData ();
|
||||
}
|
||||
finally {
|
||||
ServicePointManager.ServerCipherSuitesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CipherSuitesCallbacks ()
|
||||
{
|
||||
try {
|
||||
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
|
||||
};
|
||||
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
|
||||
};
|
||||
// both client and server supports AES (128 and 256) - server will select 128 (first choice)
|
||||
AuthenticateClientAndServer_ClientSendsNoData ();
|
||||
}
|
||||
finally {
|
||||
ServicePointManager.ClientCipherSuitesCallback = null;
|
||||
ServicePointManager.ServerCipherSuitesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MismatchedCipherSuites ()
|
||||
{
|
||||
try {
|
||||
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
|
||||
};
|
||||
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
|
||||
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
|
||||
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
|
||||
};
|
||||
// mismatch! server will refuse and send back an alert
|
||||
AuthenticateClientAndServer (false, false);
|
||||
}
|
||||
finally {
|
||||
ServicePointManager.ClientCipherSuitesCallback = null;
|
||||
ServicePointManager.ServerCipherSuitesCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartClientAndAuthenticate (ClientServerState state,
|
||||
IPEndPoint endPoint) {
|
||||
try {
|
||||
|
@@ -0,0 +1,60 @@
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System.Net.Sockets
|
||||
{
|
||||
[TestFixture]
|
||||
public class SocketAcceptAsyncTest
|
||||
{
|
||||
[Test]
|
||||
public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
|
||||
{
|
||||
var readyEvent = new ManualResetEvent(false);
|
||||
var mainEvent = new ManualResetEvent(false);
|
||||
var listenSocket = new Socket(
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
var serverSocket = new Socket(
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
Socket acceptedSocket = null;
|
||||
|
||||
ThreadPool.QueueUserWorkItem(_ =>
|
||||
{
|
||||
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
|
||||
listenSocket.Listen(1);
|
||||
|
||||
var asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
|
||||
asyncEventArgs.Completed += (s, e) =>
|
||||
{
|
||||
acceptedSocket = e.AcceptSocket;
|
||||
mainEvent.Set();
|
||||
};
|
||||
|
||||
readyEvent.Set();
|
||||
|
||||
if (listenSocket.AcceptAsync(asyncEventArgs))
|
||||
return;
|
||||
acceptedSocket = asyncEventArgs.AcceptSocket;
|
||||
mainEvent.Set();
|
||||
});
|
||||
Assert.IsTrue(readyEvent.WaitOne(1500));
|
||||
|
||||
var clientSocket = new Socket(
|
||||
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
clientSocket.Connect(listenSocket.LocalEndPoint);
|
||||
clientSocket.NoDelay = true;
|
||||
|
||||
Assert.IsTrue(mainEvent.WaitOne(1500));
|
||||
Assert.AreEqual(serverSocket, acceptedSocket);
|
||||
mainEvent.Reset();
|
||||
|
||||
if (acceptedSocket != null)
|
||||
acceptedSocket.Close();
|
||||
|
||||
listenSocket.Close();
|
||||
readyEvent.Close();
|
||||
mainEvent.Close();
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,13 +7,6 @@
|
||||
// (C) 2001 Mads Pultz
|
||||
// (C) 2003 Martin Willemoes Hansen
|
||||
//
|
||||
// This test assumes the following:
|
||||
// 1) The following Internet sites exist:
|
||||
// www.go-mono.com with IP address 64.14.94.188
|
||||
// info.diku.dk with IP address 130.225.96.4
|
||||
// 2) The following DNS name does not exist:
|
||||
// www.hopefullydoesnotexist.dk
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -28,12 +21,12 @@ namespace MonoTests.System.Net
|
||||
[TestFixture]
|
||||
public class DnsTest
|
||||
{
|
||||
private String site1Name = "jenkins.mono-project.com",
|
||||
site1Dot = "162.253.133.196",
|
||||
site2Name = "info.diku.dk",
|
||||
site2Dot = "130.225.96.4",
|
||||
private String site1Name = "google-public-dns-a.google.com",
|
||||
site1Dot = "8.8.8.8",
|
||||
site2Name = "google-public-dns-b.google.com",
|
||||
site2Dot = "8.8.4.4",
|
||||
noneExistingSite = "unlikely.xamarin.com";
|
||||
private uint site1IP = 1852407392, site2IP = 2195808260; // Big-Endian
|
||||
private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
|
||||
|
||||
[Test]
|
||||
public void AsyncGetHostByName ()
|
||||
@@ -44,7 +37,7 @@ namespace MonoTests.System.Net
|
||||
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
|
||||
IPHostEntry entry = Dns.EndGetHostByName (async);
|
||||
SubTestValidIPHostEntry (entry);
|
||||
Assert.IsTrue (entry.HostName == "jenkins.mono-project.com");
|
||||
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");
|
||||
}
|
||||
|
||||
void GetHostByNameCallback (IAsyncResult ar)
|
||||
@@ -189,7 +182,7 @@ namespace MonoTests.System.Net
|
||||
[Test]
|
||||
public void GetHostByName ()
|
||||
{
|
||||
SubTestGetHostByName ("jenkins.mono-project.com", site1Dot);
|
||||
SubTestGetHostByName (site1Name, site1Dot);
|
||||
SubTestGetHostByName (site2Name, site2Dot);
|
||||
try {
|
||||
var entry = Dns.GetHostByName (noneExistingSite);
|
||||
|
Reference in New Issue
Block a user