Skip to content

Commit be05730

Browse files
committed
More tests for public key authentication
1 parent d0bb866 commit be05730

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/Renci.SshNet.IntegrationTests/AuthenticationMethodFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ public PasswordAuthenticationMethod CreatePowerUserPasswordAuthenticationMethod(
88
return new PasswordAuthenticationMethod(user.UserName, user.Password);
99
}
1010

11-
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethod()
11+
public PrivateKeyAuthenticationMethod CreateRegularUserPrivateKeyAuthenticationMethod(string resourceName = "Data.Key.RSA.txt", string passPhrase = null)
1212
{
13-
var privateKeyFile = GetPrivateKey("Data.Key.RSA.txt");
13+
var privateKeyFile = GetPrivateKey(resourceName, passPhrase);
1414
return new PrivateKeyAuthenticationMethod(Users.Regular.UserName, privateKeyFile);
1515
}
1616

test/Renci.SshNet.IntegrationTests/AuthenticationTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ public void TearDown()
4444
}
4545

4646
[TestMethod]
47-
public void Multifactor_PublicKey()
47+
[DataRow("Data.Key.RSA.txt", null)]
48+
[DataRow("Data.Key.RSA.Encrypted.Aes.256.CBC.12345.txt", "12345")]
49+
[DataRow("Data.Key.OPENSSH.ECDSA.Encrypted.txt", "12345")]
50+
[DataRow("Data.Key.OPENSSH.ECDSA384.Encrypted.txt", "12345")]
51+
[DataRow("Data.Key.OPENSSH.ECDSA521.Encrypted.txt", "12345")]
52+
[DataRow("Data.Key.OPENSSH.ED25519.Encrypted.txt", "12345")]
53+
[DataRow("Data.Key.SSH2.DSA.Encrypted.Des.CBC.12345.txt", "12345")]
54+
public void Multifactor_PublicKey(string key, string passPhrase)
4855
{
4956
_remoteSshdConfig.WithAuthenticationMethods(Users.Regular.UserName, "publickey")
5057
.Update()
5158
.Restart();
5259

53-
var connectionInfo = _connectionInfoFactory.Create(_authenticationMethodFactory.CreateRegularUserPrivateKeyAuthenticationMethod());
60+
var connectionInfo = _connectionInfoFactory.Create(_authenticationMethodFactory.CreateRegularUserPrivateKeyAuthenticationMethod(key, passPhrase));
5461
using (var client = new SftpClient(connectionInfo))
5562
{
5663
client.Connect();

0 commit comments

Comments
 (0)