aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 16:43:50 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 16:43:50 +0200
commitbe956d18c309d5dbd36063956045bade95c6e919 (patch)
treee7ed7e0cff283ee3a80e6f5b01080539d45de51d
parent93552c217b63b3e6429abd360003abc3f76dc28b (diff)
add CHAP Success (de)serialization tests
-rw-r--r--src/lib.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 720f6a8..6031d40 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1174,4 +1174,50 @@ mod tests {
);
Ok(())
}
+
+ #[test]
+ fn test_serialize_chap_success() -> Result<()> {
+ let success = PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ 1,
+ PppPkt::new_chap(ChapPkt::new_success(0x41, "foo".into())),
+ );
+
+ let mut buf = Vec::new();
+ success.serialize(&mut buf)?;
+
+ assert_eq!(
+ &buf,
+ &[
+ 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x88, 0x64,
+ 0x11, 0x00, 0x00, 0x01, 0x00, 0x09, 0xc2, 0x23, 0x02, 0x41, 0x00, 0x07, 0x66, 0x6f,
+ 0x6f
+ ]
+ );
+ Ok(())
+ }
+
+ #[test]
+ fn test_deserialize_chap_success() -> Result<()> {
+ let mut success = PppoePkt::default();
+
+ let buf = [
+ 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x88, 0x64,
+ 0x11, 0x00, 0x00, 0x01, 0x00, 0x09, 0xc2, 0x23, 0x01, 0x41, 0x00, 0x07, 0x66, 0x6f,
+ 0x6f,
+ ];
+ success.deserialize(&mut buf.as_ref())?;
+
+ assert_eq!(
+ success,
+ PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ 1,
+ PppPkt::new_chap(ChapPkt::new_success(0x41, "foo".into()))
+ )
+ );
+ Ok(())
+ }
}