< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Selectors.WindowsSecurityTokenAuthenticator
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Selectors/WindowsSecurityTokenAuthenticator.cs
Line coverage
78%
Covered lines: 11
Uncovered lines: 3
Coverable lines: 14
Total lines: 52
Line coverage: 78.5%
Branch coverage
50%
Covered branches: 2
Total branches: 4
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()100%11100%
.ctor(...)100%11100%
CanValidateTokenCore(...)50%22100%
ValidateTokenCoreAsync(...)50%2257.14%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Selectors/WindowsSecurityTokenAuthenticator.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.Collections.Generic;
 6using System.Collections.ObjectModel;
 7using System.Security.Claims;
 8using System.Threading.Tasks;
 9using CoreWCF.IdentityModel.Claims;
 10using CoreWCF.IdentityModel.Policy;
 11using CoreWCF.IdentityModel.Tokens;
 12using CoreWCF.Security;
 13
 14namespace CoreWCF.IdentityModel.Selectors
 15{
 16    public class WindowsSecurityTokenAuthenticator : SecurityTokenAuthenticator
 17    {
 18        private readonly bool _includeWindowsGroups;
 19        private readonly LdapSettings _ldapSettings;
 20
 121        public WindowsSecurityTokenAuthenticator() : this(WindowsClaimSet.DefaultIncludeWindowsGroups, null)
 22        {
 123        }
 24
 125        public WindowsSecurityTokenAuthenticator(bool includeWindowsGroups, LdapSettings ldapSettings)
 26        {
 127            _includeWindowsGroups = includeWindowsGroups;
 128            _ldapSettings = ldapSettings;
 129        }
 30
 31        protected override bool CanValidateTokenCore(SecurityToken token)
 32        {
 133            return (token is WindowsSecurityToken || token is GenericIdentitySecurityToken);
 34        }
 35
 36        protected override ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateTokenCoreAsync(SecurityToken toke
 37        {
 138            if (token is WindowsSecurityToken)
 39            {
 040                var windowsToken = (WindowsSecurityToken)token;
 041                var claimSet = new WindowsClaimSet(windowsToken.WindowsIdentity, windowsToken.AuthenticationType, _inclu
 042                return new ValueTask<ReadOnlyCollection<IAuthorizationPolicy>>(SecurityUtils.CreateAuthorizationPolicies
 43            }
 44            else
 45            {
 146                var genericToken = (GenericIdentitySecurityToken)token;
 147                var claimSet = new WindowsClaimSet(genericToken.GenericIdentity,  _includeWindowsGroups, _ldapSettings);
 148                return new ValueTask<ReadOnlyCollection<IAuthorizationPolicy>>(SecurityUtils.CreateAuthorizationPolicies
 49            }
 50        }
 51    }
 52}