< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.Saml.KeyInfo
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/Saml/KeyInfo.cs
Line coverage
20%
Covered lines: 5
Uncovered lines: 20
Coverable lines: 25
Total lines: 80
Line coverage: 20%
Branch coverage
0%
Covered branches: 0
Total branches: 18
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
MatchesKey(...)0%440%
Equals(...)0%14140%
GetHashCode()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/Saml/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;
 5using Microsoft.IdentityModel.Tokens;
 6
 7namespace CoreWCF.IdentityModel.Tokens.Saml
 8{
 9    public class KeyInfo : Microsoft.IdentityModel.Xml.KeyInfo
 10    {
 11        public SecurityTokenReference SecurityTokenReference
 12        {
 1913            get;
 314            set;
 15        }
 16
 17        public BinarySecret BinarySecret
 18        {
 419            get;
 120            set;
 21        }
 22
 23        public EncryptedKey EncryptedKey
 24        {
 225            get;
 026            set;
 27        }
 28
 29        protected override bool MatchesKey(Microsoft.IdentityModel.Tokens.SecurityKey key)
 30        {
 31            X509SecurityKey x509SecurityKey = key as X509SecurityKey;
 032            if (key != null)
 33            {
 034                if (SecurityTokenReference != null)
 35                {
 036                    return SecurityTokenReference.MatchesKey(key);
 37                }
 38            }
 39
 040            return base.MatchesKey(key);
 41        }
 42
 43        public override bool Equals(object obj)
 44        {
 45            // Check if obj is null or not the same type
 046            if (obj == null || GetType() != obj.GetType())
 047                return false;
 48
 49            // Check if it's the same instance
 050            if (ReferenceEquals(this, obj))
 051                return true;
 52
 053            KeyInfo other = (KeyInfo)obj;
 54
 55            // Call base class Equals
 056            if (!base.Equals(obj))
 057                return false;
 58
 59            // Compare SecurityTokenReference
 060            if (!Object.Equals(SecurityTokenReference, other.SecurityTokenReference))
 061                return false;
 62
 63            // Compare BinarySecret
 064            if (!Object.Equals(BinarySecret, other.BinarySecret))
 065                return false;
 66
 67            // Compare EncryptedKey
 068            if (!Object.Equals(EncryptedKey, other.EncryptedKey))
 069                return false;
 70
 071            return true;
 72        }
 73
 74        public override int GetHashCode()
 75        {
 076            return base.GetHashCode() * 23 + HashCode.Combine(SecurityTokenReference, BinarySecret, EncryptedKey);
 77        }
 78    }
 79}
 80