< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.UserNameSecurityToken
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/UserNameSecurityToken.cs
Line coverage
72%
Covered lines: 13
Uncovered lines: 5
Coverable lines: 18
Total lines: 49
Line coverage: 72.2%
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(...)50%4480%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/UserNameSecurityToken.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 CoreWCF.Security;
 7
 8namespace CoreWCF.IdentityModel.Tokens
 9{
 10    public class UserNameSecurityToken : SecurityToken
 11    {
 12        private readonly string _id;
 13        private readonly DateTime _effectiveTime;
 14        public UserNameSecurityToken(string userName, string password)
 215            : this(userName, password, SecurityUniqueId.Create().Value)
 16        {
 217        }
 18
 2019        public UserNameSecurityToken(string userName, string password, string id)
 20        {
 2021            if (userName == null)
 22            {
 023                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(userName));
 24            }
 25
 2026            if (userName == string.Empty)
 27            {
 028                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.UserNameCannotBeEmpty);
 29            }
 30
 2031            UserName = userName;
 2032            Password = password;
 2033            _id = id;
 2034            _effectiveTime = DateTime.UtcNow;
 2035        }
 36
 1337        public override string Id => _id;
 38
 039        public override ReadOnlyCollection<SecurityKey> SecurityKeys => EmptyReadOnlyCollection<SecurityKey>.Instance;
 40
 041        public override DateTime ValidFrom => _effectiveTime;
 42
 043        public override DateTime ValidTo => SecurityUtils.MaxUtcDateTime;
 44
 1845        public string UserName { get; }
 46
 1847        public string Password { get; }
 48    }
 49}