< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.SspiSecurityToken
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SspiSecurityToken.cs
Line coverage
44%
Covered lines: 11
Uncovered lines: 14
Coverable lines: 25
Total lines: 66
Line coverage: 44%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SspiSecurityToken.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.Net;
 7using System.Security.Principal;
 8using CoreWCF.IdentityModel;
 9using CoreWCF.IdentityModel.Tokens;
 10
 11namespace CoreWCF.Security.Tokens
 12{
 13    public class SspiSecurityToken : SecurityToken
 14    {
 15        private string _id;
 16        private readonly DateTime _effectiveTime;
 17        private readonly DateTime _expirationTime;
 18
 019        public SspiSecurityToken(TokenImpersonationLevel impersonationLevel, bool allowNtlm, NetworkCredential networkCr
 20        {
 021            ImpersonationLevel = impersonationLevel;
 022            AllowNtlm = allowNtlm;
 023            NetworkCredential = SecurityUtils.GetNetworkCredentialsCopy(networkCredential);
 024            _effectiveTime = DateTime.UtcNow;
 025            _expirationTime = _effectiveTime.AddHours(10);
 026        }
 27
 1228        public SspiSecurityToken(NetworkCredential networkCredential, bool extractGroupsForWindowsAccounts, bool allowUn
 29        {
 1230            NetworkCredential = SecurityUtils.GetNetworkCredentialsCopy(networkCredential);
 1231            ExtractGroupsForWindowsAccounts = extractGroupsForWindowsAccounts;
 1232            AllowUnauthenticatedCallers = allowUnauthenticatedCallers;
 1233            _effectiveTime = DateTime.UtcNow;
 1234            _expirationTime = _effectiveTime.AddHours(10);
 1235        }
 36
 37        public override string Id
 38        {
 39            get
 40            {
 041                if (_id == null)
 42                {
 043                    _id = SecurityUniqueId.Create().Value;
 44                }
 45
 046                return _id;
 47            }
 48        }
 49
 050        public override DateTime ValidFrom => _effectiveTime;
 51
 052        public override DateTime ValidTo => _expirationTime;
 53
 054        public bool AllowUnauthenticatedCallers { get; } = SspiSecurityTokenProvider.DefaultAllowUnauthenticatedCallers;
 55
 1256        public TokenImpersonationLevel ImpersonationLevel { get; }
 57
 1258        public bool AllowNtlm { get; }
 59
 1260        public NetworkCredential NetworkCredential { get; }
 61
 1262        public bool ExtractGroupsForWindowsAccounts { get; }
 63
 064        public override ReadOnlyCollection<SecurityKey> SecurityKeys => EmptyReadOnlyCollection<SecurityKey>.Instance;
 65    }
 66}