< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.HttpTransportElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/HttpTransportElement.cs
Line coverage
41%
Covered lines: 21
Uncovered lines: 30
Coverable lines: 51
Total lines: 245
Line coverage: 41.1%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ApplyConfiguration(...)100%22100%
CopyFrom(...)100%110%
CreateDefaultBindingElement()100%11100%
InitializeFrom(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/HttpTransportElement.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.ComponentModel;
 6using System.Configuration;
 7using System.Net;
 8using CoreWCF.Channels;
 9
 10namespace CoreWCF.Configuration
 11{
 12    public class HttpTransportElement : TransportElement
 13    {
 14        //[ConfigurationProperty(ConfigurationStrings.AllowCookies, DefaultValue = HttpTransportDefaults.AllowCookies)]
 15        //public bool AllowCookies
 16        //{
 17        //    get { return (bool)base[ConfigurationStrings.AllowCookies]; }
 18        //    set { base[ConfigurationStrings.AllowCookies] = value; }
 19        //}
 20
 21        //[ConfigurationProperty(ConfigurationStrings.RequestInitializationTimeout, DefaultValue = HttpTransportDefaults
 22        //public TimeSpan RequestInitializationTimeout
 23        //{
 24        //    get { return (TimeSpan)base[ConfigurationStrings.RequestInitializationTimeout]; }
 25        //    set { base[ConfigurationStrings.RequestInitializationTimeout] = value; }
 26        //}
 27
 28        [ConfigurationProperty(ConfigurationStrings.AuthenticationScheme, DefaultValue = HttpTransportDefaults.Authentic
 29        public AuthenticationSchemes AuthenticationScheme
 30        {
 431            get { return (AuthenticationSchemes)base[ConfigurationStrings.AuthenticationScheme]; }
 032            set { base[ConfigurationStrings.AuthenticationScheme] = value; }
 33        }
 34
 35        public override Type BindingElementType
 36        {
 1237            get { return typeof(HttpTransportBindingElement); }
 38        }
 39
 40        //[ConfigurationProperty(ConfigurationStrings.BypassProxyOnLocal, DefaultValue = HttpTransportDefaults.BypassPro
 41        //public bool BypassProxyOnLocal
 42        //{
 43        //    get { return (bool)base[ConfigurationStrings.BypassProxyOnLocal]; }
 44        //    set { base[ConfigurationStrings.BypassProxyOnLocal] = value; }
 45        //}
 46
 47        //[ConfigurationProperty(ConfigurationStrings.DecompressionEnabled, DefaultValue = HttpTransportDefaults.Decompr
 48        //public bool DecompressionEnabled
 49        //{
 50        //    get { return (bool)base[ConfigurationStrings.DecompressionEnabled]; }
 51        //    set { base[ConfigurationStrings.DecompressionEnabled] = value; }
 52        //}
 53
 54        //[ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostN
 55        //public HostNameComparisonMode HostNameComparisonMode
 56        //{
 57        //    get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
 58        //    set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
 59        //}
 60
 61        [ConfigurationProperty(ConfigurationStrings.KeepAliveEnabled, DefaultValue = HttpTransportDefaults.KeepAliveEnab
 62        public bool KeepAliveEnabled
 63        {
 464            get { return (bool)base[ConfigurationStrings.KeepAliveEnabled]; }
 065            set { base[ConfigurationStrings.KeepAliveEnabled] = value; }
 66        }
 67
 68        [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)]
 69        [IntegerValidator(MinValue = 1)]
 70        public int MaxBufferSize
 71        {
 272            get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
 073            set { base[ConfigurationStrings.MaxBufferSize] = value; }
 74        }
 75
 76        //[ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = HttpTransportDefaults.DefaultMax
 77        //public int MaxPendingAccepts
 78        //{
 79        //    get { return (int)base[ConfigurationStrings.MaxPendingAccepts]; }
 80        //    set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
 81        //}
 82
 83        //[ConfigurationProperty(ConfigurationStrings.MessageHandlerFactory, DefaultValue = HttpTransportDefaults.Messag
 84        //public HttpMessageHandlerFactoryElement MessageHandlerFactory
 85        //{
 86        //    get { return (HttpMessageHandlerFactoryElement)this[ConfigurationStrings.MessageHandlerFactory]; }
 87        //    set { base[ConfigurationStrings.MessageHandlerFactory] = value; }
 88        //}
 89
 90        //[ConfigurationProperty(ConfigurationStrings.ProxyAddress, DefaultValue = HttpTransportDefaults.ProxyAddress)]
 91        //public Uri ProxyAddress
 92        //{
 93        //    get { return (Uri)base[ConfigurationStrings.ProxyAddress]; }
 94        //    set { base[ConfigurationStrings.ProxyAddress] = value; }
 95        //}
 96
 97        //[ConfigurationProperty(ConfigurationStrings.ProxyAuthenticationScheme, DefaultValue = HttpTransportDefaults.Pr
 98        //public AuthenticationSchemes ProxyAuthenticationScheme
 99        //{
 100        //    get { return (AuthenticationSchemes)base[ConfigurationStrings.ProxyAuthenticationScheme]; }
 101        //    set { base[ConfigurationStrings.ProxyAuthenticationScheme] = value; }
 102        //}
 103
 104        [ConfigurationProperty(ConfigurationStrings.Realm, DefaultValue = HttpTransportDefaults.Realm)]
 105        [StringValidator(MinLength = 0)]
 106        public string Realm
 107        {
 4108            get { return (string)base[ConfigurationStrings.Realm]; }
 109            set
 110            {
 0111                if (string.IsNullOrEmpty(value))
 112                {
 0113                    value = string.Empty;
 114                }
 0115                base[ConfigurationStrings.Realm] = value;
 0116            }
 117        }
 118
 119        [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = HttpTransportDefaults.TransferMode)]
 120        public TransferMode TransferMode
 121        {
 4122            get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
 0123            set { base[ConfigurationStrings.TransferMode] = value; }
 124        }
 125
 126        //[ConfigurationProperty(ConfigurationStrings.UnsafeConnectionNtlmAuthentication, DefaultValue = HttpTransportDe
 127        //public bool UnsafeConnectionNtlmAuthentication
 128        //{
 129        //    get { return (bool)base[ConfigurationStrings.UnsafeConnectionNtlmAuthentication]; }
 130        //    set { base[ConfigurationStrings.UnsafeConnectionNtlmAuthentication] = value; }
 131        //}
 132
 133        //[ConfigurationProperty(ConfigurationStrings.UseDefaultWebProxy, DefaultValue = HttpTransportDefaults.UseDefaul
 134        //public bool UseDefaultWebProxy
 135        //{
 136        //    get { return (bool)base[ConfigurationStrings.UseDefaultWebProxy]; }
 137        //    set { base[ConfigurationStrings.UseDefaultWebProxy] = value; }
 138        //}
 139
 140
 141        [ConfigurationProperty(ConfigurationStrings.ExtendedProtectionPolicy)]
 142        public ExtendedProtectionPolicyElement ExtendedProtectionPolicy
 143        {
 4144            get { return (ExtendedProtectionPolicyElement)base[ConfigurationStrings.ExtendedProtectionPolicy]; }
 0145            private set { base[ConfigurationStrings.ExtendedProtectionPolicy] = value; }
 146        }
 147
 148        [ConfigurationProperty(ConfigurationStrings.WebSocketSettingsSectionName)]
 149        public WebSocketTransportSettingsElement WebSocketSettings
 150        {
 4151            get { return (WebSocketTransportSettingsElement)base[ConfigurationStrings.WebSocketSettingsSectionName]; }
 0152            set { base[ConfigurationStrings.WebSocketSettingsSectionName] = value; }
 153        }
 154
 155        public override void ApplyConfiguration(BindingElement bindingElement)
 156        {
 4157            base.ApplyConfiguration(bindingElement);
 4158            HttpTransportBindingElement binding = (HttpTransportBindingElement)bindingElement;
 159
 160            //binding.AllowCookies = this.AllowCookies;
 4161            binding.AuthenticationScheme = AuthenticationScheme;
 162            //binding.BypassProxyOnLocal = this.BypassProxyOnLocal;
 163            //binding.DecompressionEnabled = this.DecompressionEnabled;
 4164            binding.KeepAliveEnabled = KeepAliveEnabled;
 165            //binding.HostNameComparisonMode = this.HostNameComparisonMode;
 4166            PropertyInformationCollection propertyInfo = ElementInformation.Properties;
 4167            if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
 168            {
 2169                binding.MaxBufferSize = MaxBufferSize;
 170            }
 171            //binding.MaxPendingAccepts = this.MaxPendingAccepts;
 172            //binding.ProxyAddress = this.ProxyAddress;
 173            //binding.ProxyAuthenticationScheme = this.ProxyAuthenticationScheme;
 4174            binding.Realm = Realm;
 175            //binding.RequestInitializationTimeout = this.RequestInitializationTimeout;
 4176            binding.TransferMode = TransferMode;
 177            //binding.UnsafeConnectionNtlmAuthentication = this.UnsafeConnectionNtlmAuthentication;
 178            //binding.UseDefaultWebProxy = this.UseDefaultWebProxy;
 4179            binding.ExtendedProtectionPolicy = ConfigurationChannelBindingUtility.BuildPolicy(ExtendedProtectionPolicy);
 4180            WebSocketSettings.ApplyConfiguration(binding.WebSocketSettings);
 181            //if (this.MessageHandlerFactory != null)
 182            //{
 183            //    binding.MessageHandlerFactory = HttpMessageHandlerFactory.CreateFromConfigurationElement(this.MessageH
 184            //}
 4185        }
 186
 187        public override void CopyFrom(ServiceModelExtensionElement from)
 188        {
 0189            base.CopyFrom(from);
 190
 0191            HttpTransportElement source = (HttpTransportElement)from;
 192            //this.AllowCookies = source.AllowCookies;
 193            //this.RequestInitializationTimeout = source.RequestInitializationTimeout;
 0194            AuthenticationScheme = source.AuthenticationScheme;
 195            //this.BypassProxyOnLocal = source.BypassProxyOnLocal;
 196            //this.DecompressionEnabled = source.DecompressionEnabled;
 0197            KeepAliveEnabled = source.KeepAliveEnabled;
 198            //this.HostNameComparisonMode = source.HostNameComparisonMode;
 0199            MaxBufferSize = source.MaxBufferSize;
 200            //this.MaxPendingAccepts = source.MaxPendingAccepts;
 201            //this.ProxyAddress = source.ProxyAddress;
 202            //this.ProxyAuthenticationScheme = source.ProxyAuthenticationScheme;
 0203            Realm = source.Realm;
 0204            TransferMode = source.TransferMode;
 205            //this.UnsafeConnectionNtlmAuthentication = source.UnsafeConnectionNtlmAuthentication;
 206            //this.UseDefaultWebProxy = source.UseDefaultWebProxy;
 0207            WebSocketSettings = source.WebSocketSettings;
 208            //this.MessageHandlerFactory = source.MessageHandlerFactory;
 0209            ConfigurationChannelBindingUtility.CopyFrom(source.ExtendedProtectionPolicy, ExtendedProtectionPolicy);
 0210        }
 211
 212        protected override TransportBindingElement CreateDefaultBindingElement()
 213        {
 2214            return new HttpTransportBindingElement();
 215        }
 216
 217        protected internal override void InitializeFrom(BindingElement bindingElement)
 218        {
 0219            base.InitializeFrom(bindingElement);
 0220            HttpTransportBindingElement source = (HttpTransportBindingElement)bindingElement;
 221            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AllowCookies, source.AllowCookies);
 0222            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AuthenticationScheme, source.AuthenticationScheme);
 223            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.DecompressionEnabled, source.DecompressionEnabled);
 224            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.BypassProxyOnLocal, source.BypassProxyOnLocal);
 0225            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.KeepAliveEnabled, source.KeepAliveEnabled);
 226            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, source.HostNameComparisonMo
 0227            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, source.MaxBufferSize);
 228            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxPendingAccepts, source.MaxPendingAccepts);
 229            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAddress, source.ProxyAddress);
 230            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAuthenticationScheme, source.ProxyAuthenticati
 0231            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Realm, source.Realm);
 232            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.RequestInitializationTimeout, source.RequestInitial
 0233            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, source.TransferMode);
 234            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UnsafeConnectionNtlmAuthentication, source.UnsafeCo
 235            //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UseDefaultWebProxy, source.UseDefaultWebProxy);
 0236            WebSocketSettings.InitializeFrom(source.WebSocketSettings);
 237            //if (source.MessageHandlerFactory != null)
 238            //{
 239            //    this.MessageHandlerFactory = source.MessageHandlerFactory.GenerateConfigurationElement();
 240            //}
 241
 0242            ConfigurationChannelBindingUtility.InitializeFrom(source.ExtendedProtectionPolicy, ExtendedProtectionPolicy)
 0243        }
 244    }
 245}