< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.ServiceModelSecurityTokenRequirement
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/ServiceModelSecurityTokenRequirement.cs
Line coverage
52%
Covered lines: 39
Uncovered lines: 35
Coverable lines: 74
Total lines: 236
Line coverage: 52.7%
Branch coverage
33%
Covered branches: 2
Total branches: 6
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
GetPropertyOrDefault(...)100%22100%
InternalToString()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/ServiceModelSecurityTokenRequirement.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.Globalization;
 5using System.Text;
 6using CoreWCF.Channels;
 7using CoreWCF.IdentityModel.Selectors;
 8
 9namespace CoreWCF.Security.Tokens
 10{
 11    public abstract class ServiceModelSecurityTokenRequirement : SecurityTokenRequirement
 12    {
 13        protected const string Namespace = "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequiremen
 14        private const string securityAlgorithmSuiteProperty = Namespace + "/SecurityAlgorithmSuite";
 15        private const string securityBindingElementProperty = Namespace + "/SecurityBindingElement";
 16        private const string issuerAddressProperty = Namespace + "/IssuerAddress";
 17        private const string issuerBindingProperty = Namespace + "/IssuerBinding";
 18        private const string secureConversationSecurityBindingElementProperty = Namespace + "/SecureConversationSecurity
 19        private const string supportSecurityContextCancellationProperty = Namespace + "/SupportSecurityContextCancellati
 20        private const string messageSecurityVersionProperty = Namespace + "/MessageSecurityVersion";
 21        private const string defaultMessageSecurityVersionProperty = Namespace + "/DefaultMessageSecurityVersion";
 22        private const string issuerBindingContextProperty = Namespace + "/IssuerBindingContext";
 23        private const string transportSchemeProperty = Namespace + "/TransportScheme";
 24        private const string isInitiatorProperty = Namespace + "/IsInitiator";
 25        private const string targetAddressProperty = Namespace + "/TargetAddress";
 26        private const string viaProperty = Namespace + "/Via";
 27        private const string listenUriProperty = Namespace + "/ListenUri";
 28        private const string auditLogLocationProperty = Namespace + "/AuditLogLocation";
 29        private const string suppressAuditFailureProperty = Namespace + "/SuppressAuditFailure";
 30        private const string messageAuthenticationAuditLevelProperty = Namespace + "/MessageAuthenticationAuditLevel";
 31        private const string isOutOfBandTokenProperty = Namespace + "/IsOutOfBandToken";
 32        private const string preferSslCertificateAuthenticatorProperty = Namespace + "/PreferSslCertificateAuthenticator
 33
 34        // the following properties dont have top level OM properties but are part of the property bag
 35        private const string supportingTokenAttachmentModeProperty = Namespace + "/SupportingTokenAttachmentMode";
 36        private const string messageDirectionProperty = Namespace + "/MessageDirection";
 37        private const string httpAuthenticationSchemeProperty = Namespace + "/HttpAuthenticationScheme";
 38        private const string issuedSecurityTokenParametersProperty = Namespace + "/IssuedSecurityTokenParameters";
 39        private const string privacyNoticeUriProperty = Namespace + "/PrivacyNoticeUri";
 40        private const string privacyNoticeVersionProperty = Namespace + "/PrivacyNoticeVersion";
 41        private const string duplexClientLocalAddressProperty = Namespace + "/DuplexClientLocalAddress";
 42        private const string endpointFilterTableProperty = Namespace + "/EndpointFilterTable";
 43        private const string channelParametersCollectionProperty = Namespace + "/ChannelParametersCollection";
 44        private const string extendedProtectionPolicy = Namespace + "/ExtendedProtectionPolicy";
 45        private const bool defaultSupportSecurityContextCancellation = false;
 46
 47        protected ServiceModelSecurityTokenRequirement()
 9948            : base()
 49        {
 9950            Properties[SupportSecurityContextCancellationProperty] = defaultSupportSecurityContextCancellation;
 9951        }
 52
 10053        public static string SecurityAlgorithmSuiteProperty { get { return securityAlgorithmSuiteProperty; } }
 10054        public static string SecurityBindingElementProperty { get { return securityBindingElementProperty; } }
 255        public static string IssuerAddressProperty { get { return issuerAddressProperty; } }
 056        public static string IssuerBindingProperty { get { return issuerBindingProperty; } }
 4457        public static string SecureConversationSecurityBindingElementProperty { get { return secureConversationSecurityB
 16758        public static string SupportSecurityContextCancellationProperty { get { return supportSecurityContextCancellatio
 10059        public static string MessageSecurityVersionProperty { get { return messageSecurityVersionProperty; } }
 260        internal static string DefaultMessageSecurityVersionProperty { get { return defaultMessageSecurityVersionPropert
 4661        public static string IssuerBindingContextProperty { get { return issuerBindingContextProperty; } }
 2262        public static string TransportSchemeProperty { get { return transportSchemeProperty; } }
 9963        public static string IsInitiatorProperty { get { return isInitiatorProperty; } }
 064        public static string TargetAddressProperty { get { return targetAddressProperty; } }
 065        public static string ViaProperty { get { return viaProperty; } }
 12266        public static string ListenUriProperty { get { return listenUriProperty; } }
 067        public static string AuditLogLocationProperty { get { return auditLogLocationProperty; } }
 068        public static string SuppressAuditFailureProperty { get { return suppressAuditFailureProperty; } }
 069        public static string MessageAuthenticationAuditLevelProperty { get { return messageAuthenticationAuditLevelPrope
 070        public static string IsOutOfBandTokenProperty { get { return isOutOfBandTokenProperty; } }
 071        public static string PreferSslCertificateAuthenticatorProperty { get { return preferSslCertificateAuthenticatorP
 72
 5573        public static string SupportingTokenAttachmentModeProperty { get { return supportingTokenAttachmentModeProperty;
 7774        public static string MessageDirectionProperty { get { return messageDirectionProperty; } }
 1275        public static string HttpAuthenticationSchemeProperty { get { return httpAuthenticationSchemeProperty; } }
 4876        public static string IssuedSecurityTokenParametersProperty { get { return issuedSecurityTokenParametersProperty;
 077        public static string PrivacyNoticeUriProperty { get { return privacyNoticeUriProperty; } }
 078        public static string PrivacyNoticeVersionProperty { get { return privacyNoticeVersionProperty; } }
 079        public static string DuplexClientLocalAddressProperty { get { return duplexClientLocalAddressProperty; } }
 2280        public static string EndpointFilterTableProperty { get { return endpointFilterTableProperty; } }
 081        public static string ChannelParametersCollectionProperty { get { return channelParametersCollectionProperty; } }
 11182        public static string ExtendedProtectionPolicy { get { return extendedProtectionPolicy; } }
 83
 84        public bool IsInitiator
 85        {
 86            get
 87            {
 088                return GetPropertyOrDefault<bool>(IsInitiatorProperty, false);
 89            }
 90        }
 91
 92        public SecurityAlgorithmSuite SecurityAlgorithmSuite
 93        {
 94            get
 95            {
 2396                return GetPropertyOrDefault<SecurityAlgorithmSuite>(SecurityAlgorithmSuiteProperty, null);
 97            }
 98            set
 99            {
 77100                Properties[SecurityAlgorithmSuiteProperty] = value;
 77101            }
 102        }
 103
 104        public SecurityBindingElement SecurityBindingElement
 105        {
 106            get
 107            {
 23108                return GetPropertyOrDefault<SecurityBindingElement>(SecurityBindingElementProperty, null);
 109            }
 110            set
 111            {
 77112                Properties[SecurityBindingElementProperty] = value;
 77113            }
 114        }
 115
 116        public EndpointAddress IssuerAddress
 117        {
 118            get
 119            {
 0120                return GetPropertyOrDefault<EndpointAddress>(IssuerAddressProperty, null);
 121            }
 122            set
 123            {
 0124                Properties[IssuerAddressProperty] = value;
 0125            }
 126        }
 127
 128        public Binding IssuerBinding
 129        {
 130            get
 131            {
 0132                return GetPropertyOrDefault<Binding>(IssuerBindingProperty, null);
 133            }
 134            set
 135            {
 0136                Properties[IssuerBindingProperty] = value;
 0137            }
 138        }
 139
 140        public SecurityBindingElement SecureConversationSecurityBindingElement
 141        {
 142            get
 143            {
 22144                return GetPropertyOrDefault<SecurityBindingElement>(SecureConversationSecurityBindingElementProperty, nu
 145            }
 146            set
 147            {
 0148                Properties[SecureConversationSecurityBindingElementProperty] = value;
 0149            }
 150        }
 151
 152        public SecurityTokenVersion MessageSecurityVersion
 153        {
 154            get
 155            {
 0156                return GetPropertyOrDefault<SecurityTokenVersion>(MessageSecurityVersionProperty, null);
 157            }
 158            set
 159            {
 77160                Properties[MessageSecurityVersionProperty] = value;
 77161            }
 162        }
 163
 164        internal MessageSecurityVersion DefaultMessageSecurityVersion
 165        {
 166            get
 167            {
 0168                return (TryGetProperty<MessageSecurityVersion>(DefaultMessageSecurityVersionProperty, out MessageSecurit
 169            }
 170            set
 171            {
 2172                Properties[DefaultMessageSecurityVersionProperty] = (object)value;
 2173            }
 174        }
 175
 176        public string TransportScheme
 177        {
 178            get
 179            {
 0180                return GetPropertyOrDefault<string>(TransportSchemeProperty, null);
 181            }
 182            set
 183            {
 22184                Properties[TransportSchemeProperty] = value;
 22185            }
 186        }
 187
 188        internal bool SupportSecurityContextCancellation
 189        {
 190            get
 191            {
 23192                return GetPropertyOrDefault<bool>(SupportSecurityContextCancellationProperty, defaultSupportSecurityCont
 193            }
 194            set
 195            {
 22196                Properties[SupportSecurityContextCancellationProperty] = value;
 22197            }
 198        }
 199
 200        internal EndpointAddress DuplexClientLocalAddress
 201        {
 202            get
 203            {
 0204                return GetPropertyOrDefault<EndpointAddress>(duplexClientLocalAddressProperty, null);
 205            }
 206            set
 207            {
 0208                Properties[duplexClientLocalAddressProperty] = value;
 0209            }
 210        }
 211
 212        internal TValue GetPropertyOrDefault<TValue>(string propertyName, TValue defaultValue)
 213        {
 136214            if (!TryGetProperty<TValue>(propertyName, out TValue result))
 215            {
 22216                result = defaultValue;
 217            }
 136218            return result;
 219        }
 220
 221        internal string InternalToString()
 222        {
 0223            StringBuilder sb = new StringBuilder();
 224
 0225            sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "{0}:", GetType().ToString()));
 0226            foreach (string propertyName in Properties.Keys)
 227            {
 0228                object propertyValue = Properties[propertyName];
 0229                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "PropertyName: {0}", propertyName));
 0230                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "PropertyValue: {0}", propertyValue));
 0231                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "---"));
 232            }
 0233            return sb.ToString().Trim();
 234        }
 235    }
 236}

Methods/Properties

.ctor()
SecurityAlgorithmSuiteProperty()
SecurityBindingElementProperty()
IssuerAddressProperty()
IssuerBindingProperty()
SecureConversationSecurityBindingElementProperty()
SupportSecurityContextCancellationProperty()
MessageSecurityVersionProperty()
DefaultMessageSecurityVersionProperty()
IssuerBindingContextProperty()
TransportSchemeProperty()
IsInitiatorProperty()
TargetAddressProperty()
ViaProperty()
ListenUriProperty()
AuditLogLocationProperty()
SuppressAuditFailureProperty()
MessageAuthenticationAuditLevelProperty()
IsOutOfBandTokenProperty()
PreferSslCertificateAuthenticatorProperty()
SupportingTokenAttachmentModeProperty()
MessageDirectionProperty()
HttpAuthenticationSchemeProperty()
IssuedSecurityTokenParametersProperty()
PrivacyNoticeUriProperty()
PrivacyNoticeVersionProperty()
DuplexClientLocalAddressProperty()
EndpointFilterTableProperty()
ChannelParametersCollectionProperty()
ExtendedProtectionPolicy()
IsInitiator()
SecurityAlgorithmSuite()
SecurityAlgorithmSuite(CoreWCF.Security.SecurityAlgorithmSuite)
SecurityBindingElement()
SecurityBindingElement(CoreWCF.Channels.SecurityBindingElement)
IssuerAddress()
IssuerAddress(CoreWCF.EndpointAddress)
IssuerBinding()
IssuerBinding(CoreWCF.Channels.Binding)
SecureConversationSecurityBindingElement()
SecureConversationSecurityBindingElement(CoreWCF.Channels.SecurityBindingElement)
MessageSecurityVersion()
MessageSecurityVersion(CoreWCF.IdentityModel.Selectors.SecurityTokenVersion)
DefaultMessageSecurityVersion()
DefaultMessageSecurityVersion(CoreWCF.MessageSecurityVersion)
TransportScheme()
TransportScheme(System.String)
SupportSecurityContextCancellation()
SupportSecurityContextCancellation(System.Boolean)
DuplexClientLocalAddress()
DuplexClientLocalAddress(CoreWCF.EndpointAddress)
GetPropertyOrDefault(System.String,TValue)
InternalToString()