Imported Upstream version 5.20.0.180

Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-04 20:11:37 +00:00
parent 0e2d47d1c8
commit 0510252385
3360 changed files with 83827 additions and 39243 deletions

View File

@@ -39,6 +39,8 @@ using System.ServiceModel.Description;
using SysConfig = System.Configuration.Configuration;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.MetadataTests {
public abstract class TestContext {
@@ -111,20 +113,12 @@ namespace MonoTests.System.ServiceModel.MetadataTests {
public static MetadataSet LoadMetadata (string name)
{
#if USE_EMBEDDED_METADATA
return LoadMetadataFromResource (name);
#else
return LoadMetadataFromFile (name);
#endif
}
public static XmlDocument LoadConfiguration (string name)
{
#if USE_EMBEDDED_METADATA
return LoadConfigurationFromResource (name);
#else
return LoadConfigurationFromFile (name);
#endif
}
public static void SaveMetadata (string name, MetadataSet metadata)
@@ -137,32 +131,9 @@ namespace MonoTests.System.ServiceModel.MetadataTests {
var asm = Assembly.GetExecutingAssembly ();
if (!name.EndsWith (".xml"))
name = name + ".xml";
var uri = new Uri (asm.CodeBase);
// Run from mcs/class/lib/<profile>
var path = Path.GetDirectoryName (uri.AbsolutePath);
path = Directory.GetParent (path).Parent.Parent.FullName;
path = Path.Combine (path, "System.ServiceModel");
path = Path.Combine (path, "Test");
path = Path.Combine (path, "MetadataTests");
path = Path.Combine (path, "Resources");
var filename = Path.Combine (path, name);
using (var stream = new StreamReader (filename)) {
var reader = new XmlTextReader (stream);
return MetadataSet.ReadFrom (reader);
}
}
public static MetadataSet LoadMetadataFromResource (string name)
{
var asm = Assembly.GetExecutingAssembly ();
if (!name.EndsWith (".xml"))
name = name + ".xml";
var resname = "MetadataTests.Resources." + name;
using (var stream = asm.GetManifestResourceStream (resname)) {
if (stream == null)
throw new InvalidOperationException (
"No such resource: " + name);
var filename = TestResourceHelper.GetFullPathOfResource ("Test/MetadataTests/Resources/" + name);
using (var stream = new StreamReader (filename)) {
var reader = new XmlTextReader (stream);
return MetadataSet.ReadFrom (reader);
}
@@ -173,32 +144,9 @@ namespace MonoTests.System.ServiceModel.MetadataTests {
var asm = Assembly.GetExecutingAssembly ();
if (!name.EndsWith (".config"))
name = name + ".config";
var uri = new Uri (asm.CodeBase);
var path = Path.GetDirectoryName (uri.AbsolutePath);
path = Directory.GetParent (path).Parent.Parent.FullName;
path = Path.Combine (path, "System.ServiceModel");
path = Path.Combine (path, "Test");
path = Path.Combine (path, "MetadataTests");
path = Path.Combine (path, "Resources");
var filename = Path.Combine (path, name);
using (var stream = new StreamReader (filename)) {
var xml = new XmlDocument ();
xml.Load (stream);
return xml;
}
}
public static XmlDocument LoadConfigurationFromResource (string name)
{
var asm = Assembly.GetExecutingAssembly ();
if (!name.EndsWith (".config"))
name = name + ".config";
var resname = "MetadataTests.Resources." + name;
using (var stream = asm.GetManifestResourceStream (resname)) {
if (stream == null)
throw new InvalidOperationException (
"No such resource: " + name);
var filename = TestResourceHelper.GetFullPathOfResource ("Test/MetadataTests/Resources/" + name);
using (var stream = new StreamReader (filename)) {
var xml = new XmlDocument ();
xml.Load (stream);
return xml;

View File

@@ -51,8 +51,8 @@ namespace MonoTests.System.ServiceModel.Channels
[TestFixture]
public class AsymmetricSecurityBindingElementTest
{
static X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
static X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test.cer");
static X509Certificate2 cert = new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
static X509Certificate2 cert2 = new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.cer"));
// InitiatorTokenParameters should have asymmetric key.
[Test]
@@ -246,7 +246,7 @@ namespace MonoTests.System.ServiceModel.Channels
binding, new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()));
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
cred.ClientCertificate.Authentication.CertificateValidationMode =
X509CertificateValidationMode.None;
host.Description.Behaviors.Add (cred);

View File

@@ -119,7 +119,7 @@ namespace MonoTests.System.ServiceModel.Channels
[Test]
public void ReadMessage ()
{
using (var ms = File.OpenRead ("Test/System.ServiceModel.Channels/binary-message.raw")) {
using (var ms = File.OpenRead (TestResourceHelper.GetFullPathOfResource ("Test/Resources/binary-message.raw"))) {
var session = new XmlBinaryReaderSession ();
byte [] rsbuf = new BinaryFrameSupportReader (ms).ReadSizedChunk ();

View File

@@ -215,7 +215,7 @@ namespace MonoTests.System.ServiceModel.Channels
EndpointAddress address = new EndpointAddress (
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
new X509CertificateEndpointIdentity (new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono")));
ChannelFactory<IRequestChannel> cf =
new ChannelFactory<IRequestChannel> (binding, address);
@@ -263,7 +263,7 @@ namespace MonoTests.System.ServiceModel.Channels
EndpointAddress address = new EndpointAddress (
new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()),
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
new X509CertificateEndpointIdentity (new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono")));
ChannelProtectionRequirements reqs =
new ChannelProtectionRequirements ();

View File

@@ -8,6 +8,8 @@ using System.Text;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -16,7 +18,7 @@ namespace MonoTests.System.ServiceModel.Channels
[Test]
public void CreateFault ()
{
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader ("Test/System.ServiceModel.Channels/soap-fault.xml")), 0x10000, MessageVersion.Default);
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader (TestResourceHelper.GetFullPathOfResource ("Test/Resources/soap-fault.xml"))), 0x10000, MessageVersion.Default);
MessageFault.CreateFault (msg, 0x10000);
}
@@ -33,7 +35,7 @@ namespace MonoTests.System.ServiceModel.Channels
[ExpectedException (typeof (CommunicationException))]
public void CreateFaultIncomplete ()
{
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader ("Test/System.ServiceModel.Channels/soap-fault-incomplete.xml")), 0x10000, MessageVersion.Default);
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader (TestResourceHelper.GetFullPathOfResource ("Test/Resources/soap-fault-incomplete.xml"))), 0x10000, MessageVersion.Default);
MessageFault.CreateFault (msg, 0x10000);
}
@@ -55,7 +57,7 @@ namespace MonoTests.System.ServiceModel.Channels
[ExpectedException (typeof (CommunicationException))]
public void CreateFaultIncomplete4 ()
{
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader ("Test/System.ServiceModel.Channels/soap-fault-incomplete4.xml")), 0x10000, MessageVersion.Default);
var msg = Message.CreateMessage (XmlReader.Create (new StreamReader (TestResourceHelper.GetFullPathOfResource ("Test/Resources/soap-fault-incomplete4.xml"))), 0x10000, MessageVersion.Default);
MessageFault.CreateFault (msg, 0x10000);
}

View File

@@ -430,7 +430,7 @@ namespace MonoTests.System.ServiceModel.Channels
Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
ClientCredentials cred = new ClientCredentials ();
cred.ClientCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
IChannelFactory<IReplyChannel> ch = b.BuildChannelFactory<IReplyChannel> (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), cred);
try {
ch.Open ();
@@ -458,7 +458,7 @@ namespace MonoTests.System.ServiceModel.Channels
Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
IChannelListener<IReplyChannel> ch = b.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), cred);
try {
ch.Open ();
@@ -480,7 +480,7 @@ namespace MonoTests.System.ServiceModel.Channels
be.EndpointSupportingTokenParameters.Endorsing.Add (
new UserNameSecurityTokenParameters ());
Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
X509Certificate2 cert = new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
EndpointAddress ea = new EndpointAddress (new Uri ("http://localhost:" + NetworkHelpers.FindFreePort ()), new X509CertificateEndpointIdentity (cert));
CalcProxy client = new CalcProxy (b, ea);
client.ClientCredentials.UserName.UserName = "rupert";

View File

@@ -37,6 +37,8 @@ using System.ServiceModel.Security;
using System.Text;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -100,7 +102,7 @@ namespace MonoTests.System.ServiceModel.Channels
{
ServiceCredentials cred = new ServiceCredentials ();
X509Certificate2 cert =
new X509Certificate2 ("Test/Resources/test.cer");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.cer"));
cred.ServiceCertificate.Certificate = cert;
X509CertificateEndpointIdentity ident =
new X509CertificateEndpointIdentity (cert);

View File

@@ -42,6 +42,8 @@ using System.ServiceModel.Security.Tokens;
using System.Xml;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Channels
{
[TestFixture]
@@ -150,7 +152,7 @@ namespace MonoTests.System.ServiceModel.Channels
EndpointAddress CreateX509EndpointAddress (string uri)
{
EndpointIdentity identity =
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
new X509CertificateEndpointIdentity (new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono"));
return new EndpointAddress (new Uri (uri), identity);
}
@@ -161,7 +163,7 @@ namespace MonoTests.System.ServiceModel.Channels
new BindingParameterCollection ();
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.pfx", "mono");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
IServiceBehavior sb = cred;
sb.AddBindingParameters (null, null, null, bpl);
IChannelListener<IReplyChannel> listener = rb.BuildChannelListener<IReplyChannel> (bpl);
@@ -239,7 +241,7 @@ namespace MonoTests.System.ServiceModel.Channels
return null;
});
ClientCredentials cred = new ClientCredentials ();
cred.ServiceCertificate.DefaultCertificate = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
cred.ServiceCertificate.DefaultCertificate = new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono");
BindingParameterCollection parameters =
new BindingParameterCollection ();
parameters.Add (cred);
@@ -486,7 +488,7 @@ namespace MonoTests.System.ServiceModel.Channels
new BindingParameterCollection ();
ServiceCredentials cred = new ServiceCredentials ();
cred.ServiceCertificate.Certificate =
new X509Certificate2 ("Test/Resources/test.cer");
new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.cer"));
IServiceBehavior sb = cred;
sb.AddBindingParameters (null, null, null, bpl);
IChannelListener<IReplyChannel> listener = rb.BuildChannelListener<IReplyChannel> (bpl);
@@ -551,7 +553,7 @@ Console.Error.WriteLine ("Processing a reply.");
public void FullRequest ()
{
EndpointIdentity identity =
new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
new X509CertificateEndpointIdentity (new X509Certificate2 (TestResourceHelper.GetFullPathOfResource ("Test/Resources/test.pfx"), "mono"));
EndpointAddress address =
new EndpointAddress (new Uri ("stream:dummy"), identity);

View File

@@ -34,6 +34,8 @@ using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Configuration;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
@@ -41,7 +43,7 @@ namespace MonoTests.System.ServiceModel.Configuration
{
[Test]
public void ReadConfiguration () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/client.endpoint").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/client.endpoint")).GetSectionGroup ("system.serviceModel");
AddressHeaderCollection col = config.Client.Endpoints [0].Headers.Headers;
Assert.AreEqual (2, col.Count, "count");

View File

@@ -34,6 +34,8 @@ using System.ServiceModel.Configuration;
using System.ServiceModel.Channels;
using System.Configuration;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
@@ -44,7 +46,7 @@ namespace MonoTests.System.ServiceModel.Configuration
[Category("NotWorking")]
[Ignore ("fails under .NET; I never bothered to fix the test")]
public void UserConfiguration () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/userBinding").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/userBinding")).GetSectionGroup ("system.serviceModel");
BindingsSection section = config.Bindings;

View File

@@ -37,13 +37,15 @@ using System.Net;
using System.ServiceModel;
using System.Net.Security;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class CustomBindingElementTest
{
CustomBindingCollectionElement OpenConfig () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/customBinding").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/customBinding")).GetSectionGroup ("system.serviceModel");
Assert.AreEqual (7, config.Bindings.CustomBinding.Bindings.Count, "CustomBinding count");
return config.Bindings.CustomBinding;
}

View File

@@ -37,13 +37,15 @@ using System.Security.Cryptography.X509Certificates;
using System.ServiceModel.Security;
using System.Security.Principal;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
public class EndpointBehaviorElementTest
{
EndpointBehaviorElement OpenConfig () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/endpointBehaviors").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/endpointBehaviors")).GetSectionGroup ("system.serviceModel");
return config.Behaviors.EndpointBehaviors [0];
}

View File

@@ -33,6 +33,8 @@ using System.ServiceModel.Configuration;
using System.Configuration;
using NUnit.Framework;
using MonoTests.Helpers;
namespace MonoTests.System.ServiceModel.Configuration
{
[TestFixture]
@@ -63,7 +65,7 @@ namespace MonoTests.System.ServiceModel.Configuration
[Test]
public void BindingExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/extensions")).GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (BasicHttpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["basicHttpBinding"].Type, "baseHttpBinding");
Assert.AreEqual (typeof (NetTcpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["netTcpBinding"].Type, "baseHttpBinding");
@@ -74,7 +76,7 @@ namespace MonoTests.System.ServiceModel.Configuration
[Test]
public void BehaviorExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/extensions")).GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (ServiceAuthorizationElement).AssemblyQualifiedName, config.Extensions.BehaviorExtensions ["serviceAuthorization"].Type, "serviceAuthorization");
Assert.AreEqual ("MyBehaviorElement", config.Extensions.BehaviorExtensions ["behaviorExtensions1"].Type, "MyBehaviorElement");
@@ -83,7 +85,7 @@ namespace MonoTests.System.ServiceModel.Configuration
[Test]
public void BindingElementExtensions () {
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (TestResourceHelper.GetFullPathOfResource ("Test/config/extensions")).GetSectionGroup ("system.serviceModel");
Assert.AreEqual (typeof (BinaryMessageEncodingElement).AssemblyQualifiedName, config.Extensions.BindingElementExtensions ["binaryMessageEncoding"].Type, "binaryMessageEncoding");
Assert.AreEqual ("MyBindingElementElement", config.Extensions.BindingElementExtensions ["bindingElementExtensions1"].Type, "MyBindingElementElement");

Some files were not shown because too many files have changed in this diff Show More