Esempio n. 1
0
def create_and_destroy_user(*, automation=False, role="user", username=None):
    if username is None:
        username = "******" + get_random_string(
            size=5, from_ascii=ord("a"), to_ascii=ord("z"))
    password = "******"
    edit_users(_mk_user_obj(username, password, automation, role))
    config.load_config()

    profile_path = Path(cmk.utils.paths.omd_root, "var", "check_mk", "web",
                        username)
    profile_path.joinpath("cached_profile.mk").write_text(
        str(
            repr({
                "alias": "Test user",
                "contactgroups": ["all"],
                "disable_notifications": {},
                "email": "*****@*****.**" % username,
                "fallback_contact": False,
                "force_authuser": False,
                "locked": False,
                "language": "de",
                "pager": "",
                "roles": [role],
                "start_url": None,
                "ui_theme": "modern-dark",
            })))

    yield username, password

    delete_users([username])

    # User directories are not deleted by WATO by default. Clean it up here!
    shutil.rmtree(str(profile_path))
Esempio n. 2
0
def _create_and_destroy_user(automation=False, role="user"):
    username = u'test123-' + get_random_string(
        size=5, from_ascii=ord('a'), to_ascii=ord('z'))
    password = u'Ischbinwischtisch'
    edit_users(_mk_user_obj(username, password, automation=automation))
    config.load_config()

    profile_path = Path(paths.omd_root, "var", "check_mk", "web", username)
    profile_path.joinpath('cached_profile.mk').write_text(
        str(
            repr({
                'alias': u'Test user',
                'contactgroups': ['all'],
                'disable_notifications': {},
                'email': u'*****@*****.**' % username,
                'fallback_contact': False,
                'force_authuser': False,
                'locked': False,
                'language': 'de',
                'pager': '',
                'roles': [role],
                'start_url': None,
                'ui_theme': 'modern-dark',
            })))

    yield username, password

    delete_users([username])

    # User directories are not deleted by WATO by default. Clean it up here!
    shutil.rmtree(str(profile_path))
Esempio n. 3
0
def _create_and_destroy_user(automation=False):
    username = u'test123-' + get_random_string(
        size=5, from_ascii=ord('a'), to_ascii=ord('z'))
    password = u'Ischbinwischtisch'
    edit_users(_mk_user_obj(username, password, automation=automation))
    config.load_config()

    yield username, password

    delete_users([username])

    # User directories are not deleted by WATO by default. Clean it up here!
    shutil.rmtree(paths.omd_root + "/var/check_mk/web/" + username)
Esempio n. 4
0
def _create_and_destroy_user(automation=False):
    contacts_mk = cmk.utils.paths.omd_root + "/etc/check_mk/conf.d/wato/contacts.mk"
    contact_existed = os.path.exists(contacts_mk)
    _touch(cmk.utils.paths.htpasswd_file)
    _touch(cmk.utils.paths.omd_root + '/etc/diskspace.conf')
    _makepath(cmk.utils.paths.var_dir + "/wato/auth")
    _makepath(config.config_dir)
    username = u'test123-' + get_random_string(size=5, from_ascii=ord('a'), to_ascii=ord('z'))
    password = u'Ischbinwischtisch'
    edit_users(_mk_user_obj(username, password, automation=automation))
    config.load_config()
    yield username, password
    delete_users([username])
    if not contact_existed:
        os.unlink(contacts_mk)
Esempio n. 5
0
def _generate_secret() -> str:
    return ensure_str(utils.get_random_string(256))
Esempio n. 6
0
def generate_secret():
    return utils.get_random_string(256)
Esempio n. 7
0
def _generate_secret():
    # type: () -> Text
    return ensure_unicode(utils.get_random_string(256))
Esempio n. 8
0
def _generate_secret():
    # type: () -> str
    return ensure_text(utils.get_random_string(256))