summaryrefslogtreecommitdiff
path: root/server/src/auth.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-01-03 01:28:54 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-01-03 01:28:54 +0100
commit7494db93b9262c3d8330fd11631e711a1642b8fc (patch)
tree565534ddaa990a861c0ef8a9439f7656fce7f132 /server/src/auth.rs
parent4b1f7fec1cf9d427234ff5bded79a6d18d5c88ce (diff)
Add initital tests
Also add /users endpoint.
Diffstat (limited to 'server/src/auth.rs')
-rw-r--r--server/src/auth.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/server/src/auth.rs b/server/src/auth.rs
index f1b8f70..db3a6a0 100644
--- a/server/src/auth.rs
+++ b/server/src/auth.rs
@@ -248,8 +248,10 @@ fn unauthorized() -> Json<api_model::StatusResponse> {
Json(STATUS_UNAUTHORIZED)
}
+#[cfg(not(test))]
async fn run_import(rocket: Rocket<Build>) -> fairing::Result {
match Db::fetch(&rocket) {
+ // TODO: Replace with ldap
Some(db) => match sqlx::query!("INSERT IGNORE INTO users (username) VALUES (?)", "user")
.execute(&**db)
.await
@@ -261,6 +263,24 @@ async fn run_import(rocket: Rocket<Build>) -> fairing::Result {
}
}
+#[cfg(test)]
+async fn run_import(rocket: Rocket<Build>) -> fairing::Result {
+ match Db::fetch(&rocket) {
+ Some(db) => match sqlx::query!(
+ "INSERT IGNORE INTO users (username) VALUES (?), (?)",
+ "user",
+ "other",
+ )
+ .execute(&**db)
+ .await
+ {
+ Ok(_) => Ok(rocket),
+ Err(_) => Err(rocket),
+ },
+ None => Err(rocket),
+ }
+}
+
pub fn stage(basepath: &str) -> AdHoc {
let l_basepath = basepath.to_string();
AdHoc::on_ignite("Auth Stage", |rocket| async {