Example #1
0
def test_managed_global_internal(monkeypatch):
    # this test uses the internal mechanics of the user endpoint
    monkeypatch.setattr(
        "cmk.gui.watolib.global_settings.rulebased_notifications_enabled",
        lambda: True)

    edit_users({
        "user": {
            "attributes": {
                "ui_theme": None,
                "ui_sidebar_position": None,
                "nav_hide_icons_title": None,
                "icons_per_item": None,
                "show_mode": None,
                "start_url": None,
                "force_authuser": False,
                "enforce_pw_change": False,
                "alias": "User Name",
                "locked": False,
                "pager": "",
                "roles": [],
                "contactgroups": [],
                "customer": None,  # None represents global internally
                "email": "",
                "fallback_contact": False,
                "disable_notifications": {},
            },
            "is_new_user": True,
        }
    })
    user_internal = _load_user("user")
    user_endpoint_attrs = complement_customer(
        _internal_to_api_format(user_internal))
    assert user_endpoint_attrs["customer"] == "global"
Example #2
0
def test_managed_idle_internal(wsgi_app, with_automation_user, monkeypatch):
    # this test uses the internal mechanics of the user endpoint
    monkeypatch.setattr(
        "cmk.gui.watolib.global_settings.rulebased_notifications_enabled",
        lambda: True)
    username, secret = with_automation_user
    wsgi_app.set_authorization(('Bearer', username + " " + secret))

    edit_users({
        'user': {
            'attributes': {
                'ui_theme': None,
                'ui_sidebar_position': None,
                'nav_hide_icons_title': None,
                'icons_per_item': None,
                'show_mode': None,
                'start_url': None,
                'force_authuser': False,
                'enforce_pw_change': False,
                'alias': 'User Name',
                'locked': False,
                'pager': '',
                'roles': [],
                'contactgroups': [],
                'customer': None,  # None represents global internally
                'email': '',
                'fallback_contact': False,
                'disable_notifications': {}
            },
            'is_new_user': True
        }
    })
    user_internal = _load_user("user")
    user_endpoint_attrs = complement_customer(
        _internal_to_api_format(user_internal))
    assert "idle_timeout" not in _load_user(username)
    assert user_endpoint_attrs["idle_timeout"] == {"option": "global"}