mirror of
https://github.com/Devolutions/IronRDP.git
synced 2026-11-23 16:35:52 +00:00
Moves relevant Close tests from ironrdp-pdu to ironrdp-dvc.
This commit is contained in:
@@ -507,7 +507,7 @@ impl From<CreationStatus> for u32 {
|
||||
/// 2.2.4 Closing a DVC (DYNVC_CLOSE)
|
||||
///
|
||||
/// [2.2.4]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpedyc/c02dfd21-ccbc-4254-985b-3ef6dd115dec
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ClosePdu {
|
||||
header: Header,
|
||||
pub channel_id: DynamicChannelId,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use super::*;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod create;
|
||||
mod close;
|
||||
#[cfg(test)]
|
||||
pub mod data;
|
||||
mod create;
|
||||
#[cfg(test)]
|
||||
pub mod data_first;
|
||||
mod data;
|
||||
#[cfg(test)]
|
||||
mod data_first;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
use crate::vec;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use super::*;
|
||||
|
||||
const CHANNEL_ID: u32 = 0x0303;
|
||||
const ENCODED: [u8; 3] = [0x41, 0x03, 0x03];
|
||||
|
||||
lazy_static! {
|
||||
static ref DECODED: ClosePdu = {
|
||||
let mut pdu = ClosePdu::new(CHANNEL_ID);
|
||||
pdu.header.cb_id = FieldType::U16;
|
||||
pdu
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_close() {
|
||||
let mut src = ReadCursor::new(&ENCODED);
|
||||
match DrdynvcClientPdu::decode(&mut src).unwrap() {
|
||||
DrdynvcClientPdu::Close(pdu) => assert_eq!(*DECODED, pdu),
|
||||
_ => panic!("Expected DataFirst"),
|
||||
}
|
||||
|
||||
let mut src = ReadCursor::new(&ENCODED);
|
||||
match DrdynvcServerPdu::decode(&mut src).unwrap() {
|
||||
DrdynvcServerPdu::Close(pdu) => assert_eq!(*DECODED, pdu),
|
||||
_ => panic!("Expected DataFirst"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encodes_close() {
|
||||
let data = &*DECODED;
|
||||
let mut buffer = vec![0x00; data.size()];
|
||||
let mut cursor = WriteCursor::new(&mut buffer);
|
||||
data.encode(&mut cursor).unwrap();
|
||||
assert_eq!(ENCODED.as_slice(), buffer.as_slice());
|
||||
}
|
||||
@@ -16,7 +16,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_data_pdu() {
|
||||
fn decodes_data() {
|
||||
let mut src = ReadCursor::new(&ENCODED);
|
||||
match DrdynvcClientPdu::decode(&mut src).unwrap() {
|
||||
DrdynvcClientPdu::Data(DrdynvcDataPdu::Data(d)) => assert_eq!(*DECODED, d),
|
||||
@@ -31,7 +31,7 @@ fn decodes_data_pdu() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encodes_data_pdu() {
|
||||
fn encodes_data() {
|
||||
let data = &*DECODED;
|
||||
let mut buffer = vec![0x00; data.size()];
|
||||
let mut cursor = WriteCursor::new(&mut buffer);
|
||||
|
||||
@@ -127,7 +127,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decodes_data_first_pdu() {
|
||||
fn decodes_data_first() {
|
||||
let mut src = ReadCursor::new(&ENCODED);
|
||||
match DrdynvcClientPdu::decode(&mut src).unwrap() {
|
||||
DrdynvcClientPdu::Data(DrdynvcDataPdu::DataFirst(df)) => assert_eq!(*DECODED, df),
|
||||
@@ -142,7 +142,7 @@ fn decodes_data_first_pdu() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encodes_data_first_pdu() {
|
||||
fn encodes_data_first() {
|
||||
let data_first = &*DECODED;
|
||||
let mut buffer = vec![0x00; data_first.size()];
|
||||
let mut cursor = WriteCursor::new(&mut buffer);
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use std::io;
|
||||
|
||||
use super::{FieldType, Header, PduType, HEADER_SIZE, UNUSED_U8};
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use super::*;
|
||||
|
||||
const DVC_TEST_CHANNEL_ID_U16: u32 = 0x0303;
|
||||
|
||||
const DVC_CLOSE_BUFFER_SIZE: usize = 3;
|
||||
const DVC_CLOSE_BUFFER: [u8; DVC_CLOSE_BUFFER_SIZE] = [0x41, 0x03, 0x03];
|
||||
|
||||
lazy_static! {
|
||||
static ref DVC_CLOSE: ClosePdu = ClosePdu {
|
||||
channel_id_type: FieldType::U16,
|
||||
channel_id: DVC_TEST_CHANNEL_ID_U16
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_buffer_correct_parses_dvc_close_pdu() {
|
||||
assert_eq!(
|
||||
DVC_CLOSE.clone(),
|
||||
ClosePdu::from_buffer(&DVC_CLOSE_BUFFER[1..], FieldType::U16).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_buffer_correct_serializes_dvc_close_pdu() {
|
||||
let close = DVC_CLOSE.clone();
|
||||
|
||||
let mut buffer = Vec::new();
|
||||
close.to_buffer(&mut buffer).unwrap();
|
||||
|
||||
assert_eq!(DVC_CLOSE_BUFFER.as_ref(), buffer.as_slice());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn buffer_length_is_correct_for_dvc_close_pdu() {
|
||||
let close = DVC_CLOSE.clone();
|
||||
let expected_buf_len = DVC_CLOSE_BUFFER.len();
|
||||
|
||||
let len = close.buffer_length();
|
||||
|
||||
assert_eq!(expected_buf_len, len);
|
||||
}
|
||||
Reference in New Issue
Block a user