Add tests for plume webserver (#513)

* begin setup front-end test environment with selenium
* run migrations before tests
* use https for tests
This commit is contained in:
fdb-hiroshima
2019-04-06 17:41:57 +02:00
committed by GitHub
parent 1f7ff62c19
commit eabe73ddc0
17 changed files with 171 additions and 45 deletions
+9 -13
View File
@@ -59,6 +59,8 @@ mod mail;
#[macro_use]
mod template_utils;
mod routes;
#[cfg(feature = "test")]
mod test_routes;
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
@@ -122,6 +124,7 @@ Then try to restart Plume
let search_unlocker = searcher.clone();
ctrlc::set_handler(move || {
search_unlocker.commit();
search_unlocker.drop_writer();
exit(0);
})
@@ -133,7 +136,7 @@ Then try to restart Plume
println!("Please refer to the documentation to see how to configure it.");
}
rocket::custom(CONFIG.rocket.clone().unwrap())
let rocket = rocket::custom(CONFIG.rocket.clone().unwrap())
.mount(
"/",
routes![
@@ -258,16 +261,6 @@ Then try to restart Plume
"/@/<name>/inbox".to_owned(),
rocket::http::Method::Post,
),
(
"/login".to_owned(),
"/login".to_owned(),
rocket::http::Method::Post,
),
(
"/users/new".to_owned(),
"/users/new".to_owned(),
rocket::http::Method::Post,
),
(
"/api/<path..>".to_owned(),
"/api/<path..>".to_owned(),
@@ -276,6 +269,9 @@ Then try to restart Plume
])
.finalize()
.expect("main: csrf fairing creation error"),
)
.launch();
);
#[cfg(feature = "test")]
let rocket = rocket.mount("/test", routes![test_routes::health,]);
rocket.launch();
}
+1 -4
View File
@@ -43,10 +43,7 @@ pub fn create(
#[post("/~/<blog>/<slug>/like", rank = 2)]
pub fn create_auth(blog: String, slug: String, i18n: I18n) -> Flash<Redirect> {
utils::requires_login(
&i18n!(
i18n.catalog,
"To like a post, you need to be logged in"
),
&i18n!(i18n.catalog, "To like a post, you need to be logged in"),
uri!(create: blog = blog, slug = slug),
)
}
+1 -4
View File
@@ -43,10 +43,7 @@ pub fn create(
#[post("/~/<blog>/<slug>/reshare", rank = 1)]
pub fn create_auth(blog: String, slug: String, i18n: I18n) -> Flash<Redirect> {
utils::requires_login(
&i18n!(
i18n.catalog,
"To reshare a post, you need to be logged in"
),
&i18n!(i18n.catalog, "To reshare a post, you need to be logged in"),
uri!(create: blog = blog, slug = slug),
)
}
+2
View File
@@ -0,0 +1,2 @@
#[get("/health")]
pub fn health() {}