summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-01-04 10:54:47 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-01-04 11:09:59 +0100
commit0a827d9efd6aba0009fe1335afc045755df89d03 (patch)
treeac4aaa2228e0856d42e33923bb47a7561b8f47c5
parent60550a86661948ed36e1dfffd5f35c057f692fb9 (diff)
Add test whether CONNACK Flag bits are set as specified
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--mqtt-tester/src/client_report.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/mqtt-tester/src/client_report.rs b/mqtt-tester/src/client_report.rs
index 57cd8f1..817f599 100644
--- a/mqtt-tester/src/client_report.rs
+++ b/mqtt-tester/src/client_report.rs
@@ -44,6 +44,7 @@ pub async fn create_client_report(
check_receiving_server_packet(&client_exe_path).boxed_local(),
check_invalid_first_packet_is_rejected(&client_exe_path).boxed_local(),
check_utf8_with_nullchar_is_rejected(&client_exe_path).boxed_local(),
+ check_connack_flags_are_set_as_reserved(&client_exe_path).boxed_local(),
];
futures::stream::iter(reports)
@@ -267,3 +268,37 @@ async fn check_utf8_with_nullchar_is_rejected(client_exe_path: &Path) -> miette:
output,
})
}
+
+async fn check_connack_flags_are_set_as_reserved(client_exe_path: &Path) -> miette::Result<Report> {
+ let output = open_connection_with(client_exe_path)
+ .await
+ .map(crate::command::Command::new)?
+ .wait_for_write([crate::command::ClientCommand::Send(vec![
+ 0b0010_0000 | 0b0000_1000, // CONNACK + garbage
+ 0b0000_0010, // Remaining length
+ 0b0000_0000, // No session present
+ 0b0000_0000, // Connection accepted
+ ])]);
+
+ let (result, output) = match tokio::time::timeout(Duration::from_millis(100), output).await {
+ Ok(Ok(out)) => (
+ if out.status.success() {
+ ReportResult::Failure
+ } else {
+ ReportResult::Success
+ },
+ Some(out.stderr),
+ ),
+ Ok(Err(_)) | Err(_) => (ReportResult::Failure, None),
+ };
+
+ Ok(Report {
+ name: String::from("Flag-Bit is set to 1 where it should be 0"),
+ description: String::from(
+ "CONNACK flag bits are marked as Reserved and must be set accordingly to spec",
+ ),
+ normative_statement_number: String::from("[MQTT-2.2.2-1]"),
+ result,
+ output,
+ })
+}