46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System.IO;
|
|
using NUnit.Framework;
|
|
using Newtonsoft.Json;
|
|
using LCU.Api.Internal.FTPLib.Models.Enums;
|
|
using LCU.Api.Internal.FTPLib.Models;
|
|
using LCU.Api.Internal.FTP.Services.FtpOpertionServices;
|
|
namespace LCU.Api.Internal.FTP.IntegrationTests;
|
|
|
|
public class SshFtpServiceTest
|
|
{
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
// Local docker SFTP Server setup:
|
|
// docker run -p 22:22 -d emberstack/sftp --name sftp -v /host/demo:/c/dev/sftp
|
|
}
|
|
|
|
/// <summary>
|
|
/// This test shows that we can use the SSH.NET sftp to easily transfer via byte array with no filesystem dependency
|
|
/// </summary>
|
|
[Test]
|
|
[Ignore("Can only be run locally for now.")]
|
|
public void TestSshFileRequest()
|
|
{
|
|
var request = new SshFtpRequest()
|
|
{
|
|
HostName = "127.0.0.1",
|
|
PortNumber = 22,
|
|
Password = "demo",
|
|
UserName = "demo",
|
|
Protocol = ProtocolType.Sftp,
|
|
RemoteFilePath = "test_uploaded1.csv",
|
|
LocalFileData = File.ReadAllBytes("example.csv")
|
|
};
|
|
|
|
var queueRequest = new QueueRequest()
|
|
{
|
|
Request = JsonConvert.SerializeObject(request),
|
|
FtpType = FtpType.SshFtp
|
|
};
|
|
|
|
var service = new SshFtpService();
|
|
var result = service.ExecuteAction(queueRequest);
|
|
Assert.True(result.IsSuccessful);
|
|
}
|
|
} |