feat: private Personas und Modellgrundlage ergänzen
This commit is contained in:
@ -2178,6 +2178,67 @@ async fn gemessener_vram_wird_gespeichert_und_begrenzt_die_gpu() {
|
||||
assert_eq!(stops(&gw), 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn nur_admin_aendert_modellgrundlage_und_personas_bleiben_privat() {
|
||||
let gw = gateway(0, false).await;
|
||||
let (admin, acsrf) = ui_session(&gw, &gw.key_admin).await;
|
||||
let (user, ucsrf) = ui_session(&gw, &gw.key_ui).await;
|
||||
assert_eq!(
|
||||
ui_post(
|
||||
&gw,
|
||||
"/ui/modelle/systemprompt",
|
||||
&user,
|
||||
&format!("csrf={ucsrf}&name=bonsai&systemprompt=Nicht+erlaubt")
|
||||
)
|
||||
.await
|
||||
.0,
|
||||
403
|
||||
);
|
||||
assert_eq!(
|
||||
gw.state
|
||||
.store()
|
||||
.model_systemprompt("bonsai")
|
||||
.unwrap()
|
||||
.as_deref(),
|
||||
Some("")
|
||||
);
|
||||
assert_eq!(
|
||||
ui_post(
|
||||
&gw,
|
||||
"/ui/modelle/systemprompt",
|
||||
&admin,
|
||||
&format!("csrf={acsrf}&name=bonsai&systemprompt=Grundlage")
|
||||
)
|
||||
.await
|
||||
.0,
|
||||
303
|
||||
);
|
||||
assert_eq!(
|
||||
gw.state
|
||||
.store()
|
||||
.model_systemprompt("bonsai")
|
||||
.unwrap()
|
||||
.as_deref(),
|
||||
Some("Grundlage")
|
||||
);
|
||||
let (status, _, _) = ui_post(
|
||||
&gw,
|
||||
"/ui/personas/speichern",
|
||||
&user,
|
||||
&format!("csrf={ucsrf}&name=Privat&systemprompt=Geheim&stil=Kurz"),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, 303);
|
||||
let (status, _, own) = ui_get(&gw, "/ui/personas", Some(&user)).await;
|
||||
assert_eq!(status, 200);
|
||||
assert!(own.contains("Privat"));
|
||||
let (_, _, foreign) = ui_get(&gw, "/ui/personas", Some(&admin)).await;
|
||||
assert!(!foreign.contains("Privat") && !foreign.contains("Geheim"));
|
||||
let id = gw.state.store().personas(TEST_NUTZER).unwrap()[0].id;
|
||||
let (_, _, foreign) = ui_get(&gw, &format!("/ui/personas?id={id}"), Some(&admin)).await;
|
||||
assert!(!foreign.contains("Geheim"));
|
||||
}
|
||||
|
||||
// --- Verwaltung und Playground (0.1.7) ---------------------------------------
|
||||
|
||||
/// Meldet an und liefert Cookie und CSRF-Token der Sitzung.
|
||||
|
||||
Reference in New Issue
Block a user