示例#1
0
def test_backup_key_create_web(monkeypatch: pytest.MonkeyPatch) -> None:
    monkeypatch.setattr(user, "id", "dingdöng")
    store_path = Path(cmk.utils.paths.default_config_dir, "backup_keys.mk")

    assert not store_path.exists()
    mode = wato.ModeBackupEditKey()

    # First create a backup key
    mode._create_key(alias="älias", passphrase="passphra$e")

    assert store_path.exists()

    # Then test key existence
    test_mode = wato.ModeBackupEditKey()
    keys = test_mode.key_store.load()
    assert len(keys) == 1

    assert store_path.exists()
    store_path.unlink()
示例#2
0
def test_backup_key_create_web(register_builtin_html, site, monkeypatch):
    store_path = Path(cmk.utils.paths.default_config_dir, "backup_keys.mk")

    assert not store_path.exists()
    mode = wato.ModeBackupEditKey()

    # First create a backup key
    mode._create_key({
        "alias": u"älias",
        "passphrase": "passphra$e",
    })

    assert store_path.exists()

    # Then test key existence
    test_mode = wato.ModeBackupEditKey()
    keys = test_mode.load()
    assert len(keys) == 1

    assert store_path.exists()
    store_path.unlink()
示例#3
0
def test_backup_key_create_web(site, monkeypatch):
    if site.file_exists("etc/check_mk/backup_keys.mk"):
        site.delete_file("etc/check_mk/backup_keys.mk")

    import cmk.gui.wato as wato
    mode = wato.ModeBackupEditKey()

    try:
        # First create a backup key
        key_dict = mode._create_key({
            "alias": u"älias",
            "passphrase": "passphra$e",
        })

        assert site.file_exists("etc/check_mk/backup_keys.mk")

        # Then test key existance
        test_mode = wato.ModeBackupEditKey()
        keys = test_mode.load()
        assert len(keys) == 1
    finally:
        site.delete_file("etc/check_mk/backup_keys.mk")