public void GetReply_StatVfsReplyInfo() { var bsize = (ulong)_random.Next(0, int.MaxValue); var frsize = (ulong)_random.Next(0, int.MaxValue); var blocks = (ulong)_random.Next(0, int.MaxValue); var bfree = (ulong)_random.Next(0, int.MaxValue); var bavail = (ulong)_random.Next(0, int.MaxValue); var files = (ulong)_random.Next(0, int.MaxValue); var ffree = (ulong)_random.Next(0, int.MaxValue); var favail = (ulong)_random.Next(0, int.MaxValue); var sid = (ulong)_random.Next(0, int.MaxValue); var namemax = (ulong)_random.Next(0, int.MaxValue); var sshDataStream = new SshDataStream(4 + 1 + 4 + 88); sshDataStream.Position = 4; // skip 4 bytes for SSH packet length sshDataStream.WriteByte((byte)SftpMessageTypes.Attrs); sshDataStream.Write(_responseId); sshDataStream.Write(bsize); sshDataStream.Write(frsize); sshDataStream.Write(blocks); sshDataStream.Write(bfree); sshDataStream.Write(bavail); sshDataStream.Write(files); sshDataStream.Write(ffree); sshDataStream.Write(favail); sshDataStream.Write(sid); sshDataStream.Write((ulong)0x2); sshDataStream.Write(namemax); var sshData = sshDataStream.ToArray(); var target = new SftpExtendedReplyResponse(_protocolVersion); target.Load(sshData, 5, sshData.Length - 5); var reply = target.GetReply <StatVfsReplyInfo>(); Assert.IsNotNull(reply); var information = reply.Information; Assert.IsNotNull(information); Assert.AreEqual(bavail, information.AvailableBlocks); Assert.AreEqual(favail, information.AvailableNodes); Assert.AreEqual(frsize, information.BlockSize); Assert.AreEqual(bsize, information.FileSystemBlockSize); Assert.AreEqual(bfree, information.FreeBlocks); Assert.AreEqual(ffree, information.FreeNodes); Assert.IsFalse(information.IsReadOnly); Assert.AreEqual(namemax, information.MaxNameLenght); Assert.AreEqual(sid, information.Sid); Assert.IsFalse(information.SupportsSetUid); Assert.AreEqual(blocks, information.TotalBlocks); Assert.AreEqual(files, information.TotalNodes); }
public void Load() { var target = new SftpExtendedReplyResponse(_protocolVersion); var sshDataStream = new SshDataStream(4); sshDataStream.Write(_responseId); target.Load(sshDataStream.ToArray()); Assert.AreEqual(_protocolVersion, target.ProtocolVersion); Assert.AreEqual(_responseId, target.ResponseId); Assert.AreEqual(SftpMessageTypes.ExtendedReply, target.SftpMessageType); }
private static SftpMessage Load(uint protocolVersion, byte[] data, SftpMessageTypes messageType, Encoding encoding) { SftpMessage message; switch (messageType) { case SftpMessageTypes.Version: message = new SftpVersionResponse(); break; case SftpMessageTypes.Status: message = new SftpStatusResponse(protocolVersion); break; case SftpMessageTypes.Data: message = new SftpDataResponse(protocolVersion); break; case SftpMessageTypes.Handle: message = new SftpHandleResponse(protocolVersion); break; case SftpMessageTypes.Name: message = new SftpNameResponse(protocolVersion, encoding); break; case SftpMessageTypes.Attrs: message = new SftpAttrsResponse(protocolVersion); break; case SftpMessageTypes.ExtendedReply: message = new SftpExtendedReplyResponse(protocolVersion); break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", messageType)); } #if TUNING message.Load(data); #else message.LoadBytes(data); message.ResetReader(); message.LoadData(); #endif return(message); }
public void Load() { var target = new SftpExtendedReplyResponse(_protocolVersion); var sshDataStream = new SshDataStream(4 + 1 + 4); sshDataStream.Position = 4; // skip 4 bytes for SSH packet length sshDataStream.WriteByte((byte)SftpMessageTypes.ExtendedReply); sshDataStream.Write(_responseId); target.Load(sshDataStream.ToArray()); Assert.AreEqual(_protocolVersion, target.ProtocolVersion); Assert.AreEqual(_responseId, target.ResponseId); Assert.AreEqual(SftpMessageTypes.ExtendedReply, target.SftpMessageType); }
public void Load() { var sshDataStream = new SshDataStream(4 + 1 + 4 + 88); sshDataStream.Write(_responseId); sshDataStream.Write(_bsize); sshDataStream.Write(_frsize); sshDataStream.Write(_blocks); sshDataStream.Write(_bfree); sshDataStream.Write(_bavail); sshDataStream.Write(_files); sshDataStream.Write(_ffree); sshDataStream.Write(_favail); sshDataStream.Write(_sid); sshDataStream.Write((ulong)0x1); sshDataStream.Write(_namemax); var extendedReplyResponse = new SftpExtendedReplyResponse(SftpSession.MaximumSupportedVersion); extendedReplyResponse.Load(sshDataStream.ToArray()); Assert.AreEqual(_responseId, extendedReplyResponse.ResponseId); var target = extendedReplyResponse.GetReply <StatVfsReplyInfo>(); Assert.IsNotNull(target.Information); var information = target.Information; Assert.AreEqual(_bavail, information.AvailableBlocks); Assert.AreEqual(_favail, information.AvailableNodes); Assert.AreEqual(_frsize, information.BlockSize); Assert.AreEqual(_bsize, information.FileSystemBlockSize); Assert.AreEqual(_bfree, information.FreeBlocks); Assert.AreEqual(_ffree, information.FreeNodes); Assert.IsTrue(information.IsReadOnly); Assert.AreEqual(_namemax, information.MaxNameLenght); Assert.AreEqual(_sid, information.Sid); Assert.IsTrue(information.SupportsSetUid); Assert.AreEqual(_blocks, information.TotalBlocks); Assert.AreEqual(_files, information.TotalNodes); }