Skip to content

Commit

Permalink
🌐 ✨ Add german dictionary (#7)
Browse files Browse the repository at this point in the history
* add german wiki

* add german dict and names and tests

* update variable names

---------

Co-authored-by: Lia <lia@staff.identeco.de>
  • Loading branch information
TadaaLiia and Lia authored Mar 5, 2024
1 parent 8088d30 commit ff52ce9
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 10 deletions.
65 changes: 57 additions & 8 deletions src/feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,24 @@ fn get_dictionary_match_feedback(
} else {
Warning::ThisIsSimilarToACommonlyUsedPassword
}),
DictionaryType::English => {
DictionaryType::EnglishWiki
| DictionaryType::GermanWiki
| DictionaryType::GermanCommonWords => {
if is_sole_match {
Some(Warning::AWordByItselfIsEasyToGuess)
} else {
None
}
}
DictionaryType::Surnames | DictionaryType::FemaleNames | DictionaryType::MaleNames => {
Some(if is_sole_match {
Warning::NamesAndSurnamesByThemselvesAreEasyToGuess
} else {
Warning::CommonNamesAndSurnamesAreEasyToGuess
})
}
DictionaryType::Surnames
| DictionaryType::FemaleNames
| DictionaryType::MaleNames
| DictionaryType::GermanNames
| DictionaryType::GermanSurnames => Some(if is_sole_match {
Warning::NamesAndSurnamesByThemselvesAreEasyToGuess
} else {
Warning::CommonNamesAndSurnamesAreEasyToGuess
}),
_ => None,
};

Expand Down Expand Up @@ -323,4 +327,49 @@ mod tests {
Some(Warning::ThisIsSimilarToACommonlyUsedPassword)
);
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
fn test_german_names_feedback() {
use crate::zxcvbn;

let password = "schmidt";
let entropy = zxcvbn(password, &[]).unwrap();
assert_eq!(
entropy.feedback.unwrap().warning,
Some(Warning::NamesAndSurnamesByThemselvesAreEasyToGuess)
);

let password = "schmidt123";
let entropy = zxcvbn(password, &[]).unwrap();
assert_eq!(
entropy.feedback.unwrap().warning,
Some(Warning::CommonNamesAndSurnamesAreEasyToGuess)
);

let password = "Peter";
let entropy = zxcvbn(password, &[]).unwrap();
assert_eq!(
entropy.feedback.unwrap().warning,
Some(Warning::NamesAndSurnamesByThemselvesAreEasyToGuess)
);

let password = "Peter678";
let entropy = zxcvbn(password, &[]).unwrap();
assert_eq!(
entropy.feedback.unwrap().warning,
Some(Warning::CommonNamesAndSurnamesAreEasyToGuess)
);
}

#[cfg_attr(not(target_arch = "wasm32"), test)]
fn test_german_common_words_feedback() {
use crate::zxcvbn;

let password = "hauSaufGaben";
let entropy = zxcvbn(password, &[]).unwrap();
assert_eq!(
entropy.feedback.unwrap().warning,
Some(Warning::AWordByItselfIsEasyToGuess)
);
}
}
44 changes: 42 additions & 2 deletions src/frequency_lists.rs

Large diffs are not rendered by default.

0 comments on commit ff52ce9

Please sign in to comment.