You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@@ -2,7 +2,8 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.1.0.0</AssemblyVersion>
|
||||
<AssemblyVersion>4.1.1.0</AssemblyVersion>
|
||||
<AssemblyKey>MSFT</AssemblyKey>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
<IsUAP>true</IsUAP>
|
||||
</PropertyGroup>
|
||||
|
@@ -88,6 +88,9 @@
|
||||
<data name="net_MethodNotImplementedException" xml:space="preserve">
|
||||
<value>This method is not implemented by this class.</value>
|
||||
</data>
|
||||
<data name="net_OperationNotSupportedException" xml:space="preserve">
|
||||
<value>This operation is not supported.</value>
|
||||
</data>
|
||||
<data name="net_PropertyNotImplementedException" xml:space="preserve">
|
||||
<value>This property is not implemented by this class.</value>
|
||||
</data>
|
||||
@@ -145,7 +148,7 @@
|
||||
<data name="net_wrongversion" xml:space="preserve">
|
||||
<value>Only HTTP/1.0 and HTTP/1.1 version requests are currently supported.</value>
|
||||
</data>
|
||||
<data name="net_WebHeaderInvalidControlChars" xml:space="preserve">
|
||||
<data name="net_WebHeaderInvalidControlChars" xml:space="preserve">
|
||||
<value>Specified value has invalid Control characters.</value>
|
||||
</data>
|
||||
<data name="net_WebHeaderInvalidCRLFChars" xml:space="preserve">
|
||||
@@ -262,4 +265,7 @@
|
||||
<data name="net_ftpstatuscode_ActionNotTakenFilenameNotAllowed" xml:space="preserve">
|
||||
<value>File name not allowed</value>
|
||||
</data>
|
||||
<data name="net_invalid_host" xml:space="preserve">
|
||||
<value>The specified value is not a valid Host header string.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
@@ -6,10 +6,7 @@
|
||||
<RootNamespace>System.Net.Requests</RootNamespace>
|
||||
<AssemblyName>System.Net.Requests</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<!-- Disable binplacing for now since we need to use the uapaot version of this assembly -->
|
||||
<BinPlaceILCInputFolder>false</BinPlaceILCInputFolder>
|
||||
</PropertyGroup>
|
||||
<!-- Help VS understand available configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
|
||||
|
@@ -27,6 +27,10 @@ namespace System.Net
|
||||
|
||||
public static void Register(IAuthenticationModule authenticationModule)
|
||||
{
|
||||
if (authenticationModule == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(authenticationModule));
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister(IAuthenticationModule authenticationModule)
|
||||
|
@@ -40,14 +40,7 @@ namespace System.Net
|
||||
[Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")]
|
||||
protected FileWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
|
||||
{
|
||||
_headers = (WebHeaderCollection)serializationInfo.GetValue("headers", typeof(WebHeaderCollection));
|
||||
Proxy = (IWebProxy)serializationInfo.GetValue("proxy", typeof(IWebProxy));
|
||||
_uri = (Uri)serializationInfo.GetValue("uri", typeof(Uri));
|
||||
ConnectionGroupName = serializationInfo.GetString("connectionGroupName");
|
||||
_method = serializationInfo.GetString("method");
|
||||
_contentLength = serializationInfo.GetInt64("contentLength");
|
||||
_timeout = serializationInfo.GetInt32("timeout");
|
||||
_fileAccess = (FileAccess)serializationInfo.GetInt32("fileAccess");
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) =>
|
||||
@@ -55,16 +48,7 @@ namespace System.Net
|
||||
|
||||
protected override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
serializationInfo.AddValue("headers", _headers, typeof(WebHeaderCollection));
|
||||
serializationInfo.AddValue("proxy", Proxy, typeof(IWebProxy));
|
||||
serializationInfo.AddValue("uri", _uri, typeof(Uri));
|
||||
serializationInfo.AddValue("connectionGroupName", ConnectionGroupName);
|
||||
serializationInfo.AddValue("method", _method);
|
||||
serializationInfo.AddValue("contentLength", _contentLength);
|
||||
serializationInfo.AddValue("timeout", _timeout);
|
||||
serializationInfo.AddValue("fileAccess", _fileAccess);
|
||||
serializationInfo.AddValue("preauthenticate", false);
|
||||
base.GetObjectData(serializationInfo, streamingContext);
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
internal bool Aborted => _aborted != 0;
|
||||
@@ -306,8 +290,8 @@ namespace System.Net
|
||||
|
||||
public override bool UseDefaultCredentials
|
||||
{
|
||||
get { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); }
|
||||
set { throw NotImplemented.ByDesignWithMessage(SR.net_PropertyNotImplementedException); }
|
||||
get { throw new NotSupportedException(SR.net_PropertyNotSupportedException); }
|
||||
set { throw new NotSupportedException(SR.net_PropertyNotSupportedException); }
|
||||
}
|
||||
|
||||
public override void Abort()
|
||||
|
@@ -50,24 +50,17 @@ namespace System.Net
|
||||
[Obsolete("Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")]
|
||||
protected FileWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
|
||||
{
|
||||
_headers = (WebHeaderCollection)serializationInfo.GetValue("headers", typeof(WebHeaderCollection));
|
||||
_uri = (Uri)serializationInfo.GetValue("uri", typeof(Uri));
|
||||
_contentLength = serializationInfo.GetInt64("contentLength");
|
||||
_fileAccess = (FileAccess)serializationInfo.GetInt32("fileAccess");
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
GetObjectData(serializationInfo, streamingContext);
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
protected override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
serializationInfo.AddValue("headers", _headers, typeof(WebHeaderCollection));
|
||||
serializationInfo.AddValue("uri", _uri, typeof(Uri));
|
||||
serializationInfo.AddValue("contentLength", _contentLength);
|
||||
serializationInfo.AddValue("fileAccess", _fileAccess);
|
||||
base.GetObjectData(serializationInfo, streamingContext);
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public override long ContentLength
|
||||
|
@@ -258,7 +258,7 @@ namespace System.Net
|
||||
|
||||
if (result is Exception e)
|
||||
{
|
||||
ExceptionDispatchInfo.Capture(e).Throw();
|
||||
ExceptionDispatchInfo.Throw(e);
|
||||
}
|
||||
|
||||
return (int)result;
|
||||
|
@@ -1233,7 +1233,7 @@ namespace System.Net
|
||||
{
|
||||
if (_exception != null)
|
||||
{
|
||||
ExceptionDispatchInfo.Capture(_exception).Throw();
|
||||
ExceptionDispatchInfo.Throw(_exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1576,7 +1576,7 @@ namespace System.Net
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ namespace System.Net
|
||||
protected ProtocolViolationException(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
: base(serializationInfo, streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
|
@@ -99,16 +99,52 @@ namespace System.Net
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (offset < 0 || offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
if (count < 0 || count > (buffer.Length - offset))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
_buffer.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (offset < 0 || offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
if (count < 0 || count > (buffer.Length - offset))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
return _buffer.WriteAsync(buffer, offset, count, cancellationToken);
|
||||
}
|
||||
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(buffer));
|
||||
}
|
||||
if (offset < 0 || offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
if (count < 0 || count > (buffer.Length - offset))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
return _buffer.BeginWrite(buffer, offset, count, asyncCallback, asyncState);
|
||||
}
|
||||
|
||||
|
@@ -53,6 +53,7 @@ namespace System.Net
|
||||
|
||||
protected WebException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public WebExceptionStatus Status
|
||||
@@ -73,7 +74,7 @@ namespace System.Net
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
GetObjectData(serializationInfo, streamingContext);
|
||||
base.GetObjectData(serializationInfo, streamingContext);
|
||||
}
|
||||
|
||||
public override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
|
@@ -35,14 +35,20 @@ namespace System.Net
|
||||
|
||||
protected WebRequest() { }
|
||||
|
||||
protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) { }
|
||||
protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
GetObjectData(serializationInfo, streamingContext);
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) { }
|
||||
protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
// Create a WebRequest.
|
||||
//
|
||||
|
@@ -27,15 +27,17 @@ namespace System.Net
|
||||
|
||||
protected WebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
GetObjectData(serializationInfo, streamingContext);
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public virtual void Close()
|
||||
|
@@ -3,66 +3,147 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections;
|
||||
using System.Net.Security;
|
||||
using System.Diagnostics;
|
||||
using Xunit;
|
||||
|
||||
#pragma warning disable CS0618 // obsolete warnings
|
||||
|
||||
namespace System.Net.Tests
|
||||
{
|
||||
public class AuthenticationManagerTest
|
||||
public class AuthenticationManagerTest : RemoteExecutorTestBase
|
||||
{
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "AuthenticationManager supported on NETFX")]
|
||||
[Fact]
|
||||
public static void Authenticate_NotSupported()
|
||||
public void Authenticate_NotSupported()
|
||||
{
|
||||
Assert.Throws<PlatformNotSupportedException>(() => AuthenticationManager.Authenticate(null, null, null));
|
||||
Assert.Throws<PlatformNotSupportedException>(() => AuthenticationManager.PreAuthenticate(null, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void Register_Unregister_Nop()
|
||||
public void Register_Null_Throws()
|
||||
{
|
||||
AuthenticationManager.Register(null);
|
||||
Assert.Throws<ArgumentNullException>(() => AuthenticationManager.Register(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Register_Unregister_ModuleCountUnchanged()
|
||||
{
|
||||
RemoteInvoke(() =>
|
||||
{
|
||||
int initialCount = GetModuleCount();
|
||||
IAuthenticationModule module = new CustomModule();
|
||||
AuthenticationManager.Register(module);
|
||||
AuthenticationManager.Unregister(module);
|
||||
Assert.Equal(initialCount, GetModuleCount());
|
||||
|
||||
return SuccessExitCode;
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
public void Register_UnregisterByScheme_ModuleCountUnchanged()
|
||||
{
|
||||
RemoteInvoke(() =>
|
||||
{
|
||||
int initialCount = GetModuleCount();
|
||||
IAuthenticationModule module = new CustomModule();
|
||||
AuthenticationManager.Register(module);
|
||||
AuthenticationManager.Unregister("custom");
|
||||
Assert.Equal(initialCount, GetModuleCount());
|
||||
|
||||
return SuccessExitCode;
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RegisteredModules_DefaultCount_ExpectedValue()
|
||||
{
|
||||
int count = 0;
|
||||
IEnumerator modules = AuthenticationManager.RegisteredModules;
|
||||
while (modules.MoveNext()) count++;
|
||||
Assert.Equal(0, count);
|
||||
|
||||
AuthenticationManager.Unregister((IAuthenticationModule)null);
|
||||
AuthenticationManager.Unregister((string)null);
|
||||
Assert.Equal(PlatformDetection.IsFullFramework ? 5 : 0, count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void CredentialPolicy_Roundtrip()
|
||||
public void CredentialPolicy_Roundtrip()
|
||||
{
|
||||
Assert.Null(AuthenticationManager.CredentialPolicy);
|
||||
|
||||
ICredentialPolicy cp = new DummyCredentialPolicy();
|
||||
AuthenticationManager.CredentialPolicy = cp;
|
||||
Assert.Same(cp, AuthenticationManager.CredentialPolicy);
|
||||
RemoteInvoke(() =>
|
||||
{
|
||||
ICredentialPolicy cp = new DummyCredentialPolicy();
|
||||
AuthenticationManager.CredentialPolicy = cp;
|
||||
Assert.Same(cp, AuthenticationManager.CredentialPolicy);
|
||||
|
||||
AuthenticationManager.CredentialPolicy = null;
|
||||
Assert.Null(AuthenticationManager.CredentialPolicy);
|
||||
AuthenticationManager.CredentialPolicy = null;
|
||||
Assert.Null(AuthenticationManager.CredentialPolicy);
|
||||
|
||||
return SuccessExitCode;
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void CustomTargetNameDictionary_ValidCollection()
|
||||
public void CustomTargetNameDictionary_ValidCollection()
|
||||
{
|
||||
Assert.NotNull(AuthenticationManager.CustomTargetNameDictionary);
|
||||
Assert.Empty(AuthenticationManager.CustomTargetNameDictionary);
|
||||
Assert.Same(AuthenticationManager.CustomTargetNameDictionary, AuthenticationManager.CustomTargetNameDictionary);
|
||||
|
||||
AuthenticationManager.CustomTargetNameDictionary.Add("some key", "some value");
|
||||
Assert.Equal("some value", AuthenticationManager.CustomTargetNameDictionary["some key"]);
|
||||
RemoteInvoke(() =>
|
||||
{
|
||||
string theKey = "http://www.contoso.com";
|
||||
string theValue = "HTTP/www.contoso.com";
|
||||
AuthenticationManager.CustomTargetNameDictionary.Add(theKey, theValue);
|
||||
Assert.Equal(theValue, AuthenticationManager.CustomTargetNameDictionary[theKey]);
|
||||
|
||||
AuthenticationManager.CustomTargetNameDictionary.Clear();
|
||||
Assert.Equal(0, AuthenticationManager.CustomTargetNameDictionary.Count);
|
||||
AuthenticationManager.CustomTargetNameDictionary.Clear();
|
||||
Assert.Equal(0, AuthenticationManager.CustomTargetNameDictionary.Count);
|
||||
|
||||
return SuccessExitCode;
|
||||
}).Dispose();
|
||||
}
|
||||
|
||||
private static int GetModuleCount()
|
||||
{
|
||||
int count = 0;
|
||||
IEnumerator modules = AuthenticationManager.RegisteredModules;
|
||||
while (modules.MoveNext()) count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private sealed class DummyCredentialPolicy : ICredentialPolicy
|
||||
{
|
||||
public bool ShouldSendCredential(Uri challengeUri, WebRequest request, NetworkCredential credential, IAuthenticationModule authenticationModule) => true;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class CustomModule : IAuthenticationModule
|
||||
{
|
||||
public bool CanPreAuthenticate
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public string AuthenticationType
|
||||
{
|
||||
get
|
||||
{
|
||||
return "custom";
|
||||
}
|
||||
}
|
||||
|
||||
public Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Authorization PreAuthenticate(WebRequest request, ICredentials credentials)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections;
|
||||
using System.Net.Security;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
#pragma warning disable CS0618 // obsolete warnings
|
||||
@@ -13,14 +12,68 @@ namespace System.Net.Tests
|
||||
public class AuthorizationTest
|
||||
{
|
||||
[Fact]
|
||||
public static void Ctor()
|
||||
public void Ctor_Token_ExpectDefaultValues()
|
||||
{
|
||||
var a = new Authorization("token");
|
||||
Assert.Equal("token", a.Message);
|
||||
Assert.True(a.Complete);
|
||||
Assert.Null(a.ConnectionGroupId);
|
||||
Assert.Null(a.ProtectionRealm);
|
||||
Assert.False(a.MutuallyAuthenticated);
|
||||
Authorization authorization = new Authorization("token");
|
||||
Assert.Equal("token", authorization.Message);
|
||||
Assert.True(authorization.Complete);
|
||||
Assert.Null(authorization.ConnectionGroupId);
|
||||
Assert.Null(authorization.ProtectionRealm);
|
||||
Assert.False(authorization.MutuallyAuthenticated);
|
||||
authorization.MutuallyAuthenticated = true;
|
||||
Assert.True(authorization.MutuallyAuthenticated);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
public void Ctor_TokenNullOrEmpty_ExpectMessageNull(string token)
|
||||
{
|
||||
Authorization authorization = new Authorization(token);
|
||||
Assert.Equal(null, authorization.Message);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
public void Ctor_ConnectionGroupIdNullOrEmpty_ExpectConnectionGroupIdNull(string connectionGroupId)
|
||||
{
|
||||
Authorization authorization = new Authorization(null, true, connectionGroupId);
|
||||
Assert.Equal(null, authorization.ConnectionGroupId);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData(new object[] { new string[0] { } })]
|
||||
public void ProtectionRealm_SetNullOrEmptyGet_ExpectNullValue(string[] protectionRealm)
|
||||
{
|
||||
Authorization authorization = new Authorization(null);
|
||||
authorization.ProtectionRealm = protectionRealm;
|
||||
Assert.Equal(null, authorization.ProtectionRealm);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProtectionRealm_SetArray_ExpectEqualValues()
|
||||
{
|
||||
Authorization authorization = new Authorization(null);
|
||||
string[] protectionRealm = new string[] { "a" };
|
||||
authorization.ProtectionRealm = protectionRealm;
|
||||
Assert.Equal(protectionRealm, authorization.ProtectionRealm);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> GetMutuallyAuthenticatedValues()
|
||||
{
|
||||
yield return new object[] { new Authorization(null, false), false, false };
|
||||
yield return new object[] { new Authorization(null, true), false, false };
|
||||
yield return new object[] { new Authorization(null, true), true, true };
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetMutuallyAuthenticatedValues))]
|
||||
public void MutuallyAuthenticated_Values_ExpectEqualValues(Authorization authorization, bool setValue, bool expectedValue)
|
||||
{
|
||||
authorization.MutuallyAuthenticated = setValue;
|
||||
Assert.Equal(expectedValue, authorization.MutuallyAuthenticated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Net.Test.Common;
|
||||
@@ -55,10 +56,10 @@ namespace System.Net.Tests
|
||||
public void InvalidArguments_Throws()
|
||||
{
|
||||
WebRequest request = WebRequest.Create("file://anything");
|
||||
Assert.Throws<ArgumentException>("value", () => request.ContentLength = -1);
|
||||
Assert.Throws<ArgumentException>("value", () => request.Method = null);
|
||||
Assert.Throws<ArgumentException>("value", () => request.Method = "");
|
||||
Assert.Throws<ArgumentOutOfRangeException>("value", () => request.Timeout = -2);
|
||||
AssertExtensions.Throws<ArgumentException>("value", () => request.ContentLength = -1);
|
||||
AssertExtensions.Throws<ArgumentException>("value", () => request.Method = null);
|
||||
AssertExtensions.Throws<ArgumentException>("value", () => request.Method = "");
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("value", () => request.Timeout = -2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -78,11 +79,11 @@ namespace System.Net.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotImplementedMembers_Throws()
|
||||
public void UseDefaultCredentials_GetOrSet_Throws()
|
||||
{
|
||||
WebRequest request = WebRequest.Create("file://anything");
|
||||
Assert.Throws<NotImplementedException>(() => request.UseDefaultCredentials);
|
||||
Assert.Throws<NotImplementedException>(() => request.UseDefaultCredentials = true);
|
||||
Assert.Throws<NotSupportedException>(() => request.UseDefaultCredentials);
|
||||
Assert.Throws<NotSupportedException>(() => request.UseDefaultCredentials = true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,10 +108,8 @@ namespace System.Net.Tests
|
||||
using (WebResponse response = await GetResponseAsync(request))
|
||||
{
|
||||
Assert.Equal(data.Length, response.ContentLength);
|
||||
Assert.Equal(data.Length.ToString(), response.Headers[HttpRequestHeader.ContentLength]);
|
||||
|
||||
Assert.Equal("application/octet-stream", response.ContentType);
|
||||
Assert.Equal("application/octet-stream", response.Headers[HttpRequestHeader.ContentType]);
|
||||
|
||||
Assert.True(response.SupportsHeaders);
|
||||
Assert.NotNull(response.Headers);
|
||||
@@ -230,6 +229,7 @@ namespace System.Net.Tests
|
||||
|
||||
public abstract class AsyncFileWebRequestTestBase : FileWebRequestTestBase
|
||||
{
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Concurrent read/write only supported on .NET Core via PR 12231")]
|
||||
[Fact]
|
||||
public async Task ConcurrentReadWrite_ResponseBlocksThenGetsNullStream()
|
||||
{
|
||||
|
@@ -40,7 +40,7 @@ namespace System.Net.Tests
|
||||
Assert.False(request.EnableSsl);
|
||||
Assert.NotNull(request.Headers);
|
||||
Assert.Equal(0, request.Headers.Count);
|
||||
Assert.False(request.KeepAlive);
|
||||
Assert.True(request.KeepAlive);
|
||||
Assert.Equal(request.Method, WebRequestMethods.Ftp.DownloadFile);
|
||||
Assert.Null(request.Proxy);
|
||||
Assert.Equal(request.ReadWriteTimeout, 5 * 60 * 1000);
|
||||
|
@@ -47,7 +47,13 @@ namespace System.Net.Tests
|
||||
|
||||
#pragma warning disable 0618 //GlobalProxySelection is Deprecated.
|
||||
Assert.NotNull(GlobalProxySelection.Select);
|
||||
Assert.Equal(GlobalProxySelection.Select, WebRequest.DefaultWebProxy);
|
||||
if (!PlatformDetection.IsFullFramework)
|
||||
{
|
||||
// On .NET Framework, the default value for Select property
|
||||
// is an internal WebRequest.WebProxyWrapper object which
|
||||
// works similarly to DefaultWebProxy but is not the same object.
|
||||
Assert.Equal(GlobalProxySelection.Select, WebRequest.DefaultWebProxy);
|
||||
}
|
||||
#pragma warning restore 0618
|
||||
|
||||
WebRequest.DefaultWebProxy = myProxy;
|
||||
|
@@ -2,6 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Cache;
|
||||
|
||||
@@ -46,9 +47,9 @@ namespace System.Net.Tests
|
||||
[Fact]
|
||||
public void Ctor_InvalidArgs_Throws()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>("level", () => new HttpRequestCachePolicy((HttpRequestCacheLevel)42));
|
||||
Assert.Throws<ArgumentException>("cacheAgeControl", () => new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, TimeSpan.FromSeconds(1)));
|
||||
Assert.Throws<ArgumentException>("cacheAgeControl", () => new HttpRequestCachePolicy(HttpCacheAgeControl.None, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)));
|
||||
AssertExtensions.Throws<ArgumentOutOfRangeException>("level", () => new HttpRequestCachePolicy((HttpRequestCacheLevel)42));
|
||||
AssertExtensions.Throws<ArgumentException>("cacheAgeControl", () => new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, TimeSpan.FromSeconds(1)));
|
||||
AssertExtensions.Throws<ArgumentException>("cacheAgeControl", () => new HttpRequestCachePolicy(HttpCacheAgeControl.None, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user