< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.UnixDomainSocketSecurity
Assembly: CoreWCF.UnixDomainSocket
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.UnixDomainSocket/src/CoreWCF/UnixDomainSocketSecurity.cs
Line coverage
73%
Covered lines: 19
Uncovered lines: 7
Coverable lines: 26
Total lines: 80
Line coverage: 73%
Branch coverage
75%
Covered branches: 15
Total branches: 20
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()50%22100%
.ctor()100%11100%
.ctor(...)0%220%
CreateTransportSecurity()92.85%141488.88%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.UnixDomainSocket/src/CoreWCF/UnixDomainSocketSecurity.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.ComponentModel;
 6using System.Diagnostics.Contracts;
 7using System.Runtime.InteropServices;
 8using CoreWCF.Channels;
 9using CoreWCF.Runtime;
 10
 11namespace CoreWCF
 12{
 13    public sealed class UnixDomainSocketSecurity
 14    {
 115        private static UnixDomainSocketSecurityMode s_defaultMode =
 116            RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
 117                UnixDomainSocketSecurityMode.Transport : UnixDomainSocketSecurityMode.TransportCredentialOnly;
 18
 19
 20        private UnixDomainSocketSecurityMode _mode;
 21
 922        public UnixDomainSocketSecurity()
 23        {
 924            _mode = s_defaultMode;
 925            Transport = new UnixDomainSocketTransportSecurity();
 926        }
 27
 028        private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSocketTransportSecurity transportS
 29        {
 30            Fx.Assert(UnixDomainSocketSecurityModeHelper.IsDefined(mode),
 31                            string.Format("Invalid SecurityMode value: {0} = {1} (default is {2} = {3}).",
 32                                            (int)mode,
 33                                            mode.ToString(),
 34                                            (int)s_defaultMode,
 35                                            s_defaultMode.ToString()));
 36
 037            _mode = mode;
 038            Transport = transportSecurity ?? new UnixDomainSocketTransportSecurity();
 039        }
 40
 41
 42        public UnixDomainSocketSecurityMode Mode
 43        {
 044            get { return _mode; }
 45            set
 46            {
 647                if (!UnixDomainSocketSecurityModeHelper.IsDefined(value))
 48                {
 049                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 50                }
 651                _mode = value;
 652            }
 53        }
 54
 8155        public UnixDomainSocketTransportSecurity Transport { get; set; }
 56
 57        internal BindingElement CreateTransportSecurity()
 58        {
 5059            if (_mode == UnixDomainSocketSecurityMode.Transport || _mode == UnixDomainSocketSecurityMode.TransportCreden
 60            {
 3561                if ((_mode == UnixDomainSocketSecurityMode.TransportCredentialOnly && Transport.ClientCredentialType != 
 3562                    ||
 3563                    (_mode == UnixDomainSocketSecurityMode.Transport && Transport.ClientCredentialType == UnixDomainSock
 64                {
 365                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.Uns
 66                }
 3267                return Transport.CreateTransportProtectionAndAuthentication();
 68            }
 1569            else if (_mode == UnixDomainSocketSecurityMode.None)
 70            {
 1571                return null;
 72            }
 73            else
 74            {
 075                throw new NotSupportedException();
 76            }
 77        }
 78
 79    }
 80}