def __init__(self):
        super().__init__()

        variables = ConfigLoader('../config.yml')

        self._api = WebApi(
            variables.config['CHECK_MK_SERVER'],
            username=variables.config['CHECK_MK_USER'],
            secret=variables.config['CHECK_MK_PASSWORD'])

        self._check = 'This is a journey into Check Mk.'
        self._command_name = 'Check Mk'

        # Add additional command functions and parsers here
        self._commands.update({
            'get': GetCommands(self._api),
            'host': HostCommands(self._api),
            'downtime': DowntimeCommands(self._api)
        })
예제 #2
0
    def __init__(self):
        super().__init__()

        variables = ConfigLoader("../../config/config.yml")

        self._api = WebApi(
            variables.config["CHECK_MK_SERVER"],
            username=variables.config["CHECK_MK_USER"],
            secret=variables.config["CHECK_MK_PASSWORD"],
        )

        self._check = "This is a journey into Check Mk."
        self._command_name = "Check Mk"

        # Add additional command functions and parsers here
        self._commands.update({
            "get": GetCommands(self._api),
            "host": HostCommands(self._api),
            "downtime": DowntimeCommands(self._api),
        })
import os
import pytest
from tests import filter_uri
from check_mk_web_api.exception import CheckMkWebApiException
from check_mk_web_api.web_api import WebApi

api = WebApi(
    os.environ["CHECK_MK_URL"],
    os.environ["CHECK_MK_USER"],
    os.environ["CHECK_MK_SECRET"],
)


class TestServiceGroup:
    def setup(self):
        api.delete_all_servicegroups()


    @pytest.mark.skip('bad cassette, will not find url currently')
    def test_get_servicegroup(self):
        api.add_servicegroup('db', 'Database')
        assert api.get_servicegroup('db')

    @pytest.mark.skip('bad cassette, will not find url currently')
    def test_get_all_servicegroups(self):
        api.add_servicegroup('db', 'Database')
        api.add_servicegroup('web', 'Webserver')
        groups = api.get_all_servicegroups()
        assert 'db' in groups
        assert 'web' in groups
예제 #4
0
import os
from tests import filter_uri
import pytest
from check_mk_web_api.exception import CheckMkWebApiException
from check_mk_web_api.web_api import WebApi

api = WebApi(os.environ['CHECK_MK_URL'], os.environ['CHECK_MK_USER'],
             os.environ['CHECK_MK_SECRET'])


class TestUsers():
    def setup(self):
        for user_id in api.get_all_users():
            if user_id != 'cmkadmin' and user_id != os.environ['CHECK_MK_USER']:
                api.delete_user(user_id)

    @pytest.mark.skip('Skip test')
    def test_get_user(self):
        api.add_user('user00', 'User 00', 'p4ssw0rd')
        assert api.get_user('user00')['alias'] == 'User 00'

    @filter_uri
    def test_get_all_users(self):
        api.add_user('user00', 'User 00', 'p4ssw0rd')
        api.add_user('user01', 'User 01', 'p4ssw0rd')

        users = api.get_all_users()
        assert 'user00' in users
        assert 'user01' in users

    @filter_uri