예제 #1
0
def list_outdated():
    agents = Agent.get_outdated_agents()
    if agents['totalItems'] == 0:
        print("All agents are updated.")
    else:
        print("%-6s%-35s %-25s" % ("ID", "Name", "Version"))
        for agent in agents['items']:
            print("%-6s%-35s %-25s" % (agent['id'], agent['name'], agent['version']))
        print("\nTotal outdated agents: {0}".format(agents['totalItems']))
예제 #2
0
def test_get_outdated_agents(test_data):
    """
    Test get_outdated_agents function
    """
    with patch('sqlite3.connect') as mock_db:
        mock_db.return_value = test_data.global_db
        result = Agent.get_outdated_agents()

        assert isinstance(result, dict)
        assert result['totalItems'] == len(result['items'])

        for item in result['items']:
            assert set(item.keys()) == {'version', 'id', 'name'}
            assert WazuhVersion(item['version']) < WazuhVersion(get_manager_version())