Code Duplication    Length = 24-24 lines in 2 locations

tests/test_rule_handling.py 2 locations

@@ 415-438 (lines=24) @@
412
    # doing changes --> password should not be cleared
413
    assert password_proxy_mock.RootPassword == "aaaa"
414
415
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
416
def test_evaluation_passwd_minlen_short_passwd_report_only(
417
        proxy_getter, rule_data, ksdata_mock, storage_mock):
418
    password_proxy_mock = mock.MagicMock()
419
    proxy_getter.return_value = password_proxy_mock
420
    password_proxy_mock.IsRootPasswordCrypted = False
421
    password_proxy_mock.RootPassword = "aaaa"
422
423
    rule_data.new_rule("passwd --minlen=8")
424
425
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=True)
426
427
    # minimal password length greater than actual length --> one warning
428
    assert len(messages) == 1
429
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
430
431
    # warning has to mention the length
432
    assert "8" in messages[0].text
433
434
    # warning should mention that something is wrong with the old password
435
    assert "is" in messages[0].text
436
437
    # doing changes --> password should not be cleared
438
    assert password_proxy_mock.RootPassword == "aaaa"
439
440
441
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
@@ 390-413 (lines=24) @@
387
        assert str(not_wanted) not in messages[0].text
388
389
390
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
391
def test_evaluation_passwd_minlen_short_passwd(
392
        proxy_getter, rule_data, ksdata_mock, storage_mock):
393
    password_proxy_mock = mock.MagicMock()
394
    proxy_getter.return_value = password_proxy_mock
395
    password_proxy_mock.IsRootPasswordCrypted = False
396
    password_proxy_mock.RootPassword = "aaaa"
397
398
    rule_data.new_rule("passwd --minlen=8")
399
400
    messages = rule_data.eval_rules(ksdata_mock, storage_mock, report_only=False)
401
402
    # minimal password length greater than actual length --> one warning
403
    assert len(messages) == 1
404
    assert messages[0].type == common.MESSAGE_TYPE_FATAL
405
406
    # warning has to mention the length
407
    assert "8" in messages[0].text
408
409
    # warning should mention that something is wrong with the old password
410
    assert "is" in messages[0].text
411
412
    # doing changes --> password should not be cleared
413
    assert password_proxy_mock.RootPassword == "aaaa"
414
415
@mock.patch("pyanaconda.dbus.DBus.get_proxy")
416
def test_evaluation_passwd_minlen_short_passwd_report_only(