< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.UnixPosixIdentityBindingElement
Assembly: CoreWCF.UnixDomainSocket
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.UnixDomainSocket/src/CoreWCF/Channels/UnixPosixIdentityBindingElement.cs
Line coverage
82%
Covered lines: 14
Uncovered lines: 3
Coverable lines: 17
Total lines: 62
Line coverage: 82.3%
Branch coverage
62%
Covered branches: 5
Total branches: 8
Branch coverage: 62.5%
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(...)100%11100%
Clone()100%11100%
BuildServerStreamUpgradeProvider(...)50%2266.66%
GetProperty(...)66.66%6671.42%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.UnixDomainSocket/src/CoreWCF/Channels/UnixPosixIdentityBindingElement.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.Net.Security;
 6using CoreWCF.Security;
 7
 8namespace CoreWCF.Channels
 9{
 10    public class UnixPosixIdentityBindingElement : StreamUpgradeBindingElement
 11    {
 12        private ProtectionLevel _protectionLevel;
 13
 14        public UnixPosixIdentityBindingElement()
 1715            : base()
 16        {
 1717            _protectionLevel = ConnectionOrientedTransportDefaults.ProtectionLevel;
 1718        }
 19
 20        protected UnixPosixIdentityBindingElement(UnixPosixIdentityBindingElement elementToBeCloned)
 1921            : base(elementToBeCloned)
 22        {
 1923            _protectionLevel = elementToBeCloned._protectionLevel;
 1924        }
 25
 26        public override BindingElement Clone()
 27        {
 1928            return new UnixPosixIdentityBindingElement(this);
 29        }
 30
 31        public override StreamUpgradeProvider BuildServerStreamUpgradeProvider(BindingContext context)
 32        {
 233            if(string.Compare(context.Binding.Scheme, "net.uds", true) != 0)
 34            {
 035                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(context.Binding.Scheme), SR.UDSUriSc
 36            }
 237            return new UnixPosixIdentitySecurityUpgradeProvider(this, context);
 38        }
 39
 40        public override T GetProperty<T>(BindingContext context)
 41        {
 442            if (context == null)
 43            {
 044                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
 45            }
 46
 447            if (typeof(T) == typeof(ISecurityCapabilities))
 48            {
 249                return (T)(object)new SecurityCapabilities(true, true, true, _protectionLevel, _protectionLevel);
 50            }
 251            else if (typeof(T) == typeof(IdentityVerifier))
 52            {
 053                return (T)(object)IdentityVerifier.CreateDefault();
 54            }
 55            else
 56            {
 257                return context.GetInnerProperty<T>();
 58            }
 59        }
 60    }
 61}
 62