def test_save_for_helpers() -> None: assert not password_store.password_store_path().exists() password_store.save({"ding": "blablu"}) assert password_store.password_store_path().exists() assert password_store.load_for_helpers() == {} password_store.save_for_helpers(LATEST_CONFIG) assert password_store.load_for_helpers() == {"ding": "blablu"}
def test_save_for_helpers_no_store() -> None: assert not password_store.password_store_path().exists() assert password_store.load_for_helpers() == {} password_store.save_for_helpers(LATEST_CONFIG) assert not password_store.password_store_path().exists() assert not password_store._helper_password_store_path( LATEST_CONFIG).exists() assert password_store.load_for_helpers() == {}
def fixture_pre_2_1_password_store(): with password_store.password_store_path().open("w") as f: f.write("ding:dong\n") passwords_mk = Path(cmk.utils.paths.check_mk_config_dir, "wato", "passwords.mk") with passwords_mk.open("w") as f: f.write( "stored_passwords.update(%r)" % { "ding": { "title": "asd", "comment": "asd\n", "docu_url": "", "password": "******", "owned_by": None, "shared_with": [], } })
def test_rewrite_password_store_skip_when_empty( uc: update_config.UpdateConfig) -> None: store.save_text_to_file(password_store.password_store_path(), "") assert os.path.getsize(password_store.password_store_path()) == 0 uc._rewrite_password_store() assert os.path.getsize(password_store.password_store_path()) == 0
def test_rewrite_password_store_skip_when_missing( uc: update_config.UpdateConfig) -> None: assert not password_store.password_store_path().exists() uc._rewrite_password_store() assert not password_store.password_store_path().exists()
def test_save_obfuscated() -> None: password_store.save({"ding": "blablu"}) assert "blablu" not in password_store.password_store_path().read_text()