def count_based_policy_counter(data): """ Uses the count based policy to find the number of invalid passwords :param data: cleansed data strings """ print('Using count based password policy') valid = 0 invalid = 0 for password in data: policy = extract_policy(password) if validate_policy(policy, password): valid += 1 else: invalid += 1 print(f'[+]\tValid: {valid}') print(f'[+]\tInvalid: {invalid}')
def test_invalid_positional_policy_duplicate_char(): password_string = '1-3 b: babdd' policy = extract_policy(password_string) assert not validate_policy(policy, password_string, positional_based_policy)
def test_invalid_positional_policy_no_match(): password_string = '1-4 a: cdefsg' policy = extract_policy(password_string) assert not validate_policy(policy, password_string, positional_based_policy)
def test_valid_positional_policy(): policy = extract_policy(__valid_example) assert validate_policy(policy, __valid_example, positional_based_policy)
def test_invalid_password_string(): policy = extract_policy(__invalid_example) assert not validate_policy(policy, __invalid_example)
def test_min_char_password_valid(): password_string = '1-3 c: caerwxf' policy = extract_policy(password_string) assert validate_policy(policy, password_string)
def test_max_char_password_valid(): password_string = '1-5 b: bbbbb' policy = extract_policy(password_string) assert validate_policy(policy, password_string)
def test_valid_input_correct_passwords_detected(): policy = extract_policy(__valid_example) policy_valid: bool = validate_policy(policy, __valid_example) assert policy_valid