コード例 #1
0
def test_disabled_config():
    module = FTPAnonymousAccess()

    if module.name not in config.config:
        config.config.add_section(module.name)
    config.config.set(module.name, "enabled", "no")

    result = module.should_execute("ftp", 21)

    config.config.set(module.name, "enabled", "yes")

    assert result is False
コード例 #2
0
def test_remove_files_over_size():
    module = FTPAnonymousAccess()
    try:
        ftp_client = ftplib.FTP()
        ftp_client.connect("speedtest.tele2.net", 21, timeout=15)
        ftp_client.login()
        ftp_files = ftp_client.nlst()
        # 2048 bytes is only bigger than one of the files available - 1KB.zip
        sanitised_ftp_files, large_files = module.remove_files_over_size(ftp_client, ftp_files, 2048)
        assert len(sanitised_ftp_files) is 1
        ftp_client.quit()
    except TimeoutError:
        warnings.warn("Connection timed out. Test unable to complete")
    except ftplib.error_temp as e:
        warnings.warn("Unable to connect - " + e.args[0])
コード例 #3
0
def test_invalid_target():
    module = FTPAnonymousAccess()
    Loot.reset()

    hostname = "1.1.1.1"
    port = 21

    module.execute(hostname, port)

    port = str(port)

    assert Loot.loot[hostname] is not None
    assert Loot.loot[hostname][port] is not None
    assert Loot.loot[hostname][port][module.loot_name] is not None
    assert "Downloaded Files" not in Loot.loot[hostname][port][module.loot_name]
    assert "Files" not in Loot.loot[hostname][port][module.loot_name]
コード例 #4
0
def test_should_not_run():
    module = FTPAnonymousAccess()
    assert module.should_execute("ssh", 22) is False
コード例 #5
0
def test_should_run_port():
    module = FTPAnonymousAccess()
    assert module.should_execute("ftpd", 21)
コード例 #6
0
def test_should_run_service():
    module = FTPAnonymousAccess()
    assert module.should_execute("ftp", 2121)
コード例 #7
0
def test_module_creation():
    module = FTPAnonymousAccess()
    assert module is not None