mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-12 15:34:00 +00:00
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
bcf5c91f81
commit
ccb6435c1d
1 changed files with 10 additions and 2 deletions
|
@ -307,7 +307,7 @@ pub fn site_description_length_check(description: &str) -> Result<(), LemmyError
|
||||||
|
|
||||||
/// Checks for a honeypot. If this field is filled, fail the rest of the function
|
/// Checks for a honeypot. If this field is filled, fail the rest of the function
|
||||||
pub fn honeypot_check(honeypot: &Option<String>) -> Result<(), LemmyError> {
|
pub fn honeypot_check(honeypot: &Option<String>) -> Result<(), LemmyError> {
|
||||||
if honeypot.is_some() {
|
if honeypot.is_some() && honeypot != &Some(String::new()) {
|
||||||
Err(LemmyError::from_message("honeypot_fail"))
|
Err(LemmyError::from_message("honeypot_fail"))
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -724,7 +724,7 @@ pub fn listing_type_with_site_default(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::password_length_check;
|
use crate::utils::{honeypot_check, password_length_check};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
@ -734,4 +734,12 @@ mod tests {
|
||||||
assert!(password_length_check("short").is_err());
|
assert!(password_length_check("short").is_err());
|
||||||
assert!(password_length_check("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong").is_err());
|
assert!(password_length_check("looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn honeypot() {
|
||||||
|
assert!(honeypot_check(&None).is_ok());
|
||||||
|
assert!(honeypot_check(&Some(String::new())).is_ok());
|
||||||
|
assert!(honeypot_check(&Some("1".to_string())).is_err());
|
||||||
|
assert!(honeypot_check(&Some("message".to_string())).is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue