aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 16:45:47 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 16:45:47 +0200
commitc888787d45131de04ae01f3a1ba547885345ba1c (patch)
treee904151378e9536a3c004b8f784fe12b5ed0e18b /src
parentbe956d18c309d5dbd36063956045bade95c6e919 (diff)
add CHAP Failure (de)serialization tests
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6031d40..260b100 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1220,4 +1220,50 @@ mod tests {
);
Ok(())
}
+
+ #[test]
+ fn test_serialize_chap_failure() -> Result<()> {
+ let failure = PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ 1,
+ PppPkt::new_chap(ChapPkt::new_failure(0x41, "foo".into())),
+ );
+
+ let mut buf = Vec::new();
+ failure.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, 0x04, 0x41, 0x00, 0x07, 0x66, 0x6f,
+ 0x6f
+ ]
+ );
+ Ok(())
+ }
+
+ #[test]
+ fn test_deserialize_chap_failure() -> Result<()> {
+ let mut failure = 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, 0x04, 0x41, 0x00, 0x07, 0x66, 0x6f,
+ 0x6f,
+ ];
+ failure.deserialize(&mut buf.as_ref())?;
+
+ assert_eq!(
+ failure,
+ PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ 1,
+ PppPkt::new_chap(ChapPkt::new_failure(0x41, "foo".into()))
+ )
+ );
+ Ok(())
+ }
}