< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.BinaryKeyIdentifierClause
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/BinaryKeyIdentifierClause.cs
Line coverage
57%
Covered lines: 12
Uncovered lines: 9
Coverable lines: 21
Total lines: 81
Line coverage: 57.1%
Branch coverage
41%
Covered branches: 5
Total branches: 12
Branch coverage: 41.6%
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(...)66.66%6677.77%
GetBuffer()100%110%
GetRawBuffer()100%110%
Matches(...)0%440%
Matches(...)100%11100%
Matches(...)50%2266.66%
ToBase64String()100%110%
ToHexString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/BinaryKeyIdentifierClause.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 CoreWCF.Security;
 6using HexBinary = CoreWCF.Security.SoapHexBinary;
 7
 8namespace CoreWCF.IdentityModel.Tokens
 9{
 10    public abstract class BinaryKeyIdentifierClause : SecurityKeyIdentifierClause
 11    {
 12        private readonly byte[] _identificationData;
 13
 14        protected BinaryKeyIdentifierClause(string clauseType, byte[] identificationData, bool cloneBuffer)
 5215            : this(clauseType, identificationData, cloneBuffer, null, 0)
 16        {
 5217        }
 18
 19        protected BinaryKeyIdentifierClause(string clauseType, byte[] identificationData, bool cloneBuffer, byte[] deriv
 5620            : base(clauseType, derivationNonce, derivationLength)
 21        {
 5622            if (identificationData == null)
 23            {
 024                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(identificatio
 25            }
 5626            if (identificationData.Length == 0)
 27            {
 028                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(identif
 29            }
 30
 5631            if (cloneBuffer)
 32            {
 633                _identificationData = SecurityUtils.CloneBuffer(identificationData);
 34            }
 35            else
 36            {
 5037                _identificationData = identificationData;
 38            }
 5039        }
 40
 41        public byte[] GetBuffer()
 42        {
 043            return SecurityUtils.CloneBuffer(_identificationData);
 44        }
 45
 46        protected byte[] GetRawBuffer()
 47        {
 048            return _identificationData;
 49        }
 50
 51        public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
 52        {
 053            BinaryKeyIdentifierClause that = keyIdentifierClause as BinaryKeyIdentifierClause;
 054            return ReferenceEquals(this, that) || (that != null && that.Matches(_identificationData));
 55        }
 56
 57        public bool Matches(byte[] data)
 58        {
 5059            return Matches(data, 0);
 60        }
 61
 62        public bool Matches(byte[] data, int offset)
 63        {
 5364            if (offset < 0)
 65            {
 066                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset)
 67            }
 5368            return SecurityUtils.MatchesBuffer(_identificationData, 0, data, offset);
 69        }
 70
 71        internal string ToBase64String()
 72        {
 073            return Convert.ToBase64String(_identificationData);
 74        }
 75
 76        internal string ToHexString()
 77        {
 078            return new HexBinary(_identificationData).ToString();
 79        }
 80    }
 81}