Test for rejecting CREATED cells

This commit is contained in:
Nick Mathewson 2020-10-26 08:33:30 -04:00
parent 494c4679b5
commit 46c991a087
1 changed files with 16 additions and 1 deletions

View File

@ -232,7 +232,10 @@ where
// In theory this is allowed in clients, but we should never get
// one, since we don't use TAP.
Created(_) => Err(Error::ChanProto(format!("{} cell received", msg.cmd()))),
Created(_) => Err(Error::ChanProto(format!(
"{} cell received, but we never send CREATEs",
msg.cmd()
))),
// These aren't allowed after handshaking is done.
Versions(_) | Certs(_) | Authorize(_) | Authenticate(_) | AuthChallenge(_)
@ -585,5 +588,17 @@ mod test {
format!("{}", e),
"channel protocol violation: VERSIONS cell after handshake is done"
);
// We don't accept CREATED.
let created_cell = msg::Created::new(&b"xyzzy"[..]).into();
input
.send(Ok(ChanCell::new(25.into(), created_cell)))
.await
.unwrap();
let e = reactor.run_once().await.unwrap_err().unwrap_err();
assert_eq!(
format!("{}", e),
"channel protocol violation: CREATED cell received, but we never send CREATEs"
);
}
}