from app.branding import BrandingStore, BrandingUpdate def test_branding_save_public_and_password_isolated(tmp_path, monkeypatch): monkeypatch.setenv("BIDITECH_BRANDING_CONFIG", str(tmp_path / "b.json")) monkeypatch.setenv("BIDITECH_BRANDING_SECRET", str(tmp_path / "bs.json")) store = BrandingStore() store.save(BrandingUpdate(plant_name="胶州水厂二期", system_title="泵组节能优化系统", company="上海碧帝", contact_phone="021-1", login_enabled=True, password="pump2026")) pub = store.public() assert pub["plant_name"] == "胶州水厂二期" assert pub["password_configured"] is True assert "password" not in pub # 公开信息不含口令 assert store.verify("pump2026") is True assert store.verify("wrong") is False def test_branding_no_password_allows_all(tmp_path, monkeypatch): monkeypatch.setenv("BIDITECH_BRANDING_CONFIG", str(tmp_path / "b.json")) monkeypatch.setenv("BIDITECH_BRANDING_SECRET", str(tmp_path / "bs.json")) store = BrandingStore() assert store.verify("anything") is True # 未设口令 → 放行