Skip to content

Commit

Permalink
Merge pull request #104 from fermyon/mqtt
Browse files Browse the repository at this point in the history
Add mqtt conformance tests
  • Loading branch information
rylev authored Jul 2, 2024
2 parents f082845 + 275e757 commit 74f0ee9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions conformance-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn run_test(test: conformance_tests::Test) -> Result<(), anyhow::Error> {
conformance_tests::config::Precondition::KeyValueStore(_) => {}
conformance_tests::config::Precondition::Sqlite => {}
conformance_tests::config::Precondition::Redis => {}
conformance_tests::config::Precondition::Mqtt => {}
}
}
for invocation in test.config.invocations {
Expand Down
13 changes: 10 additions & 3 deletions crates/spin-test-virt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,15 @@ impl mqtt::GuestConnection for MqttConnection {
password: String,
keep_alive_interval_in_secs: u64,
) -> Result<mqtt::Connection, mqtt::Error> {
let _ = (address, username, password, keep_alive_interval_in_secs);
Err(mqtt::Error::Other("not yet implemented".to_string()))
let url_allowed = manifest::AppManifest::allows_url(&address, "mqtt")
.map_err(|_| mqtt::Error::InvalidAddress)?;
if !url_allowed {
return Err(mqtt::Error::ConnectionFailed(format!(
"address {address} is not permitted"
)));
}
let _ = (username, password, keep_alive_interval_in_secs);
Ok(mqtt::Connection::new(MqttConnection))
}

fn publish(
Expand All @@ -648,7 +655,7 @@ impl mqtt::GuestConnection for MqttConnection {
qos: mqtt::Qos,
) -> Result<(), mqtt::Error> {
let _ = (topic, payload, qos);
Err(mqtt::Error::Other("not yet implemented".to_string()))
Ok(())
}
}

Expand Down

0 comments on commit 74f0ee9

Please sign in to comment.