Response to code review
This commit is contained in:
parent
4021e17bbf
commit
1b66ee8d9e
|
@ -1070,20 +1070,6 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "3.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3"
|
||||
dependencies = [
|
||||
"log 0.4.14",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"quick-error 2.0.1",
|
||||
"serde 1.0.130",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
|
@ -1177,7 +1163,7 @@ version = "1.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
||||
dependencies = [
|
||||
"quick-error 1.2.3",
|
||||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2864,12 +2850,6 @@ version = "1.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
|
@ -3258,7 +3238,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "c83f1287ad8fa034410928297a91db37518d5c46d7cc7e1e1b4a77aec0cd8807"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"handlebars",
|
||||
"normpath",
|
||||
"notify",
|
||||
"rocket",
|
||||
|
|
|
@ -50,11 +50,6 @@ regex = "1"
|
|||
xdg = "2.2.0"
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
||||
#[dependencies.rocket_contrib]
|
||||
#version = "0.4.10"
|
||||
#default-features = false
|
||||
#features = ["tera_templates"]
|
||||
|
||||
[dependencies.rocket_dyn_templates]
|
||||
version = "0.1.0-rc.1"
|
||||
features = ["handlebars", "tera"]
|
||||
features = ["tera"]
|
||||
|
|
|
@ -102,7 +102,6 @@ fn init_rocket() -> Rocket<Build> {
|
|||
forget_ap, // JSON API
|
||||
modify_password, // JSON API
|
||||
ping_pong, // JSON API
|
||||
test_route, // JSON API
|
||||
ping_network, // JSON API
|
||||
ping_oled, // JSON API
|
||||
ping_stats, // JSON API
|
||||
|
|
|
@ -3,7 +3,6 @@ use log::{debug, warn};
|
|||
use rocket::get;
|
||||
use rocket::serde::json::{Value};
|
||||
|
||||
use peach_lib::dyndns_client::is_dns_updater_online;
|
||||
use peach_lib::network_client;
|
||||
use peach_lib::oled_client;
|
||||
use peach_lib::stats_client;
|
||||
|
@ -19,15 +18,6 @@ pub fn ping_pong() -> Value {
|
|||
build_json_response(status, None, Some(msg))
|
||||
}
|
||||
|
||||
/// Test route: useful for ad hoc testing.
|
||||
#[get("/api/v1/test")]
|
||||
pub fn test_route() -> Value {
|
||||
let val = is_dns_updater_online().unwrap();
|
||||
let status = "success".to_string();
|
||||
let msg = val.to_string();
|
||||
build_json_response(status, None, Some(msg))
|
||||
}
|
||||
|
||||
/// Status route: check availability of `peach-network` microservice.
|
||||
#[get("/api/v1/ping/network")]
|
||||
pub fn ping_network() -> Value {
|
||||
|
|
|
@ -610,12 +610,9 @@ impl NetworkAddContext {
|
|||
|
||||
#[get("/network/wifi/add?<ssid>")]
|
||||
pub fn network_add_ssid(ssid: &str, flash: Option<FlashMessage>) -> Template {
|
||||
// decode ssid from url
|
||||
let decoded_ssid = ssid;
|
||||
// let decoded_ssid = percent_decode(ssid.as_bytes()).decode_utf8().unwrap();
|
||||
let mut context = NetworkAddContext::build();
|
||||
context.back = Some("/network/wifi".to_string());
|
||||
context.selected = Some(decoded_ssid.to_string());
|
||||
context.selected = Some(ssid.to_string());
|
||||
context.title = Some("Add WiFi Network".to_string());
|
||||
// check to see if there is a flash message to display
|
||||
if let Some(flash) = flash {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use log::info;
|
||||
|
||||
use rocket::serde::json::{Value, json};
|
||||
use rocket::http::{ContentType, Status};
|
||||
|
@ -423,18 +422,16 @@ fn ping_pong() {
|
|||
|
||||
// HELPER FUNCTION TESTS
|
||||
|
||||
// TODO: fix this test
|
||||
// it currently fails with
|
||||
// error[E0609]: no field `message` on type `JsonValue`
|
||||
//#[test]
|
||||
//fn test_build_json_response() {
|
||||
// let status = "success".to_string();
|
||||
// let data = json!("WiFi credentials added.".to_string());
|
||||
// let j:Value = build_json_response(status, Some(data), None);
|
||||
// assert_eq!(j.status, "success");
|
||||
// assert_eq!(j.data, Some(json!("WiFi credentials added.")));
|
||||
// assert_eq!(j.message, None);
|
||||
//}
|
||||
#[test]
|
||||
fn test_build_json_response() {
|
||||
let status = "success".to_string();
|
||||
let data = json!("WiFi credentials added.".to_string());
|
||||
let j: Value = build_json_response(status, Some(data), None);
|
||||
assert_eq!(j["status"], "success");
|
||||
assert_eq!(j["data"], "WiFi credentials added.");
|
||||
assert_eq!(j["msg"], json!(null));
|
||||
}
|
||||
|
||||
|
||||
// FILE TESTS
|
||||
|
||||
|
|
Loading…
Reference in New Issue