< Summary

Information
Class: Renci.SshNet.KeyboardInteractiveConnectionInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\KeyboardInteractiveConnectionInfo.cs
Line coverage
38%
Covered lines: 23
Uncovered lines: 37
Coverable lines: 60
Total lines: 191
Line coverage: 38.3%
Branch coverage
43%
Covered branches: 7
Total branches: 16
Branch coverage: 43.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%10%
.ctor(...)100%1100%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%4100%
AuthenticationMethod_AuthenticationPrompt(...)50%2100%
Dispose()100%10%
Dispose(...)20%1021.05%
Finalize()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\KeyboardInteractiveConnectionInfo.cs

#LineLine coverage
 1using System;
 2using Renci.SshNet.Common;
 3
 4namespace Renci.SshNet
 5{
 6    /// <summary>
 7    /// Provides connection information when keyboard interactive authentication method is used.
 8    /// </summary>
 9    /// <example>
 10    ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\KeyboardInteractiveConnectionInfoTest.cs" region="Example
 11    /// </example>
 12    public class KeyboardInteractiveConnectionInfo : ConnectionInfo, IDisposable
 13    {
 14        private bool _isDisposed;
 15
 16        /// <summary>
 17        /// Occurs when server prompts for more authentication information.
 18        /// </summary>
 19        /// <example>
 20        ///     <code source="..\..\src\Renci.SshNet.Tests\Classes\KeyboardInteractiveConnectionInfoTest.cs" region="Exa
 21        /// </example>
 22        public event EventHandler<AuthenticationPromptEventArgs> AuthenticationPrompt;
 23
 24        /// <summary>
 25        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 26        /// </summary>
 27        /// <param name="host">The host.</param>
 28        /// <param name="username">The username.</param>
 29        public KeyboardInteractiveConnectionInfo(string host, string username)
 030            : this(host, DefaultPort, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty)
 031        {
 032        }
 33
 34        /// <summary>
 35        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 36        /// </summary>
 37        /// <param name="host">The host.</param>
 38        /// <param name="port">The port.</param>
 39        /// <param name="username">The username.</param>
 40        public KeyboardInteractiveConnectionInfo(string host, int port, string username)
 141            : this(host, port, username, ProxyTypes.None, string.Empty, 0, string.Empty, string.Empty)
 142        {
 143        }
 44
 45        /// <summary>
 46        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 47        /// </summary>
 48        /// <param name="host">Connection host.</param>
 49        /// <param name="port">Connection port.</param>
 50        /// <param name="username">Connection username.</param>
 51        /// <param name="proxyType">Type of the proxy.</param>
 52        /// <param name="proxyHost">The proxy host.</param>
 53        /// <param name="proxyPort">The proxy port.</param>
 54        public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string pr
 055            : this(host, port, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty)
 056        {
 057        }
 58
 59        /// <summary>
 60        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 61        /// </summary>
 62        /// <param name="host">Connection host.</param>
 63        /// <param name="port">Connection port.</param>
 64        /// <param name="username">Connection username.</param>
 65        /// <param name="proxyType">Type of the proxy.</param>
 66        /// <param name="proxyHost">The proxy host.</param>
 67        /// <param name="proxyPort">The proxy port.</param>
 68        /// <param name="proxyUsername">The proxy username.</param>
 69        public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string pr
 070            : this(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty)
 071        {
 072        }
 73
 74        /// <summary>
 75        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 76        /// </summary>
 77        /// <param name="host">Connection host.</param>
 78        /// <param name="username">Connection username.</param>
 79        /// <param name="proxyType">Type of the proxy.</param>
 80        /// <param name="proxyHost">The proxy host.</param>
 81        /// <param name="proxyPort">The proxy port.</param>
 82        public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, i
 083            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, string.Empty, string.Empty)
 084        {
 085        }
 86
 87        /// <summary>
 88        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 89        /// </summary>
 90        /// <param name="host">Connection host.</param>
 91        /// <param name="username">Connection username.</param>
 92        /// <param name="proxyType">Type of the proxy.</param>
 93        /// <param name="proxyHost">The proxy host.</param>
 94        /// <param name="proxyPort">The proxy port.</param>
 95        /// <param name="proxyUsername">The proxy username.</param>
 96        public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, i
 097            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, string.Empty)
 098        {
 099        }
 100
 101        /// <summary>
 102        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 103        /// </summary>
 104        /// <param name="host">Connection host.</param>
 105        /// <param name="username">Connection username.</param>
 106        /// <param name="proxyType">Type of the proxy.</param>
 107        /// <param name="proxyHost">The proxy host.</param>
 108        /// <param name="proxyPort">The proxy port.</param>
 109        /// <param name="proxyUsername">The proxy username.</param>
 110        /// <param name="proxyPassword">The proxy password.</param>
 111        public KeyboardInteractiveConnectionInfo(string host, string username, ProxyTypes proxyType, string proxyHost, i
 0112            : this(host, DefaultPort, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword)
 0113        {
 0114        }
 115
 116        /// <summary>
 117        /// Initializes a new instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 118        /// </summary>
 119        /// <param name="host">Connection host.</param>
 120        /// <param name="port">Connection port.</param>
 121        /// <param name="username">Connection username.</param>
 122        /// <param name="proxyType">Type of the proxy.</param>
 123        /// <param name="proxyHost">The proxy host.</param>
 124        /// <param name="proxyPort">The proxy port.</param>
 125        /// <param name="proxyUsername">The proxy username.</param>
 126        /// <param name="proxyPassword">The proxy password.</param>
 127        public KeyboardInteractiveConnectionInfo(string host, int port, string username, ProxyTypes proxyType, string pr
 1128            : base(host, port, username, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword, new KeyboardInte
 1129        {
 5130            foreach (var authenticationMethod in AuthenticationMethods)
 1131            {
 1132                if (authenticationMethod is KeyboardInteractiveAuthenticationMethod kbdInteractive)
 1133                {
 1134                    kbdInteractive.AuthenticationPrompt += AuthenticationMethod_AuthenticationPrompt;
 1135                }
 1136            }
 1137        }
 138
 139        private void AuthenticationMethod_AuthenticationPrompt(object sender, AuthenticationPromptEventArgs e)
 2140        {
 141#pragma warning disable MA0091 // Sender should be 'this' for instance events
 2142            AuthenticationPrompt?.Invoke(sender, e);
 143#pragma warning restore MA0091 // Sender should be 'this' for instance events
 2144        }
 145
 146        /// <summary>
 147        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 148        /// </summary>
 149        public void Dispose()
 0150        {
 0151            Dispose(disposing: true);
 0152            GC.SuppressFinalize(this);
 0153        }
 154
 155        /// <summary>
 156        /// Releases unmanaged and - optionally - managed resources.
 157        /// </summary>
 158        /// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langwor
 159        protected virtual void Dispose(bool disposing)
 1160        {
 1161            if (_isDisposed)
 0162            {
 0163                return;
 164            }
 165
 1166            if (disposing)
 0167            {
 0168                if (AuthenticationMethods != null)
 0169                {
 0170                    foreach (var authenticationMethods in AuthenticationMethods)
 0171                    {
 0172                        if (authenticationMethods is IDisposable disposable)
 0173                        {
 0174                            disposable.Dispose();
 0175                        }
 0176                    }
 0177                }
 178
 0179                _isDisposed = true;
 0180            }
 1181        }
 182
 183        /// <summary>
 184        /// Finalizes an instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
 185        /// </summary>
 186        ~KeyboardInteractiveConnectionInfo()
 2187        {
 1188            Dispose(disposing: false);
 2189        }
 190    }
 191}