< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WSSecureConversationFeb2005
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSSecureConversationFeb2005.cs
Line coverage
72%
Covered lines: 26
Uncovered lines: 10
Coverable lines: 36
Total lines: 113
Line coverage: 72.2%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)83.33%6688.88%
PopulateTokenEntries(...)100%11100%
.ctor(...)100%11100%
CanReadGeneration(...)100%11100%
CanReadGeneration(...)0%220%
ReadGeneration(...)100%110%
ReadGeneration(...)100%110%
WriteGeneration(...)50%2233.33%
.ctor()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSSecureConversationFeb2005.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.Xml;
 7using CoreWCF.Security.Tokens;
 8using TokenEntry = CoreWCF.Security.WSSecurityTokenSerializer.TokenEntry;
 9
 10namespace CoreWCF.Security
 11{
 12    internal class WSSecureConversationFeb2005 : WSSecureConversation
 13    {
 14        private readonly SecurityStateEncoder _securityStateEncoder;
 15        private readonly IList<Type> _knownClaimTypes;
 16
 17        public WSSecureConversationFeb2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityState
 18            int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength)
 6519            : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
 20        {
 6521            if (securityStateEncoder != null)
 22            {
 6123                _securityStateEncoder = securityStateEncoder;
 24            }
 25            else
 26            {
 427                _securityStateEncoder = new DataProtectionSecurityStateEncoder();
 28            }
 29
 6530            _knownClaimTypes = new List<Type>();
 6531            if (knownTypes != null)
 32            {
 33                // Clone this collection.
 12234                foreach (Type knownType in knownTypes)
 35                {
 036                    _knownClaimTypes.Add(knownType);
 37                }
 38            }
 6539        }
 40
 14441        public override SecureConversationDictionary SerializerDictionary => XD.SecureConversationFeb2005Dictionary;
 42
 43        public override void PopulateTokenEntries(IList<TokenEntry> tokenEntryList)
 44        {
 6545            base.PopulateTokenEntries(tokenEntryList);
 6546            tokenEntryList.Add(new SecurityContextTokenEntryFeb2005(this, _securityStateEncoder, _knownClaimTypes));
 6547        }
 48
 49        private class SecurityContextTokenEntryFeb2005 : SecurityContextTokenEntry
 50        {
 51            public SecurityContextTokenEntryFeb2005(WSSecureConversationFeb2005 parent, SecurityStateEncoder securitySta
 6552                : base(parent, securityStateEncoder, knownClaimTypes)
 53            {
 6554            }
 55
 56            protected override bool CanReadGeneration(XmlDictionaryReader reader)
 57            {
 1258                return reader.IsStartElement(DXD.SecureConversationDec2005Dictionary.Instance, XD.SecureConversationFeb2
 59            }
 60
 61            protected override bool CanReadGeneration(XmlElement element)
 62            {
 063                return (element.LocalName == DXD.SecureConversationDec2005Dictionary.Instance.Value &&
 064                    element.NamespaceURI == XD.SecureConversationFeb2005Dictionary.Namespace.Value);
 65            }
 66
 67            protected override UniqueId ReadGeneration(XmlDictionaryReader reader)
 68            {
 069                return reader.ReadElementContentAsUniqueId();
 70            }
 71
 72            protected override UniqueId ReadGeneration(XmlElement element)
 73            {
 074                return XmlHelper.ReadTextElementAsUniqueId(element);
 75            }
 76
 77            protected override void WriteGeneration(XmlDictionaryWriter writer, SecurityContextSecurityToken sct)
 78            {
 79                // serialize the generation
 680                if (sct.KeyGeneration != null)
 81                {
 082                    writer.WriteStartElement(XD.SecureConversationFeb2005Dictionary.Prefix.Value, DXD.SecureConversation
 083                        XD.SecureConversationFeb2005Dictionary.Namespace);
 084                    XmlHelper.WriteStringAsUniqueId(writer, sct.KeyGeneration);
 085                    writer.WriteEndElement();
 86                }
 687            }
 88        }
 89
 90        public class DriverFeb2005 : Driver
 91        {
 6492            public DriverFeb2005()
 93            {
 6494            }
 95
 12596            protected override SecureConversationDictionary DriverDictionary => XD.SecureConversationFeb2005Dictionary;
 97
 4198            public override XmlDictionaryString CloseAction => XD.SecureConversationFeb2005Dictionary.RequestSecurityCon
 99
 12100            public override XmlDictionaryString CloseResponseAction => XD.SecureConversationFeb2005Dictionary.RequestSec
 101
 17102            public override bool IsSessionSupported => true;
 103
 40104            public override XmlDictionaryString RenewAction => XD.SecureConversationFeb2005Dictionary.RequestSecurityCon
 105
 6106            public override XmlDictionaryString RenewResponseAction => XD.SecureConversationFeb2005Dictionary.RequestSec
 107
 0108            public override XmlDictionaryString Namespace => XD.SecureConversationFeb2005Dictionary.Namespace;
 109
 18110            public override string TokenTypeUri => XD.SecureConversationFeb2005Dictionary.SecurityContextTokenType.Value
 111        }
 112    }
 113}