< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.SecurityElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/SecurityElement.cs
Line coverage
38%
Covered lines: 12
Uncovered lines: 19
Coverable lines: 31
Total lines: 81
Line coverage: 38.7%
Branch coverage
33%
Covered branches: 4
Total branches: 12
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%
CopyFrom(...)0%220%
CreateBindingElement(...)66.66%6680%
AddBindingTemplates(...)100%110%
InitializeSecureConversationParameters(...)0%220%
InitializeNestedTokenParameterSettings(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/SecurityElement.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.Collections.Generic;
 6using System.Configuration;
 7using CoreWCF.Channels;
 8using CoreWCF.Security.Tokens;
 9
 10namespace CoreWCF.Configuration
 11{
 12    public sealed class SecurityElement : SecurityElementBase
 13    {
 314        public SecurityElement()
 15        {
 316            SecureConversationBootstrap.IsSecurityElementBootstrap = true; // Tell the bootstrap it's potentially okay t
 317        }
 18
 19        [ConfigurationProperty(ConfigurationStrings.SecureConversationBootstrap)]
 20        public SecurityElementBase SecureConversationBootstrap
 21        {
 622            get { return (SecurityElementBase)base[ConfigurationStrings.SecureConversationBootstrap]; }
 23        }
 24
 25        public override void CopyFrom(ServiceModelExtensionElement from)
 26        {
 027            base.CopyFrom(from);
 28
 029            SecurityElement source = (SecurityElement)from;
 30
 031            if (PropertyValueOrigin.Default != source.ElementInformation.Properties[ConfigurationStrings.SecureConversat
 032                SecureConversationBootstrap.CopyFrom(source.SecureConversationBootstrap);
 033        }
 34
 35        protected internal override BindingElement CreateBindingElement(bool createTemplateOnly)
 36        {
 37            SecurityBindingElement result;
 338            if (AuthenticationMode == AuthenticationMode.SecureConversation)
 39            {
 140                if (SecureConversationBootstrap == null)
 041                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 142                if (SecureConversationBootstrap.AuthenticationMode == AuthenticationMode.SecureConversation)
 043                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 144                SecurityBindingElement bootstrapSecurity = (SecurityBindingElement)SecureConversationBootstrap.CreateBin
 145                result = SecurityBindingElement.CreateSecureConversationBindingElement(bootstrapSecurity, RequireSecurit
 46            }
 47            else
 48            {
 249                result = (SecurityBindingElement)base.CreateBindingElement(createTemplateOnly);
 50            }
 51
 152            ApplyConfiguration(result);
 53
 154            return result;
 55        }
 56
 57        protected override void AddBindingTemplates(Dictionary<AuthenticationMode, SecurityBindingElement> bindingTempla
 58        {
 059            base.AddBindingTemplates(bindingTemplates);
 060            AddBindingTemplate(bindingTemplates, AuthenticationMode.SecureConversation);
 061        }
 62
 63        private void InitializeSecureConversationParameters(SecureConversationSecurityTokenParameters sc, bool initializ
 64        {
 065            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.RequireSecurityContextCancellation, sc.RequireCancell
 066            CanRenewSecurityContextToken = sc.CanRenewSession; // can't use default value optimization here because Appl
 067            if (sc.BootstrapSecurityBindingElement != null)
 68            {
 069                SecureConversationBootstrap.InitializeFrom(sc.BootstrapSecurityBindingElement, initializeNestedBindings)
 70            }
 071        }
 72
 73        protected override void InitializeNestedTokenParameterSettings(SecurityTokenParameters sp, bool initializeNested
 74        {
 075            if (sp is SecureConversationSecurityTokenParameters)
 076                InitializeSecureConversationParameters((SecureConversationSecurityTokenParameters)sp, initializeNestedBi
 77            else
 078                base.InitializeNestedTokenParameterSettings(sp, initializeNestedBindings);
 079        }
 80    }
 81}