< Summary

Information
Class: Renci.SshNet.Messages.Authentication.RequestMessage
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Authentication\RequestMessage.cs
Line coverage
87%
Covered lines: 28
Uncovered lines: 4
Coverable lines: 32
Total lines: 116
Line coverage: 87.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Username()100%1100%
get_ServiceName()100%1100%
get_MethodName()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
LoadData()100%10%
SaveData()100%1100%
Process(...)100%10%
ToString()100%1100%

File(s)

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

#LineLine coverage
 1using System;
 2using Renci.SshNet.Common;
 3
 4namespace Renci.SshNet.Messages.Authentication
 5{
 6    /// <summary>
 7    /// Represents SSH_MSG_USERAUTH_REQUEST message. Server as a base message for other user authentication requests.
 8    /// </summary>
 9    [Message("SSH_MSG_USERAUTH_REQUEST", AuthenticationMessageCode)]
 10    public abstract class RequestMessage : Message
 11    {
 12        /// <summary>
 13        /// Returns the authentication message code for <c>SSH_MSG_USERAUTH_REQUEST</c>.
 14        /// </summary>
 15        internal const int AuthenticationMessageCode = 50;
 16
 17        private readonly byte[] _serviceName;
 18        private readonly byte[] _userName;
 19        private readonly byte[] _methodNameBytes;
 20        private readonly string _methodName;
 21
 22        /// <summary>
 23        /// Gets authentication username as UTF-8 encoded byte array.
 24        /// </summary>
 25        public byte[] Username
 26        {
 1335927            get { return _userName; }
 28        }
 29
 30        /// <summary>
 31        /// Gets the name of the service as ASCII encoded byte array.
 32        /// </summary>
 33        /// <value>
 34        /// The name of the service.
 35        /// </value>
 36        public byte[] ServiceName
 37        {
 927938            get { return _serviceName; }
 39        }
 40
 41        /// <summary>
 42        /// Gets the name of the authentication method.
 43        /// </summary>
 44        /// <value>
 45        /// The name of the method.
 46        /// </value>
 47        public virtual string MethodName
 48        {
 1089949            get { return _methodName; }
 50        }
 51
 52        /// <summary>
 53        /// Gets the size of the message in bytes.
 54        /// </summary>
 55        /// <value>
 56        /// The size of the messages in bytes.
 57        /// </value>
 58        protected override int BufferCapacity
 59        {
 60            get
 309361            {
 309362                var capacity = base.BufferCapacity;
 309363                capacity += 4; // Username length
 309364                capacity += Username.Length; // Username
 309365                capacity += 4; // ServiceName length
 309366                capacity += ServiceName.Length; // ServiceName
 309367                capacity += 4; // MethodName length
 309368                capacity += _methodNameBytes.Length; // MethodName
 309369                return capacity;
 309370            }
 71        }
 72
 73        /// <summary>
 74        /// Initializes a new instance of the <see cref="RequestMessage"/> class.
 75        /// </summary>
 76        /// <param name="serviceName">Name of the service.</param>
 77        /// <param name="username">Authentication username.</param>
 78        /// <param name="methodName">The name of the authentication method.</param>
 456979        protected RequestMessage(ServiceName serviceName, string username, string methodName)
 456980        {
 456981            _serviceName = serviceName.ToArray();
 456982            _userName = Utf8.GetBytes(username);
 456983            _methodNameBytes = Ascii.GetBytes(methodName);
 456984            _methodName = methodName;
 456985        }
 86
 87        /// <summary>
 88        /// Called when type specific data need to be loaded.
 89        /// </summary>
 90        protected override void LoadData()
 091        {
 092            throw new InvalidOperationException("Load data is not supported.");
 93        }
 94
 95        /// <summary>
 96        /// Called when type specific data need to be saved.
 97        /// </summary>
 98        protected override void SaveData()
 309399        {
 3093100            WriteBinaryString(_userName);
 3093101            WriteBinaryString(_serviceName);
 3093102            WriteBinaryString(_methodNameBytes);
 3093103        }
 104
 105        internal override void Process(Session session)
 0106        {
 0107            throw new NotImplementedException();
 108        }
 109
 110        /// <inheritdoc/>
 111        public override string ToString()
 3093112        {
 3093113            return $"SSH_MSG_USERAUTH_REQUEST ({MethodName})";
 3093114        }
 115    }
 116}