Exemple #1
0
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}')
Exemple #2
0
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)
Exemple #3
0
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)
Exemple #4
0
def test_valid_positional_policy():
    policy = extract_policy(__valid_example)
    assert validate_policy(policy, __valid_example, positional_based_policy)
Exemple #5
0
def test_invalid_password_string():
    policy = extract_policy(__invalid_example)
    assert not validate_policy(policy, __invalid_example)
Exemple #6
0
def test_min_char_password_valid():
    password_string = '1-3 c: caerwxf'
    policy = extract_policy(password_string)
    assert validate_policy(policy, password_string)
Exemple #7
0
def test_max_char_password_valid():
    password_string = '1-5 b: bbbbb'
    policy = extract_policy(password_string)
    assert validate_policy(policy, password_string)
Exemple #8
0
def test_valid_input_correct_passwords_detected():
    policy = extract_policy(__valid_example)
    policy_valid: bool = validate_policy(policy, __valid_example)
    assert policy_valid