public void Complete_SftpStatusResponse() { var statusActionInvocations = new List<SftpStatusResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new SftpRmDirRequest(_protocolVersion, _requestId, _path, _encoding, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); }
public void Complete_SftpStatusResponse() { var statusActionInvocations = new List<SftpStatusResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new SftpUnblockRequest(_protocolVersion, _requestId, _handle, _offset, _length, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); }
public void Complete_SftpStatusResponse() { IList<SftpStatusResponse> statusActionInvocations = new List<SftpStatusResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); }
public void Complete_SftpStatusResponse() { IList<SftpStatusResponse> statusActionInvocations = new List<SftpStatusResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new HardLinkRequest(_protocolVersion, _requestId, _oldPath, _newPath, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); }
public void Complete_SftpStatusResponse() { var statusActionInvocations = new List<SftpStatusResponse>(); var nameActionInvocations = new List<SftpNameResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; Action<SftpNameResponse> nameAction = nameActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new SftpReadDirRequest(_protocolVersion, _requestId, _handle, nameAction, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); Assert.AreEqual(0, nameActionInvocations.Count); }
public void Complete_SftpStatusResponse() { IList<SftpStatusResponse> statusActionInvocations = new List<SftpStatusResponse>(); IList<SftpExtendedReplyResponse> extendedReplyActionInvocations = new List<SftpExtendedReplyResponse>(); Action<SftpExtendedReplyResponse> extendedAction = extendedReplyActionInvocations.Add; Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new StatVfsRequest(_protocolVersion, _requestId, _path, _encoding, extendedAction, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); Assert.AreEqual(0, extendedReplyActionInvocations.Count); }
private SshException GetSftpException(SftpStatusResponse response) { if (response.StatusCode == StatusCodes.Ok) { return null; } if (response.StatusCode == StatusCodes.PermissionDenied) { return new SftpPermissionDeniedException(response.ErrorMessage); } else if (response.StatusCode == StatusCodes.NoSuchFile) { return new SftpPathNotFoundException(response.ErrorMessage); } else { return new SshException(response.ErrorMessage); } }
private void ThrowSftpException(SftpStatusResponse response) { if (response.StatusCode == StatusCodes.PermissionDenied) { throw new SftpPermissionDeniedException(response.ErrorMessage); } else if (response.StatusCode == StatusCodes.NoSuchFile) { throw new SftpPathNotFoundException(response.ErrorMessage); } else { throw new SshException(response.ErrorMessage); } }
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)); } message.LoadBytes(data); message.ResetReader(); message.LoadData(); return message; }
private static SshException GetSftpException(SftpStatusResponse response) { switch (response.StatusCode) { case StatusCodes.Ok: return null; case StatusCodes.PermissionDenied: return new SftpPermissionDeniedException(response.ErrorMessage); case StatusCodes.NoSuchFile: return new SftpPathNotFoundException(response.ErrorMessage); default: return new SshException(response.ErrorMessage); } }
public void Complete_SftpStatusResponse() { var statusActionInvocations = new List<SftpStatusResponse>(); var handleActionInvocations = new List<SftpHandleResponse>(); Action<SftpStatusResponse> statusAction = statusActionInvocations.Add; Action<SftpHandleResponse> handleAction = handleActionInvocations.Add; var statusResponse = new SftpStatusResponse(_protocolVersion); var request = new SftpOpenRequest( _protocolVersion, _requestId, _filename, _encoding, _flags, handleAction, statusAction); request.Complete(statusResponse); Assert.AreEqual(1, statusActionInvocations.Count); Assert.AreSame(statusResponse, statusActionInvocations[0]); Assert.AreEqual(0, handleActionInvocations.Count); }