Code Duplication    Length = 22-22 lines in 2 locations

tests/test_rule_handling.py 2 locations

@@ 458-479 (lines=22) @@
455
    assert password_proxy_mock.RootPassword == "aaaa"
456
457
458
def test_evaluation_passwd_minlen_short_passwd_report_only(
459
        proxy_getter, rule_data, ksdata_mock, storage_mock):
460
    password_proxy_mock = USERS.get_proxy()
461
    password_proxy_mock.IsRootPasswordCrypted = False
462
    password_proxy_mock.RootPassword = "aaaa"
463
464
    rule_data.new_rule("passwd --minlen=8")
465
466
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=True)
467
468
    # minimal password length greater than actual length --> one warning
469
    assert len(messages) == 1
470
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
471
472
    # warning has to mention the length
473
    assert "8" in messages[0].text
474
475
    # warning should mention that something is wrong with the old password
476
    assert "is" in messages[0].text
477
478
    # doing changes --> password should not be cleared
479
    assert password_proxy_mock.RootPassword == "aaaa"
480
481
482
def test_evaluation_passwd_minlen_crypted_passwd(
@@ 434-455 (lines=22) @@
431
        assert str(not_wanted) not in messages[0].text
432
433
434
def test_evaluation_passwd_minlen_short_passwd(
435
        proxy_getter, rule_data, ksdata_mock, storage_mock):
436
    password_proxy_mock = USERS.get_proxy()
437
    password_proxy_mock.IsRootPasswordCrypted = False
438
    password_proxy_mock.RootPassword = "aaaa"
439
440
    rule_data.new_rule("passwd --minlen=8")
441
442
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=False)
443
444
    # minimal password length greater than actual length --> one warning
445
    assert len(messages) == 1
446
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
447
448
    # warning has to mention the length
449
    assert "8" in messages[0].text
450
451
    # warning should mention that something is wrong with the old password
452
    assert "is" in messages[0].text
453
454
    # doing changes --> password should not be cleared
455
    assert password_proxy_mock.RootPassword == "aaaa"
456
457
458
def test_evaluation_passwd_minlen_short_passwd_report_only(