summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-01-04 11:28:09 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-01-04 11:44:59 +0100
commitdddde418462580b91cc9a8c3074a74e231b47da4 (patch)
treea5e44f9d298cc4145a0c8421fbd99d6ea2d281b9
parent923f8220c37714d7f18ecae778d78449adfc7eb7 (diff)
Add check: PUBLISH gets PUBACK with same id
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--mqtt-tester/src/client_report.rs56
1 files changed, 55 insertions, 1 deletions
diff --git a/mqtt-tester/src/client_report.rs b/mqtt-tester/src/client_report.rs
index cd78027..9967c9b 100644
--- a/mqtt-tester/src/client_report.rs
+++ b/mqtt-tester/src/client_report.rs
@@ -13,7 +13,7 @@ use mqtt_format::v3::connect_return::MConnectReturnCode;
use mqtt_format::v3::header::MPacketKind;
use mqtt_format::v3::identifier::MPacketIdentifier;
-use mqtt_format::v3::packet::{MConnack, MConnect, MPacket, MPublish, MSubscribe};
+use mqtt_format::v3::packet::{MConnack, MConnect, MPacket, MPuback, MPublish, MSubscribe};
use mqtt_format::v3::qos::MQualityOfService;
use mqtt_format::v3::strings::MString;
@@ -46,6 +46,7 @@ pub async fn create_client_report(
check_utf8_with_nullchar_is_rejected(&client_exe_path).boxed_local(),
check_connack_flags_are_set_as_reserved(&client_exe_path).boxed_local(),
check_publish_qos_zero_with_ident_fails(&client_exe_path).boxed_local(),
+ check_publish_qos_2_is_acked(&client_exe_path).boxed_local(),
];
futures::stream::iter(reports)
@@ -356,3 +357,56 @@ async fn check_publish_qos_zero_with_ident_fails(client_exe_path: &Path) -> miet
output
})
}
+
+async fn check_publish_qos_2_is_acked(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(
+ crate::util::packet_to_vec(MPacket::Connack({
+ MConnack {
+ session_present: false,
+ connect_return_code: MConnectReturnCode::Accepted,
+ }
+ }))
+ .await?,
+ ),
+ crate::command::ClientCommand::Send(
+ crate::util::packet_to_vec(MPacket::Publish({
+ MPublish {
+ dup: false,
+ qos: MQualityOfService::AtLeastOnce, // QoS 2
+ retain: false,
+ topic_name: MString { value: "a" },
+ id: Some(MPacketIdentifier(1)),
+ payload: &[0x00],
+ }
+ }))
+ .await?,
+ ),
+ crate::command::ClientCommand::WaitFor({
+ crate::util::packet_to_vec(MPacket::Puback({
+ MPuback {
+ id: MPacketIdentifier(1),
+ }
+ }))
+ .await?
+ }),
+ ]);
+
+ let (result, output) = wait_for_output! {
+ output,
+ timeout_ms: 100,
+ out_success => { ReportResult::Success },
+ out_failure => { ReportResult::Failure }
+ };
+
+ Ok(mk_report! {
+ name: "A PUBLISH packet is replied to with Puback with the same id",
+ desc: "A PUBACK, PUBREC or PUBREL Packet MUST contain the same Packet Identifier as the PUBLISH Packet that was originally sent.",
+ normative: "[MQTT-2.3.1-6]",
+ result,
+ output
+ })
+}