def test_edit_htpasswd_users(web): users = { "klaus": { "alias": "mr. klaus", "pager": "99221199", "password": "******" }, "monroe": { "alias": "mr. monroe" } } try: web.add_htpasswd_users(users) web.edit_htpasswd_users({ "monroe": { "set_attributes": { "alias": "ms. monroe" } }, "klaus": { "unset_attributes": ["pager"] } }) all_users = web.get_all_users() assert not "pager" in all_users["klaus"] assert all_users["monroe"]["alias"] == "ms. monroe" finally: web.delete_htpasswd_users(list(users.keys()))
def test_edit_htpasswd_users(web): # noqa: F811 # pylint: disable=redefined-outer-name users = { "klaus": { "alias": "mr. klaus", "pager": "99221199", "password": "******" }, "monroe": { "alias": "mr. monroe" } } try: web.add_htpasswd_users(users) web.edit_htpasswd_users({ "monroe": { "set_attributes": { "alias": "ms. monroe" } }, "klaus": { "unset_attributes": ["pager"] } }) all_users = web.get_all_users() assert "pager" not in all_users["klaus"] assert all_users["monroe"]["alias"] == "ms. monroe" finally: web.delete_htpasswd_users(list(users.keys()))
def test_log(request, web, site, fake_sendmail): core, log = request.param site.set_config("CORE", core, with_restart=True) users = { "hh": { "alias": "Harry Hirsch", "password": "******", "email": u"%s@localhost" % web.site.id, 'contactgroups': ['all'], }, } expected_users = set(["cmkadmin", "automation"] + users.keys()) web.add_htpasswd_users(users) all_users = web.get_all_users() assert not expected_users - set(all_users.keys()) site.live.command("[%d] STOP_EXECUTING_HOST_CHECKS" % time.time()) site.live.command("[%d] STOP_EXECUTING_SVC_CHECKS" % time.time()) web.add_host("notify-test", attributes={ "ipaddress": "127.0.0.1", }) web.activate_changes() with WatchLog(site, log, default_timeout=20) as l: yield l site.live.command("[%d] START_EXECUTING_HOST_CHECKS" % time.time()) site.live.command("[%d] START_EXECUTING_SVC_CHECKS" % time.time()) web.delete_host("notify-test") web.delete_htpasswd_users(users.keys()) web.activate_changes()
def test_config(web, site): users = { "hh": { "alias": "Harry Hirsch", "password": "******", "email": u"%s@localhost" % web.site.id, 'contactgroups': ['all'], }, } expected_users = set(["cmkadmin", "automation"] + users.keys()) web.add_htpasswd_users(users) all_users = web.get_all_users() assert not expected_users - set(all_users.keys()) site.live.command("[%d] STOP_EXECUTING_HOST_CHECKS" % time.time()) site.live.command("[%d] STOP_EXECUTING_SVC_CHECKS" % time.time()) web.add_host("notify-test", attributes={ "ipaddress": "127.0.0.1", }) web.activate_changes() yield site.live.command("[%d] START_EXECUTING_HOST_CHECKS" % time.time()) site.live.command("[%d] START_EXECUTING_SVC_CHECKS" % time.time()) web.delete_host("notify-test") web.delete_htpasswd_users(users.keys()) web.activate_changes()
def test_get_all_users(web): users = { "klaus": { "alias": "mr. klaus", "pager": "99221199", "password": "******" }, "monroe": { "alias": "mr. monroe" } } expected_users = set(["cmkadmin", "automation"] + list(users.keys())) try: _response = web.add_htpasswd_users(users) all_users = web.get_all_users() assert not expected_users - set(all_users.keys()) finally: web.delete_htpasswd_users(list(users.keys()))
def test_get_all_users(web): # noqa: F811 # pylint: disable=redefined-outer-name users = { "klaus": { "alias": "mr. klaus", "pager": "99221199", "password": "******" }, "monroe": { "alias": "mr. monroe" } } expected_users = set(["cmkadmin", "automation"] + list(users.keys())) try: web.add_htpasswd_users(users) all_users = web.get_all_users() assert not expected_users - set(all_users.keys()) finally: web.delete_htpasswd_users(list(users.keys()))