summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbin Suresh <albin.suresh@softwareag.com>2022-05-13 20:06:28 +0530
committerGitHub <noreply@github.com>2022-05-13 20:06:28 +0530
commitba49c8bdd3ca4e7ad5249a89ac90d2aad9479dfb (patch)
tree7a755ab5860099463803487c09183871444c6735
parent42859fa5a847179867f3dce2143cc533655bc2de (diff)
parent3a892093d38f9320800bdb635012c5b860c018b0 (diff)
Merge PR #1138 Issue #1030 c8y_configuration_plugin integration tests
Issue #1030 c8y_configuration_plugin integration tests
-rw-r--r--Cargo.lock222
-rw-r--r--crates/common/mqtt_channel/Cargo.toml2
-rw-r--r--crates/core/c8y_api/src/http_proxy.rs72
-rw-r--r--crates/core/c8y_smartrest/src/smartrest_deserializer.rs18
-rw-r--r--crates/core/plugin_sm/Cargo.toml2
-rw-r--r--crates/core/tedge_agent/Cargo.toml2
-rw-r--r--crates/core/tedge_mapper/Cargo.toml2
-rw-r--r--crates/core/tedge_mapper/src/c8y/tests.rs1
-rw-r--r--plugins/c8y_configuration_plugin/Cargo.toml5
-rw-r--r--plugins/c8y_configuration_plugin/src/download.rs6
-rw-r--r--plugins/c8y_configuration_plugin/src/main.rs106
-rw-r--r--plugins/c8y_configuration_plugin/src/upload.rs91
-rw-r--r--plugins/tedge_apt_plugin/Cargo.toml2
13 files changed, 369 insertions, 162 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 66dc64be..045cbbd1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -72,9 +72,9 @@ checksum = "be69f70ef5497dd6ab331a50bd95c6ac6b8f7f17a7967838332743fbd58dc3b5"
dependencies = [
"argh_shared",
"heck 0.3.3",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -105,9 +105,9 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
"synstructure",
]
@@ -117,9 +117,9 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -201,9 +201,9 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -212,9 +212,9 @@ version = "0.1.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -395,12 +395,16 @@ dependencies = [
"assert_matches",
"c8y_api",
"c8y_smartrest",
- "clap 3.1.15",
+ "clap 3.1.18",
"csv",
"download",
+ "mockall 0.11.0",
+ "mockito",
"mqtt_channel",
+ "mqtt_tests",
"serde",
"serde_json",
+ "serial_test",
"tedge_config",
"tedge_utils",
"tempfile",
@@ -516,9 +520,9 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.1.15"
+version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85a35a599b11c089a7f49105658d089b8f2cf0882993c17daf6de15285c2c35d"
+checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b"
dependencies = [
"atty",
"bitflags",
@@ -533,15 +537,15 @@ dependencies = [
[[package]]
name = "clap_derive"
-version = "3.1.7"
+version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
+checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
dependencies = [
"heck 0.4.0",
"proc-macro-error",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -730,7 +734,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c"
dependencies = [
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -817,9 +821,9 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -1051,9 +1055,9 @@ version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -1292,7 +1296,7 @@ dependencies = [
"hyper",
"rustls 0.20.4",
"tokio",
- "tokio-rustls 0.23.3",
+ "tokio-rustls 0.23.4",
]
[[package]]
@@ -1442,7 +1446,7 @@ dependencies = [
"assert_matches",
"async-trait",
"log",
- "serial_test 0.6.0",
+ "serial_test",
"tempfile",
"test-case",
"thiserror",
@@ -1513,25 +1517,14 @@ dependencies = [
[[package]]
name = "mio"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9"
+checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799"
dependencies = [
"libc",
"log",
- "miow",
- "ntapi",
"wasi 0.11.0+wasi-snapshot-preview1",
- "winapi",
-]
-
-[[package]]
-name = "miow"
-version = "0.3.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
-dependencies = [
- "winapi",
+ "windows-sys",
]
[[package]]
@@ -1571,9 +1564,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e25b214433f669161f414959594216d8e6ba83b6679d3db96899c0b4639033"
dependencies = [
"cfg-if 1.0.0",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -1583,9 +1576,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79ef208208a0dea3f72221e26e904cdc6db2e481d9ade89081ddd494f1dbaa6b"
dependencies = [
"cfg-if 1.0.0",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -1616,7 +1609,7 @@ dependencies = [
"futures",
"mqtt_tests",
"rumqttc",
- "serial_test 0.5.1",
+ "serial_test",
"thiserror",
"tokio",
]
@@ -1701,15 +1694,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
-name = "ntapi"
-version = "0.3.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f"
-dependencies = [
- "winapi",
-]
-
-[[package]]
name = "num"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1767,9 +1751,9 @@ dependencies = [
[[package]]
name = "num-iter"
-version = "0.1.42"
+version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
+checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
dependencies = [
"autocfg",
"num-integer",
@@ -1809,18 +1793,18 @@ dependencies = [
[[package]]
name = "num_threads"
-version = "0.1.5"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0"
+checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
"libc",
]
[[package]]
name = "object"
-version = "0.28.3"
+version = "0.28.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456"
+checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424"
dependencies = [
"memchr",
]
@@ -1945,9 +1929,9 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -2003,7 +1987,7 @@ dependencies = [
"logged_command",
"serde",
"serde_json",
- "serial_test 0.5.1",
+ "serial_test",
"tedge_utils",
"tempfile",
"test-case",
@@ -2071,9 +2055,9 @@ dependencies = [
[[package]]
name = "pretty_assertions"
-version = "1.2.0"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57c038cb5319b9c704bf9c227c261d275bfec0ad438118a2787ce47944fb228b"
+checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563"
dependencies = [
"ansi_term",
"ctor",
@@ -2098,9 +2082,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
"version_check",
]
@@ -2110,7 +2094,7 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
"version_check",
]
@@ -2126,9 +2110,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.37"
+version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
+checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
dependencies = [
"unicode-xid 0.2.3",
]
@@ -2180,7 +2164,7 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
]
[[package]]
@@ -2340,7 +2324,7 @@ dependencies = [
"serde_json",
"serde_urlencoded",
"tokio",
- "tokio-rustls 0.23.3",
+ "tokio-rustls 0.23.4",
"tokio-util 0.6.9",
"url",
"wasm-bindgen",
@@ -2627,16 +2611,16 @@ version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
name = "serde_json"
-version = "1.0.80"
+version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944"
+checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
dependencies = [
"itoa 1.0.1",
"ryu",
@@ -2657,35 +2641,13 @@ dependencies = [
[[package]]
name = "serial_test"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
-dependencies = [
- "lazy_static",
- "parking_lot 0.11.2",
- "serial_test_derive 0.5.1",
-]
-
-[[package]]
-name = "serial_test"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5bcc41d18f7a1d50525d080fd3e953be87c4f9f1a974f3c21798ca00d54ec15"
dependencies = [
"lazy_static",
"parking_lot 0.11.2",
- "serial_test_derive 0.6.0",
-]
-
-[[package]]
-name = "serial_test_derive"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
-dependencies = [
- "proc-macro2 1.0.37",
- "quote 1.0.18",
- "syn 1.0.92",
+ "serial_test_derive",
]
[[package]]
@@ -2695,10 +2657,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2881bccd7d60fb32dfa3d7b3136385312f8ad75e2674aab2852867a09790cae8"
dependencies = [
"proc-macro-error",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
"rustversion",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -2802,11 +2764,11 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.92"
+version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
+checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
"unicode-xid 0.2.3",
]
@@ -2817,9 +2779,9 @@ version = "0.12.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
"unicode-xid 0.2.3",
]
@@ -2832,7 +2794,7 @@ dependencies = [
"assert_matches",
"base64",
"certificate",
- "clap 3.1.15",
+ "clap 3.1.18",
"futures",
"hyper",
"mockito",
@@ -2865,7 +2827,7 @@ dependencies = [
"assert-json-diff",
"assert_cmd",
"async-trait",
- "clap 3.1.15",
+ "clap 3.1.18",
"flockfile",
"futures",
"mockall 0.10.2",
@@ -2876,7 +2838,7 @@ dependencies = [
"predicates 2.1.1",
"serde",
"serde_json",
- "serial_test 0.5.1",
+ "serial_test",
"tedge_config",
"tedge_users",
"tedge_utils",
@@ -2893,7 +2855,7 @@ dependencies = [
name = "tedge_apama_plugin"
version = "0.6.4"
dependencies = [
- "clap 3.1.15",
+ "clap 3.1.18",
"roxmltree",
"tempfile",
"thiserror",
@@ -2905,12 +2867,12 @@ name = "tedge_apt_plugin"
version = "0.6.4"
dependencies = [
"anyhow",
- "clap 3.1.15",
+ "clap 3.1.18",
"csv",
"hamcrest2",
"reqwest",
"serde",
- "serial_test 0.5.1",
+ "serial_test",
"tedge_utils",
"test-case",
"thiserror",
@@ -2935,7 +2897,7 @@ dependencies = [
name = "tedge_dummy_plugin"
version = "0.6.4"
dependencies = [
- "clap 3.1.15",
+ "clap 3.1.18",
"thiserror",
]
@@ -2975,7 +2937,7 @@ dependencies = [
"c8y_api",
"c8y_smartrest",
"c8y_translator",
- "clap 3.1.15",
+ "clap 3.1.18",
"clock",
"csv",
"download",
@@ -2990,7 +2952,7 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
- "serial_test 0.5.1",
+ "serial_test",
"tedge_config",
"tedge_users",
"tedge_utils",
@@ -3035,7 +2997,7 @@ name = "tedge_watchdog"
version = "0.6.4"
dependencies = [
"anyhow",
- "clap 3.1.15",
+ "clap 3.1.18",
"freedesktop_entry_parser",
"futures",
"mqtt_channel",
@@ -3086,9 +3048,9 @@ checksum = "6344589a99d3971d6fa4e8314dbcbeca2df6273a6b642e46906971779159af1f"
dependencies = [
"cfg-if 1.0.0",
"proc-macro-error",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -3141,9 +3103,9 @@ version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -3201,9 +3163,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
-version = "1.18.1"
+version = "1.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dce653fb475565de9f6fb0614b28bca8df2c430c0cf84bcd9c843f15de5414cc"
+checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395"
dependencies = [
"bytes",
"libc",
@@ -3225,9 +3187,9 @@ version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -3243,9 +3205,9 @@ dependencies = [
[[package]]
name = "tokio-rustls"
-version = "0.23.3"
+version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e"
+checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"rustls 0.20.4",
"tokio",
@@ -3351,9 +3313,9 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
]
[[package]]
@@ -3627,9 +3589,9 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
"wasm-bindgen-shared",
]
@@ -3661,9 +3623,9 @@ version = "0.2.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
dependencies = [
- "proc-macro2 1.0.37",
+ "proc-macro2 1.0.38",
"quote 1.0.18",
- "syn 1.0.92",
+ "syn 1.0.94",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
diff --git a/crates/common/mqtt_channel/Cargo.toml b/crates/common/mqtt_channel/Cargo.toml
index d310365c..cfa73363 100644
--- a/crates/common/mqtt_channel/Cargo.toml
+++ b/crates/common/mqtt_channel/Cargo.toml
@@ -18,4 +18,4 @@ tokio = { version = "1.12", features = ["rt", "time"] }
[dev-dependencies]
anyhow = "1.0"
mqtt_tests = { path = "../../tests/mqtt_tests" }
-serial_test = "0.5"
+serial_test = "0.6"
diff --git a/crates/core/c8y_api/src/http_proxy.rs b/crates/core/c8y_api/src/http_proxy.rs
index 098ce82f..5bd93f3a 100644
--- a/crates/core/c8y_api/src/http_proxy.rs
+++ b/crates/core/c8y_api/src/http_proxy.rs
@@ -47,7 +47,6 @@ pub trait C8YHttpProxy: Send + Sync {
async fn upload_config_file(
&mut self,
config_path: &Path,
- config_content: &str,
) -> Result<String, SMCumulocityMapperError>;
}
@@ -414,10 +413,12 @@ impl C8YHttpProxy for JwtAuthHttpProxy {
async fn upload_config_file(
&mut self,
config_path: &Path,
- config_content: &str,
) -> Result<String, SMCumulocityMapperError> {
let token = self.get_jwt_token().await?;
+ // read the config file contents
+ let config_content = std::fs::read_to_string(config_path)?;
+
let config_file_event = self.create_event(config_path.display().to_string(), None, None);
let event_response_id = self.send_event_internal(config_file_event).await?;
let binary_upload_event_url = self
@@ -441,10 +442,13 @@ impl C8YHttpProxy for JwtAuthHttpProxy {
#[cfg(test)]
mod tests {
+ use std::io::Write;
+
use super::*;
use anyhow::Result;
use mockito::{mock, Matcher};
use serde_json::json;
+ use tempfile::NamedTempFile;
use test_case::test_case;
#[test]
@@ -569,4 +573,68 @@ mod tests {
Ok(())
}
+
+ #[tokio::test]
+ async fn upload_config_file() -> anyhow::Result<()> {
+ let device_id = "test-device";
+ let event_id = "456";
+
+ // Mock endpoint to return C8Y internal id
+ let _get_internal_id_mock = mock("GET", "/identity/externalIds/c8y_Serial/test-device")
+ .with_status(200)
+ .with_body(
+ json!({ "externalId": device_id, "managedObject": { "id": "123" } }).to_string(),
+ )
+ .create();
+
+ let config_content = "key=value";
+ let config_file = create_test_config_file_with_content(config_content)?;
+
+ // Mock endpoint for config upload event creation
+ let _config_file_event_mock = mock("POST", "/event/events/")
+ .match_body(Matcher::PartialJson(
+ json!({ "type": config_file.path(), "text": config_file.path() }),
+ ))
+ .with_status(201)
+ .with_body(json!({ "id": event_id }).to_string())
+ .create();
+
+ let config_binary_url_path = format!("/event/events/{event_id}/binaries");
+
+ // Mock endpoint for config file binary upload
+ let _config_binary_upload_mock = mock("POST", config_binary_url_path.as_str())
+ .match_body(Matcher::Exact(config_content.to_string()))
+ .with_status(201)
+ .with_body("irrelevant response")
+ .create();
+
+ // An JwtAuthHttpProxy ...
+ let mut jwt_token_retriver = Box::new(MockC8yJwtTokenRetriever::new());
+ jwt_token_retriver
+ .expect_get_jwt_token()
+ .returning(|| Ok(SmartRestJwtResponse::default()));
+
+ let http_client = reqwest::ClientBuilder::new().build().unwrap();
+ let mut http_proxy = JwtAuthHttpProxy::new(
+ jwt_token_retriver,
+ http_client,
+ mockito::server_url().as_str(),
+ device_id,
+ );
+
+ // Upload the config file and assert its binary URL
+ assert_eq!(
+ http_proxy.upload_config_file(config_file.path()).await?,
+ mockito::server_url() + config_binary_url_path.as_str()
+ );
+
+ Ok(())
+ }
+
+ fn create_test_config_file_with_content(content: &str) -> Result<NamedTempFile, anyhow::Error> {
+ let mut file = NamedTempFile::new()?;
+ file.write_all(content.as_bytes())?;
+
+ Ok(file)
+ }
}
diff --git a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
index 5d28fac0..362c4521 100644
--- a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
+++ b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
@@ -611,6 +611,24 @@ mod tests {
}
#[test]
+ fn deserialize_smartrest_config_upload_request() {
+ let message_id = "526".to_string();
+ let device = "deviceId".to_string();
+ let config_type = "/test/config/path".to_string();
+
+ let smartrest_message = format!("{message_id},{device},{config_type}");
+ let expected = SmartRestConfigUploadRequest {
+ message_id,
+ device,
+ config_type,
+ };
+ assert_eq!(
+ SmartRestConfigUploadRequest::from_smartrest(smartrest_message.as_str()).unwrap(),
+ expected
+ );
+ }
+
+ #[test]
fn deserialize_smartrest_config_download_request_operation() {
let smartrest = "524,deviceId,https://test.cumulocity.com/inventory/binaries/70208,/etc/tedge/tedge.toml".to_string();
let request = SmartRestConfigDownloadRequest::from_smartrest(&smartrest).unwrap();
diff --git a/crates/core/plugin_sm/Cargo.toml b/crates/core/plugin_sm/Cargo.toml
index 6070c13b..f8393219 100644
--- a/crates/core/plugin_sm/Cargo.toml
+++ b/crates/core/plugin_sm/Cargo.toml
@@ -23,7 +23,7 @@ url = "2.2"
[dev-dependencies]
anyhow = "1.0"
assert_matches = "1.5"
-serial_test = "0.5.1"
+serial_test = "0.6"
tempfile = "3.2"
test-case = "2.0"
diff --git a/crates/core/tedge_agent/Cargo.toml b/crates/core/tedge_agent/Cargo.toml
index a10ab647..0e9a1a11 100644
--- a/crates/core/tedge_agent/Cargo.toml
+++ b/crates/core/tedge_agent/Cargo.toml
@@ -52,4 +52,4 @@ tedge_users = { path = "../../common/tedge_users"}
tedge_utils = { path = "../../common/tedge_utils"}
tempfile = "3.2"
tokio-test = "0.4"
-serial_test = "0.5"
+serial_test = "0.6"
diff --git a/crates/core/tedge_mapper/Cargo.toml b/crates/core/tedge_mapper/Cargo.toml
index af240f7b..b7561fb3 100644
--- a/crates/core/tedge_mapper/Cargo.toml
+++ b/crates/core/tedge_mapper/Cargo.toml
@@ -62,7 +62,7 @@ serde = "1.0"
mockito = "0.31"
mqtt_tests = { path = "../../tests/mqtt_tests" }
serde_json = "1.0"
-serial_test = "0.5"
+serial_test = "0.6"
tempfile = "3.2"
test-case = "2.0"
time = { version = "0.3", features = ["macros"] }
diff --git a/crates/core/tedge_mapper/src/c8y/tests.rs b/crates/core/tedge_mapper/src/c8y/tests.rs
index 2e8ccc0e..e0366934 100644
--- a/crates/core/tedge_mapper/src/c8y/tests.rs
+++ b/crates/core/tedge_mapper/src/c8y/tests.rs
@@ -911,7 +911,6 @@ impl C8YHttpProxy for FakeC8YHttpProxy {
async fn upload_config_file(
&mut self,
_config_path: &Path,
- _config_content: &str,
) -> Result<String, SMCumulocityMapperError> {
Ok("fake/upload/url".into())
}
diff --git a/plugins/c8y_configuration_plugin/Cargo.toml b/plugins/c8y_configuration_plugin/Cargo.toml
index 75f6d895..a36221fe 100644
--- a/plugins/c8y_configuration_plugin/Cargo.toml
+++ b/plugins/c8y_configuration_plugin/Cargo.toml
@@ -33,5 +33,10 @@ tracing = { version = "0.1", features = ["attributes", "log"] }
[dev-dependencies]
assert_matches = "1.5"
+mockall = "0.11"
+mockito = "0.31"
+mqtt_tests = { path = "../../crates/tests/mqtt_tests" }
+serial_test = "0.6"
tempfile = "3.3"
test-case = "2.0"
+toml = "0.5"
diff --git a/plugins/c8y_configuration_plugin/src/download.rs b/plugins/c8y_configuration_plugin/src/download.rs
index 766a9238..b293926c 100644
--- a/plugins/c8y_configuration_plugin/src/download.rs
+++ b/plugins/c8y_configuration_plugin/src/download.rs
@@ -1,7 +1,7 @@
use crate::error::ConfigManagementError;
use crate::smartrest::TryIntoOperationStatusMessage;
use crate::{error, PluginConfig};
-use c8y_api::http_proxy::{C8YHttpProxy, JwtAuthHttpProxy};
+use c8y_api::http_proxy::C8YHttpProxy;
use c8y_smartrest::error::SmartRestSerializerError;
use c8y_smartrest::smartrest_deserializer::SmartRestConfigDownloadRequest;
use c8y_smartrest::smartrest_serializer::{
@@ -24,7 +24,7 @@ pub async fn handle_config_download_request(
smartrest_request: SmartRestConfigDownloadRequest,
tmp_dir: PathBuf,
mqtt_client: &mut Connection,
- http_client: &mut JwtAuthHttpProxy,
+ http_client: &mut impl C8YHttpProxy,
) -> Result<(), anyhow::Error> {
let executing_message = DownloadConfigFileStatusMessage::executing()?;
let () = mqtt_client.published.send(executing_message).await?;
@@ -53,7 +53,7 @@ async fn download_config_file(
plugin_config: &PluginConfig,
smartrest_request: SmartRestConfigDownloadRequest,
tmp_dir: PathBuf,
- http_client: &mut JwtAuthHttpProxy,
+ http_client: &mut impl C8YHttpProxy,
) -> Result<(), anyhow::Error> {
// Convert smartrest request to config download request struct
let mut config_download_request =
diff --git a/plugins/c8y_configuration_plugin/src/main.rs b/plugins/c8y_configuration_plugin/src/main.rs
index 884c84c6..44307255 100644
--- a/plugins/c8y_configuration_plugin/src/main.rs
+++ b/plugins/c8y_configuration_plugin/src/main.rs
@@ -59,10 +59,7 @@ pub struct ConfigPluginOpt {
pub config_file: PathBuf,
}
-async fn create_mqtt_client(
- tedge_config: &TEdgeCon