aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2021-07-22 12:14:04 +0800
committerKunoiSayami <[email protected]>2021-07-22 12:14:04 +0800
commit84a915854ce73dadbed40fd13cea6044e7776ae9 (patch)
tree84810fe81a3546af5aff0bdc044d03ce4bf9a02c
parent840a5e9e6f077d0c7cf42d6e8a7089f41fb1ab0e (diff)
feat(test): Add compile time wait commit time option
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs10
-rw-r--r--src/test.rs7
4 files changed, 17 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a6a0145..9a0c062 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -370,7 +370,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cgit-simple-authentication"
-version = "3.0.2"
+version = "3.0.3"
dependencies = [
"anyhow",
"argon2",
diff --git a/Cargo.toml b/Cargo.toml
index 8c16e60..e09141e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cgit-simple-authentication"
-version = "3.0.2"
+version = "3.0.3"
authors = ["KunoiSayami <[email protected]>"]
edition = "2018"
diff --git a/src/main.rs b/src/main.rs
index 46f088f..f960422 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -60,6 +60,11 @@ impl<R: BufRead, W: Write> IOModule<R, W> {
if let Err(ref e) = ret {
eprintln!("{:?}", e);
+ #[cfg(test)]
+ eprintln!(
+ "If database locked error occurs frequently, \
+ please use environment DISK_WAIT_TIME to specify longer time."
+ );
log::error!("{:?}", e)
}
@@ -89,7 +94,10 @@ impl<R: BufRead, W: Write> IOModule<R, W> {
writeln!(
&mut self.writer,
"Set-Cookie: cgit_auth={}; Domain={}; Max-Age={}; HttpOnly{}",
- cookie_value, domain, cfg.cookie_ttl * 10, cookie_suffix
+ cookie_value,
+ domain,
+ cfg.cookie_ttl * 10,
+ cookie_suffix
)?;
} else {
writeln!(&mut self.writer, "Status: 403 Forbidden")?;
diff --git a/src/test.rs b/src/test.rs
index 8ae631a..100954c 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -212,7 +212,12 @@ mod core {
fn test_91_auth_pass() {
lock(&PathBuf::from("test/REPO_USER_ADDED"), 10);
// If process is too fast, this function may got Database locked error
- sleep(Duration::from_millis(10));
+ sleep(Duration::from_millis(
+ option_env!("DISK_WAIT_TIME")
+ .unwrap_or("10")
+ .parse()
+ .unwrap_or(10),
+ ));
let s = test_auth_post();