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))
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))
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)
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)
def _generate_secret() -> str: return ensure_str(utils.get_random_string(256))
def generate_secret(): return utils.get_random_string(256)
def _generate_secret(): # type: () -> Text return ensure_unicode(utils.get_random_string(256))
def _generate_secret(): # type: () -> str return ensure_text(utils.get_random_string(256))