diff --git a/crates/core/tedge_agent/Cargo.toml b/crates/core/tedge_agent/Cargo.toml index 5b8cf43e11..2ec8e11148 100644 --- a/crates/core/tedge_agent/Cargo.toml +++ b/crates/core/tedge_agent/Cargo.toml @@ -12,7 +12,7 @@ repository = { workspace = true } [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -axum = { workspace = true } +axum = { workspace = true, features = ["macros"] } axum-server = { workspace = true } axum_tls = { workspace = true } camino = { workspace = true } diff --git a/crates/core/tedge_agent/src/http_server/entity_store.rs b/crates/core/tedge_agent/src/http_server/entity_store.rs index 9f34cff828..aead06a19c 100644 --- a/crates/core/tedge_agent/src/http_server/entity_store.rs +++ b/crates/core/tedge_agent/src/http_server/entity_store.rs @@ -620,7 +620,7 @@ mod tests { let response = app.call(req).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); - let body = hyper::body::to_bytes(response.into_body()).await.unwrap(); + let body = response.into_body().collect().await.unwrap().to_bytes(); let entities: Vec = serde_json::from_slice(&body).unwrap(); let entity_set = entities diff --git a/crates/core/tedge_api/src/entity_store.rs b/crates/core/tedge_api/src/entity_store.rs index 71ffd50574..d91335328b 100644 --- a/crates/core/tedge_api/src/entity_store.rs +++ b/crates/core/tedge_api/src/entity_store.rs @@ -710,20 +710,26 @@ impl EntityTree { let mut entities = vec![]; while let Some(topic_id) = topic_ids.pop_front() { - let metadata = self.entities.get(topic_id).map(|node| node.metadata()).unwrap(); + let metadata = self + .entities + .get(topic_id) + .map(|node| node.metadata()) + .unwrap(); if filters.matches(metadata) { entities.push(metadata); } - let (child_topics, _): (Vec<_>, Vec<_>) = self - .children(topic_id) - .into_iter() - .unzip(); + let (child_topics, _): (Vec<_>, Vec<_>) = + self.children(topic_id).into_iter().unzip(); // If the `parent` filter is used, no need to search beyond the direct children of that parent - if filters.parent.as_ref().map_or(true, |parent| parent == topic_id) { + if filters + .parent + .as_ref() + .map_or(true, |parent| parent == topic_id) + { topic_ids.extend(child_topics); - } + } } Ok(entities) } else { @@ -992,7 +998,8 @@ mod tests { use assert_matches::assert_matches; use mqtt_channel::Topic; use serde_json::json; - use std::{collections::BTreeSet, str::FromStr}; + use std::collections::BTreeSet; + use std::str::FromStr; use tempfile::TempDir; use test_case::test_case; @@ -1102,7 +1109,7 @@ mod tests { } #[test_case( - ListFilters::default(), + ListFilters::default(), BTreeSet::from([ "device/main//", "device/main/service/service0", @@ -1265,10 +1272,22 @@ mod tests { Some("device/child00//"), ), ("device/child1//", "child-device", None), - ("device/child1/service/service10", "service", Some("device/child1//")), + ( + "device/child1/service/service10", + "service", + Some("device/child1//"), + ), ("device/child2//", "child-device", None), - ("device/child2/service/service20", "service", Some("device/child2//")), - ("device/child2/service/service21", "service", Some("device/child2//")), + ( + "device/child2/service/service20", + "service", + Some("device/child2//"), + ), + ( + "device/child2/service/service21", + "service", + Some("device/child2//"), + ), ("device/child20//", "child-device", Some("device/child2//")), ("device/child21//", "child-device", Some("device/child2//")), ( diff --git a/tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py b/tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py index 2c4f17d9b9..e0fa15d810 100644 --- a/tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py +++ b/tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py @@ -1047,7 +1047,7 @@ def list_entities( query_string = "&".join(f"{key}={value}" for key, value in params.items()) url += f"?{query_string}" - output = device.execute_command(f"curl -f {url}") + output = device.execute_command(f"curl -f '{url}'") entities = json.loads(output.stdout) return entities