< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WrappedSamlSecurityTokenAuthenticator
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrappedSamlSecurityTokenAuthenticator.cs
Line coverage
64%
Covered lines: 9
Uncovered lines: 5
Coverable lines: 14
Total lines: 58
Line coverage: 64.2%
Branch coverage
40%
Covered branches: 4
Total branches: 10
Branch coverage: 40%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%4475%
CanValidateTokenCore(...)50%22100%
ValidateTokenCoreAsync(...)25%4440%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrappedSamlSecurityTokenAuthenticator.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.ObjectModel;
 6using System.Threading.Tasks;
 7using CoreWCF.IdentityModel.Policy;
 8using CoreWCF.IdentityModel.Selectors;
 9using CoreWCF.IdentityModel.Tokens;
 10
 11namespace CoreWCF.Security
 12{
 13    /// <summary>
 14    /// Authenticator that wraps both SAML 1.1 and SAML 2.0 WrapperSecurityTokenAuthenticators.
 15    /// </summary>
 16    internal class WrappedSamlSecurityTokenAuthenticator : SecurityTokenAuthenticator
 17    {
 18        private WrappedSaml11SecurityTokenAuthenticator _wrappedSaml11SecurityTokenAuthenticator;
 19        private WrappedSaml2SecurityTokenAuthenticator _wrappedSaml2SecurityTokenAuthenticator;
 20
 221        public WrappedSamlSecurityTokenAuthenticator(WrappedSaml11SecurityTokenAuthenticator wrappedSaml11SecurityTokenA
 22        {
 223            if (wrappedSaml11SecurityTokenAuthenticator == null)
 24            {
 025                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(wrappedSaml11SecurityTokenAuthen
 26            }
 27
 228            if (wrappedSaml2SecurityTokenAuthenticator == null)
 29            {
 030                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(wrappedSaml2SecurityTokenAuthent
 31            }
 32
 233            _wrappedSaml11SecurityTokenAuthenticator = wrappedSaml11SecurityTokenAuthenticator;
 234            _wrappedSaml2SecurityTokenAuthenticator = wrappedSaml2SecurityTokenAuthenticator;
 235        }
 36
 37        protected override bool CanValidateTokenCore(SecurityToken token)
 38        {
 9439            return (_wrappedSaml11SecurityTokenAuthenticator.CanValidateToken(token) || _wrappedSaml2SecurityTokenAuthen
 40        }
 41
 42        protected override ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateTokenCoreAsync(SecurityToken toke
 43        {
 4744            if (_wrappedSaml11SecurityTokenAuthenticator.CanValidateToken(token))
 45            {
 4746                return _wrappedSaml11SecurityTokenAuthenticator.ValidateTokenAsync(token);
 47            }
 048            else if (_wrappedSaml2SecurityTokenAuthenticator.CanValidateToken(token))
 49            {
 050                return _wrappedSaml2SecurityTokenAuthenticator.ValidateTokenAsync(token);
 51            }
 52            else
 53            {
 054                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.ID4101, tok
 55            }
 56        }
 57    }
 58}