-
-
Notifications
You must be signed in to change notification settings - Fork 980
Expand file tree
/
Copy pathSftpClientTest.CreateDirectory.cs
More file actions
63 lines (53 loc) · 1.93 KB
/
SftpClientTest.CreateDirectory.cs
File metadata and controls
63 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Renci.SshNet.Common;
namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
{
/// <summary>
/// Implementation of the SSH File Transfer Protocol (SFTP) over SSH.
/// </summary>
public partial class SftpClientTest : IntegrationTestBase
{
[TestMethod]
[TestCategory("Sftp")]
public void Test_Sftp_CreateDirectory_In_Current_Location()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
sftp.Connect();
sftp.CreateDirectory("test-in-current");
sftp.Disconnect();
}
}
[TestMethod]
[TestCategory("Sftp")]
public void Test_Sftp_CreateDirectory_In_Forbidden_Directory()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
{
sftp.Connect();
Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.CreateDirectory("/sbin/test"));
}
}
[TestMethod]
[TestCategory("Sftp")]
public void Test_Sftp_CreateDirectory_Invalid_Path()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
sftp.Connect();
Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.CreateDirectory("/abcdefg/abcefg"));
}
}
[TestMethod]
[TestCategory("Sftp")]
public void Test_Sftp_CreateDirectory_Already_Exists()
{
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
{
sftp.Connect();
sftp.CreateDirectory("test");
Assert.ThrowsExactly<SshException>(() => sftp.CreateDirectory("test"));
}
}
}
}