From 0108133876702e21203d9e02eb282b0ba93c43b4 Mon Sep 17 00:00:00 2001 From: KunoiSayami <46131041+KunoiSayami@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:42:39 +0800 Subject: feat(test): Add query_is_all_protected() method for test * feat(build): Add optimize option for build release --- Cargo.lock | 2 +- Cargo.toml | 7 ++++++- src/datastructures.rs | 10 ++++++++++ src/test.rs | 6 ++---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4e96f5..7fcda56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,7 +370,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cgit-simple-authentication" -version = "3.0.0" +version = "3.0.1" dependencies = [ "anyhow", "argon2", diff --git a/Cargo.toml b/Cargo.toml index f48ed89..837e7c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cgit-simple-authentication" -version = "3.0.0" +version = "3.0.1" authors = ["KunoiSayami <46131041+KunoiSayami@users.noreply.github.com>"] edition = "2018" @@ -30,3 +30,8 @@ regex = "1" [target.aarch64-unknown-linux-musl.dependencies] openssl = { version = "0.10", features = ["vendored"] } cpufeatures = "0.1.3" + +[profile.release] +opt-level=3 +lto=true +panic="abort" \ No newline at end of file diff --git a/src/datastructures.rs b/src/datastructures.rs index ba73d96..e004514 100644 --- a/src/datastructures.rs +++ b/src/datastructures.rs @@ -230,6 +230,11 @@ impl Config { pub(crate) fn get_white_list_mode_status(&self) -> bool { self.protect_config.get_white_list_mode_status() } + + #[cfg(test)] + pub(crate) fn query_is_all_protected(&self) -> bool { + self.protect_config.query_is_all_protected() + } } impl TestSuite for Config { @@ -379,6 +384,11 @@ impl ProtectSettings { pub(crate) fn get_white_list_mode_status(&self) -> bool { self.protect_white_list_mode } + + #[cfg(test)] + pub(crate) fn query_is_all_protected(&self) -> bool { + self.protect_enabled && self.protect_white_list_mode && self.repos.is_empty() + } } impl TestSuite for ProtectSettings { diff --git a/src/test.rs b/src/test.rs index 68ba29d..8ae631a 100644 --- a/src/test.rs +++ b/src/test.rs @@ -323,8 +323,7 @@ mod core { assert!(cfg.check_repo_protect("test"), "struct: {:#?}", cfg); assert!(!cfg.get_white_list_mode_status()); - // TODO: - //assert!(!cfg.query_is_all_protected()); + assert!(!cfg.query_is_all_protected()); write_to_specify_file( &tmpdir.path().join("REPO_SETTING"), @@ -336,8 +335,7 @@ mod core { assert!(!cfg.check_repo_protect("test")); assert!(!cfg.get_white_list_mode_status()); - // TODO: - //assert!(!cfg.query_is_all_protected()); + assert!(!cfg.query_is_all_protected()); tmpdir.close().unwrap(); } -- cgit v1.3.1