ezidam: tests: openid configuration
This commit is contained in:
parent
2d0d6857ce
commit
d7783a2002
3 changed files with 46 additions and 6 deletions
|
|
@ -93,11 +93,7 @@ mod test {
|
|||
assert_eq!(setup_page.status(), Status::Ok);
|
||||
|
||||
// Create account
|
||||
let create_account = client
|
||||
.post(uri!("/setup"))
|
||||
.header(ContentType::Form)
|
||||
.body(r#"username=phil&password=password&url=https://example.com"#)
|
||||
.dispatch();
|
||||
let create_account = run_setup(&client);
|
||||
assert_eq!(create_account.status(), Status::SeeOther);
|
||||
|
||||
// Make request again, make sure its not OK
|
||||
|
|
|
|||
|
|
@ -23,3 +23,39 @@ async fn openid_configuration(mut db: Connection<Database>) -> Result<Json<Value
|
|||
// HTTP response
|
||||
Ok(Json(openid_configuration))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::tests::*;
|
||||
use rocket::serde::json::Value;
|
||||
|
||||
#[test]
|
||||
fn valid_openid_configuration() {
|
||||
// Setup http server
|
||||
let client = setup_rocket_testing();
|
||||
|
||||
// Run setup
|
||||
run_setup(&client);
|
||||
|
||||
// Make request
|
||||
let response = client
|
||||
.get(uri!("/.well-known/openid-configuration"))
|
||||
.dispatch();
|
||||
assert_eq!(response.status(), Status::Ok);
|
||||
|
||||
// Make sure it is valid json
|
||||
assert!(response.into_json::<Value>().is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_openid_configuration() {
|
||||
// Setup http server
|
||||
let client = setup_rocket_testing();
|
||||
|
||||
// Make request
|
||||
let response = client
|
||||
.get(uri!("/.well-known/openid-configuration"))
|
||||
.dispatch();
|
||||
assert_ne!(response.status(), Status::Ok);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::rocket_setup;
|
||||
use rocket::local::blocking::Client;
|
||||
use rocket::local::blocking::{Client, LocalResponse};
|
||||
use rocket::{Build, Rocket};
|
||||
|
||||
pub use rocket::http::{ContentType, Status};
|
||||
|
|
@ -26,3 +26,11 @@ fn rocket_with_memory_database() -> Rocket<Build> {
|
|||
pub fn setup_rocket_testing() -> Client {
|
||||
Client::tracked(rocket_with_memory_database()).expect("valid rocket instance")
|
||||
}
|
||||
|
||||
pub fn run_setup(client: &Client) -> LocalResponse {
|
||||
client
|
||||
.post(uri!("/setup"))
|
||||
.header(ContentType::Form)
|
||||
.body(r#"username=phil&password=password&url=https://example.com"#)
|
||||
.dispatch()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue