< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.SecurityTokenParametersEnumerable
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityTokenParametersEnumerable.cs
Line coverage
42%
Covered lines: 16
Uncovered lines: 22
Coverable lines: 38
Total lines: 120
Line coverage: 42.1%
Branch coverage
36%
Covered branches: 17
Total branches: 46
Branch coverage: 36.9%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
.ctor(...)50%22100%
GetEnumerator()36.36%444434.37%
System.Collections.IEnumerable.GetEnumerator()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityTokenParametersEnumerable.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 CoreWCF.Channels;
 7using CoreWCF.Security.Tokens;
 8
 9namespace CoreWCF.Security
 10{
 11    internal class SecurityTokenParametersEnumerable : IEnumerable<SecurityTokenParameters>
 12    {
 13        private readonly SecurityBindingElement _sbe;
 14        private readonly bool _clientTokensOnly;
 15
 16        public SecurityTokenParametersEnumerable(SecurityBindingElement sbe)
 4417            : this(sbe, false) { }
 18
 4419        public SecurityTokenParametersEnumerable(SecurityBindingElement sbe, bool clientTokensOnly)
 20        {
 4421            _sbe = sbe ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(sbe));
 4422            _clientTokensOnly = clientTokensOnly;
 4423        }
 24
 25        public IEnumerator<SecurityTokenParameters> GetEnumerator()
 26        {
 4427            if (_sbe is SymmetricSecurityBindingElement)
 28            {
 029                SymmetricSecurityBindingElement ssbe = (SymmetricSecurityBindingElement)_sbe;
 030                if (ssbe.ProtectionTokenParameters != null && (!_clientTokensOnly || !ssbe.ProtectionTokenParameters.Has
 31                {
 032                    yield return ssbe.ProtectionTokenParameters;
 33                }
 34            }
 35            // TODO
 36            /* else if (this.sbe is AsymmetricSecurityBindingElement)
 37             {
 38                 AsymmetricSecurityBindingElement asbe = (AsymmetricSecurityBindingElement)sbe;
 39                 if (asbe.InitiatorTokenParameters != null)
 40                     yield return asbe.InitiatorTokenParameters;
 41                 if (asbe.RecipientTokenParameters != null && !this.clientTokensOnly)
 42                     yield return asbe.RecipientTokenParameters;
 43             }*/
 14344            foreach (SecurityTokenParameters stp in _sbe.EndpointSupportingTokenParameters.Endorsing)
 45            {
 3246                if (stp != null)
 47                {
 3248                    yield return stp;
 49                }
 50            }
 51
 9452            foreach (SecurityTokenParameters stp in _sbe.EndpointSupportingTokenParameters.SignedEncrypted)
 53            {
 1254                if (stp != null)
 55                {
 1256                    yield return stp;
 57                }
 58            }
 59
 7060            foreach (SecurityTokenParameters stp in _sbe.EndpointSupportingTokenParameters.SignedEndorsing)
 61            {
 062                if (stp != null)
 63                {
 064                    yield return stp;
 65                }
 66            }
 67
 7068            foreach (SecurityTokenParameters stp in _sbe.EndpointSupportingTokenParameters.Signed)
 69            {
 070                if (stp != null)
 71                {
 072                    yield return stp;
 73                }
 74            }
 75
 7076            foreach (SupportingTokenParameters str in _sbe.OperationSupportingTokenParameters.Values)
 77            {
 078                if (str != null)
 79                {
 080                    foreach (SecurityTokenParameters stp in str.Endorsing)
 81                    {
 082                        if (stp != null)
 83                        {
 084                            yield return stp;
 85                        }
 86                    }
 87
 088                    foreach (SecurityTokenParameters stp in str.SignedEncrypted)
 89                    {
 090                        if (stp != null)
 91                        {
 092                            yield return stp;
 93                        }
 94                    }
 95
 096                    foreach (SecurityTokenParameters stp in str.SignedEndorsing)
 97                    {
 098                        if (stp != null)
 99                        {
 0100                            yield return stp;
 101                        }
 102                    }
 103
 0104                    foreach (SecurityTokenParameters stp in str.Signed)
 105                    {
 0106                        if (stp != null)
 107                        {
 0108                            yield return stp;
 109                        }
 110                    }
 111                }
 0112            }
 35113        }
 114
 115        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 116        {
 0117            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 118        }
 119    }
 120}