private void SetupData() { var random = new Random(); #region SftpSession.Connect() _operationTimeout = random.Next(100, 500); _protocolVersion = (uint)random.Next(0, 3); _encoding = Encoding.UTF8; _sftpResponseFactory = new SftpResponseFactory(); _sftpInitRequestBytes = new SftpInitRequestBuilder().WithVersion(SftpSession.MaximumSupportedVersion) .Build() .GetBytes(); _sftpVersionResponse = new SftpVersionResponseBuilder().WithVersion(_protocolVersion) .Build(); _sftpRealPathRequestBytes = new SftpRealPathRequestBuilder().WithProtocolVersion(_protocolVersion) .WithRequestId(1) .WithPath(".") .WithEncoding(_encoding) .Build() .GetBytes(); _sftpNameResponse = new SftpNameResponseBuilder().WithProtocolVersion(_protocolVersion) .WithResponseId(1) .WithEncoding(_encoding) .WithFile("XYZ", SftpFileAttributes.Empty) .Build(); #endregion SftpSession.Connect() _handle = CryptoAbstraction.GenerateRandom(random.Next(1, 10)); _offset = (uint)random.Next(1, 5); _length = (uint)random.Next(30, 50); _data = CryptoAbstraction.GenerateRandom((int)_length); _sftpReadRequestBytes = new SftpReadRequestBuilder().WithProtocolVersion(_protocolVersion) .WithRequestId(2) .WithHandle(_handle) .WithOffset(_offset) .WithLength(_length) .Build() .GetBytes(); _sftpDataResponseBytes = new SftpDataResponseBuilder().WithProtocolVersion(_protocolVersion) .WithResponseId(2) .WithData(_data) .Build() .GetBytes(); }
private void SetupData() { var random = new Random(); #region SftpSession.Connect() _operationTimeout = random.Next(100, 500); _encoding = Encoding.UTF8; _protocolVersion = 3; _sftpResponseFactory = new SftpResponseFactory(); _sftpInitRequestBytes = new SftpInitRequestBuilder().WithVersion(SftpSession.MaximumSupportedVersion) .Build() .GetBytes(); _sftpVersionResponse = new SftpVersionResponseBuilder().WithVersion(_protocolVersion) .WithExtension("*****@*****.**", "") .Build(); _sftpRealPathRequestBytes = new SftpRealPathRequestBuilder().WithProtocolVersion(_protocolVersion) .WithRequestId(1) .WithPath(".") .WithEncoding(_encoding) .Build() .GetBytes(); _sftpNameResponse = new SftpNameResponseBuilder().WithProtocolVersion(_protocolVersion) .WithResponseId(1U) .WithEncoding(_encoding) .WithFile("ABC", SftpFileAttributes.Empty) .Build(); #endregion SftpSession.Connect() _path = random.Next().ToString(); _bAvail = (ulong)random.Next(0, int.MaxValue); _sftpStatVfsRequestBytes = new SftpStatVfsRequestBuilder().WithProtocolVersion(_protocolVersion) .WithRequestId(2) .WithPath(_path) .WithEncoding(_encoding) .Build() .GetBytes(); _sftpStatVfsResponse = new SftpStatVfsResponseBuilder().WithProtocolVersion(_protocolVersion) .WithResponseId(2U) .WithBAvail(_bAvail) .Build(); }
/// <summary> /// Creates a new <see cref="ISftpSession"/> in a given <see cref="ISession"/> and with /// the specified operation timeout and encoding. /// </summary> /// <param name="session">The <see cref="ISession"/> to create the <see cref="ISftpSession"/> in.</param> /// <param name="operationTimeout">The number of milliseconds to wait for an operation to complete, or -1 to wait indefinitely.</param> /// <param name="encoding">The encoding.</param> /// <param name="sftpMessageFactory">The factory to use for creating SFTP messages.</param> /// <returns> /// An <see cref="ISftpSession"/>. /// </returns> public ISftpSession CreateSftpSession(ISession session, int operationTimeout, Encoding encoding, ISftpResponseFactory sftpMessageFactory) { return(new SftpSession(session, operationTimeout, encoding, sftpMessageFactory)); }