Skip to content

Commit

Permalink
Make BasicHttpSecurity default constructor public in the contract.
Browse files Browse the repository at this point in the history
* Already public in the implementation.
* If BasicHttpSecurityMode is set to Message or TransportWithMessageCredential throw PNSE.
* Fixes #2365
  • Loading branch information
StephenBonikowsky committed Feb 15, 2018
1 parent 4df27d4 commit 4037cc5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ public BasicHttpSecurityMode Mode
get { return _mode; }
set
{
if (value == BasicHttpSecurityMode.Message ||
value == BasicHttpSecurityMode.TransportWithMessageCredential)
{
throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.UnsupportedSecuritySetting, nameof(value), value));
}

if (!BasicHttpSecurityModeHelper.IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value"));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value)));
}
_mode = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum BasicHttpMessageCredentialType
}
public sealed partial class BasicHttpSecurity
{
internal BasicHttpSecurity() { }
public BasicHttpSecurity() { }
public System.ServiceModel.BasicHttpSecurityMode Mode { get { return default(System.ServiceModel.BasicHttpSecurityMode); } set { } }
public System.ServiceModel.HttpTransportSecurity Transport { get { return default(System.ServiceModel.HttpTransportSecurity); } set { } }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Tests.Common;
using System.Text;
using System.Xml;
using Infrastructure.Common;
using Xunit;

public static class BasicHttpSecurityTest
{
[WcfTheory]
[InlineData(BasicHttpSecurityMode.Message)]
[InlineData(BasicHttpSecurityMode.TransportWithMessageCredential)]
public static void BasicHttpSecurity_MessageSecurityMode_ThrowsPNSE(BasicHttpSecurityMode value)
{
var security = new BasicHttpSecurity();
Assert.Throws<PlatformNotSupportedException>(() => security.Mode = value);
}
}

0 comments on commit 4037cc5

Please sign in to comment.