< Summary

Information
Class: Renci.SshNet.Messages.Authentication.RequestMessagePassword
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Authentication\RequestMessagePassword.cs
Line coverage
64%
Covered lines: 20
Uncovered lines: 11
Coverable lines: 31
Total lines: 83
Line coverage: 64.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 Line coverage
get_Password()100%1100%
get_NewPassword()100%1100%
get_BufferCapacity()50%266.66%
.ctor(...)100%1100%
.ctor(...)100%10%
SaveData()50%266.66%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Authentication\RequestMessagePassword.cs

#LineLine coverage
 1namespace Renci.SshNet.Messages.Authentication
 2{
 3    /// <summary>
 4    /// Represents "password" SSH_MSG_USERAUTH_REQUEST message.
 5    /// </summary>
 6    internal sealed class RequestMessagePassword : RequestMessage
 7    {
 8        /// <summary>
 9        /// Gets authentication password.
 10        /// </summary>
 253411        public byte[] Password { get; private set; }
 12
 13        /// <summary>
 14        /// Gets new authentication password.
 15        /// </summary>
 158416        public byte[] NewPassword { get; private set; }
 17
 18        /// <summary>
 19        /// Gets the size of the message in bytes.
 20        /// </summary>
 21        /// <value>
 22        /// The size of the messages in bytes.
 23        /// </value>
 24        protected override int BufferCapacity
 25        {
 26            get
 52827            {
 52828                var capacity = base.BufferCapacity;
 52829                capacity += 1; // NewPassword flag
 52830                capacity += 4; // Password length
 52831                capacity += Password.Length; // Password
 32
 52833                if (NewPassword != null)
 034                {
 035                    capacity += 4; // NewPassword length
 036                    capacity += NewPassword.Length; // NewPassword
 037                }
 38
 52839                return capacity;
 52840            }
 41        }
 42
 43        /// <summary>
 44        /// Initializes a new instance of the <see cref="RequestMessagePassword"/> class.
 45        /// </summary>
 46        /// <param name="serviceName">Name of the service.</param>
 47        /// <param name="username">Authentication username.</param>
 48        /// <param name="password">Authentication password.</param>
 49        public RequestMessagePassword(ServiceName serviceName, string username, byte[] password)
 147850            : base(serviceName, username, "password")
 147851        {
 147852            Password = password;
 147853        }
 54
 55        /// <summary>
 56        /// Initializes a new instance of the <see cref="RequestMessagePassword"/> class.
 57        /// </summary>
 58        /// <param name="serviceName">Name of the service.</param>
 59        /// <param name="username">Authentication username.</param>
 60        /// <param name="password">Authentication password.</param>
 61        /// <param name="newPassword">New authentication password.</param>
 62        public RequestMessagePassword(ServiceName serviceName, string username, byte[] password, byte[] newPassword)
 063            : this(serviceName, username, password)
 064        {
 065            NewPassword = newPassword;
 066        }
 67
 68        /// <summary>
 69        /// Called when type specific data need to be saved.
 70        /// </summary>
 71        protected override void SaveData()
 52872        {
 52873            base.SaveData();
 74
 52875            Write(NewPassword != null);
 52876            WriteBinaryString(Password);
 52877            if (NewPassword != null)
 078            {
 079                WriteBinaryString(NewPassword);
 080            }
 52881        }
 82    }
 83}