< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.KeyInfo
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/KeyInfo.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 29
Coverable lines: 29
Total lines: 85
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
ReadXml(...)0%14140%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/KeyInfo.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.Xml;
 5using CoreWCF.IdentityModel.Selectors;
 6using CoreWCF.IdentityModel.Tokens;
 7
 8namespace CoreWCF.IdentityModel
 9{
 10    internal class KeyInfo
 11    {
 12        private readonly SecurityTokenSerializer _keyInfoSerializer;
 13        private SecurityKeyIdentifier _ski;
 14
 015        public KeyInfo( SecurityTokenSerializer keyInfoSerializer )
 16        {
 017            _keyInfoSerializer = keyInfoSerializer;
 018            _ski = new SecurityKeyIdentifier();
 019        }
 20
 021        public string RetrievalMethod { get; private set; }
 22
 23        public SecurityKeyIdentifier KeyIdentifier
 24        {
 025            get { return _ski; }
 26            set
 27            {
 028                if ( value == null )
 29                {
 030                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 31                }
 32
 033                _ski = value;
 034            }
 35        }
 36
 37        public virtual void ReadXml(XmlDictionaryReader reader)
 38        {
 039            if ( reader == null )
 40            {
 041                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reader));
 42            }
 43
 044            reader.MoveToContent();
 045            if ( reader.IsStartElement(CoreWCF.XD.XmlSignatureDictionary.KeyInfo.Value, CoreWCF.XD.XmlSignatureDictionar
 46            {
 47                // <KeyInfo>
 048                reader.ReadStartElement();
 49
 050                while ( reader.IsStartElement() )
 51                {
 52                    // <RetrievalMethod>
 053                    if ( reader.IsStartElement( XmlSignatureConstants.Elements.RetrievalMethod, CoreWCF.XD.XmlSignatureD
 54                    {
 055                        string method = reader.GetAttribute(CoreWCF.XD.XmlSignatureDictionary.URI.Value );
 056                        if ( !string.IsNullOrEmpty( method ) )
 57                        {
 058                            RetrievalMethod = method;
 59                        }
 060                        reader.Skip();
 61                    }
 62                    // check if internal serializer can handle clause
 063                    else if ( _keyInfoSerializer.CanReadKeyIdentifierClause( reader ) )
 64                    {
 065                        _ski.Add( _keyInfoSerializer.ReadKeyIdentifierClause( reader ) );
 66                    }
 67                    // trace we skipped over an element
 068                    else if ( reader.IsStartElement() )
 69                    {
 070                        string xml = reader.ReadOuterXml();
 71
 72                        //if ( DiagnosticUtility.ShouldTraceWarning )
 73                        //{
 74                        //    TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID80
 75                        //}
 76                    }
 077                    reader.MoveToContent();
 78                }
 79
 080                reader.MoveToContent();
 081                reader.ReadEndElement();
 82            }
 083        }
 84    }
 85}