< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.NegotiationTokenAuthenticatorState
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/NegotiationTokenAuthenticatorState.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 53
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Dispose()100%110%
SetServiceToken(...)0%220%
GetRemoteIdentityName()0%220%
CheckCompleted()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/NegotiationTokenAuthenticatorState.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.Runtime;
 6using CoreWCF.Security.Tokens;
 7
 8namespace CoreWCF.Security
 9{
 10    internal class NegotiationTokenAuthenticatorState : IDisposable
 11    {
 12        private bool _isNegotiationCompleted;
 13        private SecurityContextSecurityToken _serviceToken;
 14
 015        public AsyncLock AsyncLock { get; } = new AsyncLock();
 16
 017        public bool IsNegotiationCompleted => _isNegotiationCompleted;
 18
 19        public SecurityContextSecurityToken ServiceToken
 20        {
 21            get
 22            {
 023                CheckCompleted();
 024                return _serviceToken;
 25            }
 26        }
 27
 028        public virtual void Dispose() { }
 29
 30        public void SetServiceToken(SecurityContextSecurityToken token)
 31        {
 032            _serviceToken = token ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(token));
 033            _isNegotiationCompleted = true;
 034        }
 35
 36        public virtual string GetRemoteIdentityName()
 37        {
 038            if (_isNegotiationCompleted)
 39            {
 040                return SecurityUtils.GetIdentityNamesFromPolicies(_serviceToken.AuthorizationPolicies);
 41            }
 042            return string.Empty;
 43        }
 44
 45        private void CheckCompleted()
 46        {
 047            if (!_isNegotiationCompleted)
 48            {
 049                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Neg
 50            }
 051        }
 52    }
 53}