< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.SecurityHeader
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityHeader.cs
Line coverage
77%
Covered lines: 35
Uncovered lines: 10
Coverable lines: 45
Total lines: 114
Line coverage: 77.7%
Branch coverage
50%
Covered branches: 5
Total branches: 10
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%88100%
SetProcessingStarted()100%11100%
ThrowIfProcessingStarted()50%2266.66%
ToString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityHeader.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.Globalization;
 6using CoreWCF.Channels;
 7using CoreWCF.Description;
 8
 9namespace CoreWCF.Security
 10{
 11    internal abstract class SecurityHeader : MessageHeader
 12    {
 13        private readonly string _actor;
 15714        private bool _encryptedKeyContainsReferenceList = true;
 15        private readonly bool _mustUnderstand;
 16        private readonly bool _relay;
 15717        private bool _requireMessageProtection = true;
 18        private bool _processingStarted;
 19        private bool _maintainSignatureConfirmationState;
 20        private SecurityHeaderLayout _layout = SecurityHeaderLayout.Strict;
 21
 15722        public SecurityHeader(Message message,
 15723            string actor, bool mustUnderstand, bool relay,
 15724            SecurityStandardsManager standardsManager
 15725            , SecurityAlgorithmSuite algorithmSuite,
 15726            MessageDirection transferDirection)
 27        {
 15728            Message = message ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message));
 15729            _actor = actor ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(actor));
 15730            _mustUnderstand = mustUnderstand;
 15731            _relay = relay;
 15732            StandardsManager = standardsManager ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(name
 15733            AlgorithmSuite = algorithmSuite ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(a
 15734            MessageDirection = transferDirection;
 15735        }
 36
 6337        public override string Actor => _actor;
 38
 9239        public SecurityAlgorithmSuite AlgorithmSuite { get; }
 40
 41        public bool EncryptedKeyContainsReferenceList
 42        {
 043            get { return _encryptedKeyContainsReferenceList; }
 44            set
 45            {
 046                ThrowIfProcessingStarted();
 047                _encryptedKeyContainsReferenceList = value;
 048            }
 49        }
 50
 51        public bool RequireMessageProtection
 52        {
 99253            get { return _requireMessageProtection; }
 54            set
 55            {
 15756                ThrowIfProcessingStarted();
 15757                _requireMessageProtection = value;
 15758            }
 59        }
 60
 61        public bool MaintainSignatureConfirmationState
 62        {
 2263            get { return _maintainSignatureConfirmationState; }
 64            set
 65            {
 066                ThrowIfProcessingStarted();
 067                _maintainSignatureConfirmationState = value;
 068            }
 69        }
 70
 108471        protected Message Message { get; set; }
 72
 12673        public override bool MustUnderstand => _mustUnderstand;
 74
 6375        public override bool Relay => _relay;
 76
 77        public SecurityHeaderLayout Layout
 78        {
 79            get
 80            {
 22081                return _layout;
 82            }
 83            set
 84            {
 13785                ThrowIfProcessingStarted();
 13786                _layout = value;
 13787            }
 88        }
 89
 68790        public SecurityStandardsManager StandardsManager { get; }
 91
 092        public MessageDirection MessageDirection { get; }
 93
 24494        protected MessageVersion Version => Message.Version;
 95
 96        protected void SetProcessingStarted()
 97        {
 15798            _processingStarted = true;
 15799        }
 100
 101        protected void ThrowIfProcessingStarted()
 102        {
 1004103            if (_processingStarted)
 104            {
 0105                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.OperationCann
 106            }
 1004107        }
 108
 109        public override string ToString()
 110        {
 0111            return string.Format(CultureInfo.InvariantCulture, "{0}(Actor = '{1}')", GetType().Name, Actor);
 112        }
 113    }
 114}