< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WrappedSaml11SecurityTokenAuthenticator
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrappedSaml11SecurityTokenAuthenticator.cs
Line coverage
92%
Covered lines: 13
Uncovered lines: 1
Coverable lines: 14
Total lines: 65
Line coverage: 92.8%
Branch coverage
50%
Covered branches: 3
Total branches: 6
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%44100%
ValidateTokenCoreAsync(...)50%2290%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrappedSaml11SecurityTokenAuthenticator.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.Collections.Generic;
 5using System.Collections.ObjectModel;
 6using CoreWCF.IdentityModel.Policy;
 7using CoreWCF.IdentityModel.Selectors;
 8using CoreWCF.IdentityModel.Tokens;
 9using System.Security.Claims;
 10using System;
 11using System.Threading.Tasks;
 12
 13namespace CoreWCF.Security
 14{
 15    /// <summary>
 16    /// Wraps a Samll1SecurityTokenHandler. Delegates the token authentication call to
 17    /// this wrapped tokenAuthenticator.  Wraps the returned ClaimsIdentities into
 18    /// an IAuthorizationPolicy.
 19    /// </summary>
 20    internal class WrappedSaml11SecurityTokenAuthenticator : SamlSecurityTokenAuthenticator
 21    {
 22        private readonly SamlSecurityTokenHandler _wrappedSaml11SecurityTokenHandler;
 23        private readonly ExceptionMapper _exceptionMapper;
 24
 25        /// <summary>
 26        /// Initializes an instance of <see cref="WrappedSaml11SecurityTokenAuthenticator"/>
 27        /// </summary>
 28        /// <param name="saml11SecurityTokenHandler">The Saml11SecurityTokenHandler to wrap.</param>
 29        /// <param name="exceptionMapper">Converts token validation exceptions to SOAP faults.</param>
 30        public WrappedSaml11SecurityTokenAuthenticator(
 31            SamlSecurityTokenHandler saml11SecurityTokenHandler,
 32            ExceptionMapper exceptionMapper)
 233            : base(new List<SecurityTokenAuthenticator>())
 34        {
 235            _wrappedSaml11SecurityTokenHandler = saml11SecurityTokenHandler ?? throw DiagnosticUtility.ExceptionUtility.
 236            _exceptionMapper = exceptionMapper ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameo
 237        }
 38
 39        /// <summary>
 40        /// Validates the token using the wrapped token handler and generates IAuthorizationPolicy
 41        /// wrapping the returned ClaimsIdentities.
 42        /// </summary>
 43        /// <param name="token">Token to be validated.</param>
 44        /// <returns>Read-only collection of IAuthorizationPolicy</returns>
 45        protected override ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateTokenCoreAsync(SecurityToken toke
 46        {
 4747            IEnumerable<ClaimsIdentity> identities = null;
 48            try
 49            {
 4750                identities = _wrappedSaml11SecurityTokenHandler.ValidateToken(token);
 2851            }
 1952            catch (Exception ex)
 53            {
 1954                if (!_exceptionMapper.HandleSecurityTokenProcessingException(ex))
 55                {
 1956                    throw;
 57                }
 058            }
 59
 2860            List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>(1);
 2861            policies.Add(new AuthorizationPolicy(identities));
 2862            return new ValueTask<ReadOnlyCollection<IAuthorizationPolicy>>(policies.AsReadOnly());
 63        }
 64    }
 65}