From 58547c822182724baf5a82ee95914ae3e9692a89 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 26 Nov 2026 17:34:40 +0300 Subject: [PATCH] Exercise channel administration through the real Rust CLI - Validate temporary channel creation, sparse edits, stale requests and limit readback on an isolated TeamSpeak beta14. - Report omitted inheritance flags and permission refusals separately from confirmed server writes. --- CHANGELOG.md | 2 + core/examples/channel_admin_qa.rs | 608 ++++++++++++++++++++++++++++++ docs/bridge.md | 2 + docs/mobile-port-progress.md | 1 + 4 files changed, 613 insertions(+) create mode 100644 core/examples/channel_admin_qa.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 65ea15e..9cabb9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Channel and server edit dialogs read current values before editing, retain drafts after rejection, + and close only on the matching server acknowledgement. Passwords are never prefilled. - Added ordinary-channel S3 metadata browsing, taking precedence over HTTPFT when both are advertised. The core accepts underscore-bearing command names and requires both matching list data and successful status; malformed or timed-out replies are errors, not empty folders. An isolated official TS6 beta14 diff --git a/core/examples/channel_admin_qa.rs b/core/examples/channel_admin_qa.rs new file mode 100644 index 0000000..0a99102 --- /dev/null +++ b/core/examples/channel_admin_qa.rs @@ -0,0 +1,608 @@ +//! Connected administration QA for an already running, private TS6 beta14 fixture. +//! Set TEAMSPEACH_QA_CORE to an absolute path to a disposable teamspeach-core.exe, +//! then run `cargo run --locked -p teamspeach-core --example channel_admin_qa`. +//! The only endpoint is 127.0.0.1:19987. No credentials, devices or ServerQuery. + +use std::fs; +use std::io::{BufRead, BufReader, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Child, Command, ExitCode, Stdio}; +use std::sync::mpsc; +use std::thread; +use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; + +use serde_json::{json, Value}; + +const ENDPOINT: &str = "127.0.0.1:19987"; +const CONTROL: Duration = Duration::from_secs(5); +const CONNECT: Duration = Duration::from_secs(12); +const POLL: Duration = Duration::from_millis(50); +// Leave a quiet window between ordinary server commands; do not retry flood refusals. +const WIRE_SPACING: Duration = Duration::from_secs(5); +const CLIENT_IS_FLOODING: u64 = 524; +const PERMISSION_DENIED: u64 = 2568; +const ORIGINAL_TOPIC: &str = "QA initial topic"; +const UPDATED_TOPIC: &str = "QA edited topic"; +const CODEC_QUALITY: u64 = 5; +const FAMILY_INHERITED: &str = "channel_flag_maxfamilyclients_inherited"; + +type Result = std::result::Result; + +enum Reply { + Accepted(Value), + Refused(Value), +} + +impl Reply { + fn require(self, cmd: &str) -> Result { + match self { + Self::Accepted(result) => Ok(result), + Self::Refused(refusal) => Err(rejection(cmd, &refusal)), + } + } +} + +fn rejection(cmd: &str, refusal: &Value) -> String { + // IDs are diagnostic; the IPC error message/detail can contain real target data. + if let Some(id) = refusal["ts_error"]["id"].as_u64() { + if id == CLIENT_IS_FLOODING { + return format!("{cmd}: server flood-limited this request (TS {id}); not retried"); + } + return format!("{cmd}: server refused (TS {id})"); + } + let kind = match refusal["code"].as_str() { + Some("bad_request") => "bad_request", + Some("not_connected") => "not_connected", + Some("not_found") => "not_found", + Some("server_error") => "server_error without a TeamSpeak result", + _ => "unexpected IPC error", + }; + format!("{cmd}: {kind}") +} + +struct Core { + child: Child, + input: Option>, + written: mpsc::Receiver, + output: mpsc::Receiver, + sequence: u32, + state: Option<&'static str>, + snapshot: Value, + last_wire: Option, +} + +impl Core { + fn start(exe: &Path, root: &Path) -> Result { + let mut child = Command::new(exe) + .arg("--data-dir").arg(root.join("profile")) + .current_dir(root) + .env("TEAMSPEACH_LOG", "off") + .env("TMP", root).env("TEMP", root).env("TMPDIR", root) + .stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()) + .spawn().map_err(|e| format!("could not start diagnostic core ({:?})", e.kind()))?; + let mut stdin = child.stdin.take().expect("piped stdin"); + let stdout = child.stdout.take().expect("piped stdout"); + let (input, outgoing) = mpsc::sync_channel::(1); + let (ack, written) = mpsc::sync_channel(1); + let (incoming, output) = mpsc::sync_channel(256); + let reader = thread::Builder::new().spawn(move || { + for line in BufReader::new(stdout).lines() { + let Ok(value) = line.and_then(|text| serde_json::from_str(&text).map_err(std::io::Error::other)) else { + break; + }; + if incoming.try_send(value).is_err() { + break; + } + } + }); + let writer = thread::Builder::new().spawn(move || { + while let Ok(line) = outgoing.recv() { + let ok = stdin.write_all(line.as_bytes()).is_ok(); + if ack.send(ok).is_err() || !ok { + break; + } + } + }); + let core = Self { + child, input: Some(input), written, output, sequence: 0, state: None, snapshot: Value::Null, + last_wire: None, + }; + if reader.is_err() || writer.is_err() { + return Err("could not start core pipe workers".into()); + } + let ready = core.read(Instant::now() + CONTROL, "ready")?; + ensure(ready["event"] == "ready" && ready["protocol"] == 1, "expected protocol 1 ready event")?; + Ok(core) + } + + fn read(&self, deadline: Instant, stage: &str) -> Result { + let remaining = deadline.saturating_duration_since(Instant::now()); + if remaining.is_zero() { + return Err(format!("{stage}: deadline exceeded")); + } + self.output.recv_timeout(remaining).map_err(|e| format!("{stage}: core stdout {e}")) + } + + fn request(&mut self, cmd: &str, args: Value, deadline: Instant) -> Result { + self.sequence += 1; + let id = self.sequence.to_string(); + let line = format!("{}\n", json!({"id": id, "cmd": cmd, "args": args})); + if Instant::now() >= deadline + || self.input.as_ref().is_none_or(|input| input.try_send(line).is_err()) + || self.written.recv_timeout(deadline.saturating_duration_since(Instant::now())) != Ok(true) + { + return Err(format!("{cmd}: core stdin write failed or timed out")); + } + loop { + let value = self.read(deadline, cmd)?; + if value["id"].as_str() == Some(id.as_str()) { + return match value["ok"].as_bool() { + Some(true) => Ok(Reply::Accepted(value["result"].clone())), + Some(false) if value["error"].is_object() => Ok(Reply::Refused(value["error"].clone())), + _ => Err(format!("{cmd}: malformed core reply")), + }; + } + self.observe(value); + } + } + + fn observe(&mut self, event: Value) { + match event["event"].as_str() { + Some("snapshot") => self.snapshot = event, + Some("state") => self.state = match event["state"].as_str() { + Some("connecting") => Some("connecting"), + Some("connected") => Some("connected"), + Some("disconnecting") => Some("disconnecting"), + Some("disconnected") => Some("disconnected"), + _ => None, + }, + _ => {} + } + } + + fn call(&mut self, cmd: &str, args: Value) -> Result { + self.request(cmd, args, Instant::now() + CONTROL)?.require(cmd) + } + + fn wire_request(&mut self, cmd: &str, args: Value, timeout: Duration) -> Result { + if let Some(last) = self.last_wire { + thread::sleep((last + WIRE_SPACING).saturating_duration_since(Instant::now())); + } + let reply = self.request(cmd, args, Instant::now() + timeout); + self.last_wire = Some(Instant::now()); + reply + } + + fn wire_call(&mut self, cmd: &str, args: Value) -> Result { + self.wire_request(cmd, args, CONTROL)?.require(cmd) + } + + fn wait_for(&mut self, stage: &str, ready: impl Fn(&Value) -> bool) -> Result<()> { + let deadline = Instant::now() + CONTROL; + while !ready(&self.snapshot) { + let event = self.read(deadline, stage)?; + self.observe(event); + } + Ok(()) + } + + fn leave_and_close(&mut self) -> Result<()> { + // A failed action can still leave us connected. Shutdown runs even if the + // explicit disconnect failed; dropping stdin is the last graceful path. + let leave = if self.state == Some("connected") { + self.call("disconnect", json!({})).and_then(|result| { + ensure(self.state == Some("disconnected") && result["clean"] == true, + "disconnect did not receive server confirmation") + }).map(|()| println!("disconnect: ok (server confirmed)")) + } else { + Ok(()) + }; + let close = self.call("shutdown", json!({})).and_then(|_| { + match self.wait_exit(CONTROL)? { + Some(status) if status.success() => { + println!("shutdown: ok (core exited)"); + Ok(()) + } + _ => Err("core did not exit cleanly by its deadline".into()), + } + }); + combine(leave, close) + } + + fn wait_exit(&mut self, limit: Duration) -> Result> { + let deadline = Instant::now() + limit; + loop { + let status = self.child.try_wait().map_err(|_| "could not query the diagnostic core process")?; + if status.is_some() || Instant::now() >= deadline { + return Ok(status); + } + thread::sleep(Duration::from_millis(10)); + } + } +} + +impl Drop for Core { + fn drop(&mut self) { + drop(self.input.take()); + if !matches!(self.wait_exit(CONTROL), Ok(Some(_))) && self.child.kill().is_ok() { + let _ = self.wait_exit(CONTROL); + } + } +} + +// Only constructed from this run's create result and a verified matching live +// name. No caller-supplied channel ID can reach the edit path, and no delete +// command is sent: the server expires the temporary channel after we leave it. +struct RunChannel<'a> { + id: u64, + name: &'a str, + generation: u64, +} + +impl RunChannel<'_> { + fn row<'a>(&self, rows: &'a [Value]) -> Result<&'a Value> { + let row = rows.iter().find(|row| wire_id(row) == Some(self.id)); + row.filter(|row| row["channel_name"].as_str() == Some(self.name)) + .ok_or_else(|| "the generated channel is not visible with its original name".into()) + } + + fn listed(&self, core: &mut Core, deadline: Instant) -> Result { + let list = core.request("channel_list", json!({}), deadline)?.require("channel_list")?; + Ok(self.row(rows(&list)?)?.clone()) + } + + fn edit(&self, core: &mut Core, generation: u64, properties: Value) -> Result { + let args = self.edit_args(core, generation, properties)?; + core.wire_request("channel_edit", args, CONTROL) + } + + fn edit_args(&self, core: &mut Core, generation: u64, properties: Value) -> Result { + self.listed(core, Instant::now() + CONTROL)?; + self.check_live_generation(core)?; + Ok(json!({"generation": generation, "channel_id": self.id, "properties": properties})) + } + + fn check_live_generation(&self, core: &Core) -> Result<()> { + ensure(core.state == Some("connected") && core.snapshot["generation"].as_u64() == Some(self.generation), + "live connection changed before mutating the generated channel") + } + + fn move_under(&self, core: &mut Core, parent_id: u64) -> Result { + self.listed(core, Instant::now() + CONTROL)?; + self.check_live_generation(core)?; + ensure(valid_parent(&core.snapshot, parent_id), "the original default channel is no longer a valid parent")?; + core.wire_request("channel_move", json!({"generation": self.generation, "channel_id": self.id, "parent_id": parent_id}), CONTROL) + } + + fn info(&self, core: &mut Core) -> Result { + let result = core.wire_call("channel_info", json!({"channel_id": self.id}))?; + let rows = rows(&result)?; + ensure(rows.len() == 1, "channel_info did not return exactly one row")?; + Ok(self.row(rows)?.clone()) + } + + fn observe_row(&self, core: &mut Core, matches: impl Fn(&Value) -> bool) -> Result { + let deadline = Instant::now() + CONTROL; + loop { + let row = self.listed(core, deadline)?; + if matches(&row) || deadline.saturating_duration_since(Instant::now()) <= POLL { + return Ok(row); + } + thread::sleep(POLL); + } + } + + fn wait_fields(&self, core: &mut Core, expected: &[(&str, &str)]) -> Result { + let matches = |row: &Value| expected.iter().all(|(key, value)| row[*key].as_str() == Some(*value)); + let row = self.observe_row(core, matches)?; + ensure(matches(&row), "server acknowledged edit but live properties did not match")?; + Ok(row) + } +} + +fn ensure(condition: bool, message: &str) -> Result<()> { + if condition { Ok(()) } else { Err(message.into()) } +} + +fn combine(first: Result<()>, second: Result<()>) -> Result<()> { + match (first, second) { + (Err(first), Err(second)) => Err(format!("{first}; {second}")), + (first, second) => first.and(second), + } +} + +fn rows(value: &Value) -> Result<&[Value]> { + value["rows"].as_array().map(Vec::as_slice).ok_or_else(|| "missing row list".into()) +} + +fn wire_id(row: &Value) -> Option { + row["cid"].as_str()?.parse().ok() +} + +fn snapshot_channel(snapshot: &Value, id: u64) -> Option<&Value> { + snapshot["channels"].as_array()?.iter().find(|row| row["id"].as_u64() == Some(id)) +} + +fn own_channel(snapshot: &Value, own: u64) -> Option { + if snapshot["own_client_id"].as_u64() != Some(own) { + return None; + } + let channel = snapshot["own_channel_id"].as_u64().filter(|id| *id != 0)?; + snapshot_channel(snapshot, channel)?; + snapshot["clients"].as_array()?.iter() + .any(|client| client["id"].as_u64() == Some(own) && client["channel_id"].as_u64() == Some(channel)) + .then_some(channel) +} + +fn check_topic(stage: &str, row: &Value, expected: &str) -> Result<()> { + let field = row.get("channel_topic"); + let text = field.and_then(Value::as_str); + if text == Some(expected) { + Ok(()) + } else { + Err(format!("{stage}: channel row topic (present={}, string={}, matches=false)", + field.is_some(), text.is_some())) + } +} + +fn check_quality(stage: &str, snapshot: &Value, id: u64, row: &Value) -> Result<()> { + let field = snapshot_channel(snapshot, id).and_then(|channel| channel.get("codec_quality")); + let quality = field.and_then(Value::as_u64); + if quality != Some(CODEC_QUALITY) { + return Err(format!("{stage}: snapshot codec quality (reported={}, integer={}, matches=false)", + field.is_some_and(|value| !value.is_null()), quality.is_some())); + } + // The raw row is sparse; require agreement only when the server reported it there. + if let Some(wire) = row.get("channel_codec_quality") { + let quality = wire.as_str().and_then(|text| text.parse::().ok()); + if quality != Some(CODEC_QUALITY) { + return Err(format!("{stage}: channel row codec quality (present=true, wire_integer={}, matches=false)", + quality.is_some())); + } + } + Ok(()) +} + +fn check_local_refusal(reply: Reply, message: &str, generation: Option) -> Result<()> { + match reply { + Reply::Refused(error) if error["code"] == "bad_request" && error.get("ts_error").is_none() + && error["message"] == message && error["detail"]["generation"].as_u64() == generation => Ok(()), + Reply::Refused(error) => Err(rejection("expected local validation", &error)), + Reply::Accepted(_) => Err("unexpected mutation acknowledgement".into()), + } +} + +fn permission_probe( + core: &mut Core, channel: &RunChannel<'_>, label: &str, props: Value, expected: &[(&str, &str)], +) -> Result> { + let before = channel.listed(core, Instant::now() + CONTROL)?; + match channel.edit(core, channel.generation, props)? { + Reply::Accepted(_) => { + let after = channel.wait_fields(core, expected).map_err(|err| format!("{label}: {err}"))?; + ensure(after["channel_topic"] == before["channel_topic"], "limit edit changed the topic")?; + let changed = expected.iter().any(|(key, _)| key.starts_with("channel_flag_") && before[*key] != after[*key]); + ensure(changed, "limit edit did not exercise a flag change")?; + println!("{label}: ok (server acknowledged, properties read back)"); + Ok(Some(after)) + } + Reply::Refused(error) if permission_denied(&error) => { + let after = channel.listed(core, Instant::now() + CONTROL)?; + ensure(after == before, "permission refusal was followed by a property change")?; + println!("{label}: refused (TS {PERMISSION_DENIED}; properties unchanged)"); + Ok(None) + } + Reply::Refused(error) => Err(rejection(label, &error)), + } +} + +fn permission_denied(error: &Value) -> bool { + error["code"] == "server_error" && error["ts_error"]["id"].as_u64() == Some(PERMISSION_DENIED) +} + +fn report_inherited(label: &str, row: &Value, expected: &str) -> Result<()> { + match row.get(FAMILY_INHERITED) { + Some(value) if value.as_str() == Some(expected) => println!("{label}: ok (inherited flag read back)"), + Some(value) => return Err(format!("{label}: wrong inherited flag (present=true, string={}, matches=false)", + value.is_string())), + None => println!("{label}: unreported (server acknowledged; inherited flag not returned)"), + } + Ok(()) +} + +fn valid_parent(snapshot: &Value, id: u64) -> bool { + snapshot_channel(snapshot, id).is_some_and(|parent| parent["is_default"] == true && parent["channel_type"] == "permanent") +} + +fn probe_inherited(core: &mut Core, channel: &RunChannel<'_>, lobby: u64) -> Result<()> { + const LABEL: &str = "family inheritance under a parent"; + if !valid_parent(&core.snapshot, lobby) { + println!("{LABEL}: unverified (no valid default-channel parent)"); + return Ok(()); + } + // Move only our temporary channel. The default lobby is a parent reference, + // never the target of a write. Its properties and permissions stay untouched. + let before_move = channel.listed(core, Instant::now() + CONTROL)?; + match channel.move_under(core, lobby)? { + Reply::Accepted(_) => core.wait_for("generated channel under the default parent", |s| { + snapshot_channel(s, channel.id).is_some_and(|c| c["parent_id"].as_u64() == Some(lobby)) + })?, + Reply::Refused(error) if permission_denied(&error) => { + ensure(channel.listed(core, Instant::now() + CONTROL)? == before_move, + "refused parent move changed the generated channel")?; + println!("{LABEL}: unverified (parent placement refused, TS {PERMISSION_DENIED}; channel unchanged)"); + return Ok(()); + } + Reply::Refused(error) => return Err(rejection("place generated channel under parent", &error)), + } + let before = channel.listed(core, Instant::now() + CONTROL)?; + if before[FAMILY_INHERITED] == "1" { + println!("{LABEL}: unverified (already inherited after placement; no explicit transition observed)"); + return Ok(()); + } + let properties = json!({"channel_flag_maxfamilyclients_unlimited": false, "channel_flag_maxfamilyclients_inherited": true}); + match channel.edit(core, channel.generation, properties)? { + Reply::Accepted(_) => { + let after = channel.observe_row(core, |row| row[FAMILY_INHERITED] == "1")?; + report_inherited(LABEL, &after, "1") + } + Reply::Refused(error) if permission_denied(&error) => { + ensure(channel.listed(core, Instant::now() + CONTROL)? == before, + "permission refusal was followed by a property change")?; + println!("{LABEL}: refused (TS {PERMISSION_DENIED}; properties unchanged)"); + Ok(()) + } + Reply::Refused(error) => Err(rejection(LABEL, &error)), + } +} + +fn exercise(core: &mut Core, name: &str) -> Result<()> { + let profile = core.call("profile_get", json!({}))?; + ensure(profile["exists"] == false, "expected an empty disposable profile")?; + core.call("profile_create", json!({"nickname": name}))?; + let mute = core.call("set_audio", json!({"input_muted": true, "output_muted": true}))?; + ensure(mute["input_muted"] == true && mute["output_muted"] == true, "both mutes must be active before connect")?; + let connect = core.wire_request("connect", json!({"address": ENDPOINT}), CONNECT)?.require("connect")?; + let own = connect["own_client_id"].as_u64().filter(|id| *id != 0).ok_or("connect did not return an own client ID")?; + ensure(core.state == Some("connected"), "core did not reach connected state")?; + // Connect can be acknowledged before the own client and channel enter the book. + core.wait_for("initial channel and own-client roster", |s| own_channel(s, own).is_some())?; + let snapshot = &core.snapshot; + let generation = snapshot["generation"].as_u64().filter(|g| *g != 0).ok_or("connected snapshot has no generation")?; + let lobby = own_channel(snapshot, own).ok_or("missing initial channel")?; + let beta14 = snapshot["server"]["version"].as_str().is_some_and(|s| { + s.starts_with("6.") && s.split(|c: char| !c.is_ascii_alphanumeric()).any(|part| part.eq_ignore_ascii_case("beta14")) + }); + ensure(beta14, "loopback endpoint did not report TS6 beta14")?; + ensure(snapshot_channel(snapshot, lobby).is_some_and(|c| c["is_default"] == true), "session did not start in the fixture's default channel")?; + ensure(snapshot["clients"].as_array().is_some_and(|clients| { + clients.len() == 1 && clients[0]["id"].as_u64() == Some(own) + && clients[0]["client_type"] == "normal" && clients[0]["input_muted"] == true && clients[0]["output_muted"] == true + }), "connected snapshot did not show only the muted fixture client")?; + println!("connect: ok (loopback beta14; disposable guest; both mutes active)"); + + let server = core.wire_call("server_info", json!({}))?; + let server_rows = rows(&server)?; + ensure(server_rows.len() == 1 && server_rows[0].as_object().is_some_and(|row| !row.is_empty()), + "server_info did not return observed server properties")?; + println!("server_info: ok (read only)"); + + let list = core.call("channel_list", json!({}))?; + let existing = rows(&list)?; + ensure(existing.iter().any(|row| wire_id(row) == Some(lobby)) + && existing.iter().all(|row| wire_id(row).is_some() && row["channel_name"].as_str() != Some(name)), + "initial channel list cannot establish a unique writable target")?; + println!("channel_list: ok (baseline read only)"); + + let create = core.wire_call("channel_create", json!({"generation": generation, "parent_id": 0, "properties": { + "channel_name": name, "channel_topic": ORIGINAL_TOPIC, "channel_codec_quality": CODEC_QUALITY, + }}))?; + let id = create["channel_id"].as_u64().filter(|id| *id != 0 && existing.iter().all(|row| wire_id(row) != Some(*id))) + .ok_or("create did not return a newly generated channel ID")?; + let channel = RunChannel { id, name, generation }; + core.wait_for("temporary channel and own-client roster", |s| { + snapshot_channel(s, id).is_some() && own_channel(s, own).is_some() + })?; + ensure(snapshot_channel(&core.snapshot, id).is_some_and(|c| c["channel_type"] == "temporary" && c["parent_id"] == 0 + && c["name"].as_str() == Some(name)), "created channel was not the generated root temporary channel")?; + if own_channel(&core.snapshot, own) != Some(id) { + core.wire_call("join_channel", json!({"channel_id": id}))?; + core.wait_for("enter generated channel", |s| own_channel(s, own) == Some(id))?; + } + let original = channel.info(core)?; + check_topic("create", &original, ORIGINAL_TOPIC)?; + check_quality("create", &core.snapshot, id, &original)?; + println!("channel_create + channel_info: ok (own root temporary channel, topic and codec quality read back)"); + + channel.edit(core, generation, json!({"channel_topic": UPDATED_TOPIC}))?.require("sparse channel_edit")?; + let edited = channel.wait_fields(core, &[("channel_topic", UPDATED_TOPIC)])?; + core.wait_for("edited channel snapshot", |s| snapshot_channel(s, id).is_some_and(|c| c["topic"] == UPDATED_TOPIC))?; + check_topic("sparse edit", &edited, UPDATED_TOPIC)?; + check_quality("sparse edit", &core.snapshot, id, &edited)?; + println!("sparse channel_edit: ok (topic changed; name and codec quality preserved)"); + + for (label, attempt, props, message, live_generation) in [ + ("invalid codec quality", generation, json!({"channel_topic": "invalid quality marker", "channel_codec_quality": 11}), + "channel_codec_quality must be an integer 0..=10", None), + ("stale generation", generation.checked_add(1).ok_or("connection generation exhausted")?, + json!({"channel_topic": "stale generation marker"}), "connection changed; reload and confirm again", Some(generation)), + ] { + // These two requests must be rejected locally without reaching the server. + let args = channel.edit_args(core, attempt, props)?; + check_local_refusal(core.request("channel_edit", args, Instant::now() + CONTROL)?, message, live_generation) + .map_err(|err| format!("{label}: {err}"))?; + let after = channel.listed(core, Instant::now() + CONTROL)?; + ensure(after == edited, "rejected edit changed live channel properties")?; + check_quality(label, &core.snapshot, id, &after)?; + println!("{label}: rejected (local bad_request; properties unchanged)"); + } + + let finite_clients = [("channel_maxclients", "3"), ("channel_flag_maxclients_unlimited", "0")]; + let unlimited_clients = [("channel_maxclients", "-1"), ("channel_flag_maxclients_unlimited", "1")]; + let (props, expected) = if edited["channel_flag_maxclients_unlimited"] == "0" { + (json!({"channel_maxclients": -1, "channel_flag_maxclients_unlimited": true}), &unlimited_clients) + } else { + (json!({"channel_maxclients": 3, "channel_flag_maxclients_unlimited": false}), &finite_clients) + }; + let max_clients = permission_probe(core, &channel, "maximum clients / unlimited flag", props, expected)?; + let (family_limit, unlimited, wire_limit, wire_unlimited) = if edited["channel_flag_maxfamilyclients_unlimited"] == "0" + && edited["channel_flag_maxfamilyclients_inherited"] == "0" { + (-1, true, "-1", "1") + } else { + (4, false, "4", "0") + }; + let family = permission_probe(core, &channel, "family limit / unlimited flag", + json!({"channel_maxfamilyclients": family_limit, "channel_flag_maxfamilyclients_unlimited": unlimited, + "channel_flag_maxfamilyclients_inherited": false}), + &[("channel_maxfamilyclients", wire_limit), ("channel_flag_maxfamilyclients_unlimited", wire_unlimited)])?; + let written = max_clients.is_some() as usize + family.is_some() as usize; + println!("limit flag cases: {written} written and read back, {} refused", 2 - written); + if let Some(row) = family { + report_inherited("root family inheritance disabled", &row, "0")?; + probe_inherited(core, &channel, lobby)?; + } else { + println!("family inheritance: unverified (family-limit baseline refused)"); + } + + // Join the original default as this same client; never edit it or issue a + // delete verb. Only the generated temporary channel is expected to expire. + core.wire_call("join_channel", json!({"channel_id": lobby}))?; + core.wait_for("leave generated channel and observe its expiry", |s| { + own_channel(s, own) == Some(lobby) && snapshot_channel(s, id).is_none() + })?; + println!("temporary channel cleanup: ok (left channel; server expired it)"); + Ok(()) +} + +fn run() -> Result<()> { + ensure(std::env::args_os().nth(1).is_none(), "this example takes no arguments")?; + let exe = std::env::var_os("TEAMSPEACH_QA_CORE").map(PathBuf::from) + .filter(|path| path.is_absolute() && path.is_file() && path.file_name().and_then(|n| n.to_str()) + .is_some_and(|n| n.eq_ignore_ascii_case("teamspeach-core.exe"))) + .ok_or("set TEAMSPEACH_QA_CORE to the absolute path of a disposable teamspeach-core.exe")?; + let stamp = SystemTime::now().duration_since(UNIX_EPOCH).map_err(|_| "invalid system clock")?.as_nanos(); + let name = format!("PeachQA-{:x}-{stamp:x}", std::process::id()); + let root = std::env::temp_dir().join(&name); + ensure(root.is_absolute(), "system temporary directory must be absolute")?; + fs::create_dir(&root).map_err(|_| "could not create unique scratch directory")?; + let result = (|| { + let mut core = Core::start(&exe, &root)?; + let cases = exercise(&mut core, &name); + let cleanup = core.leave_and_close(); + combine(cases, cleanup) + })(); + let profile = fs::remove_dir_all(&root).map_err(|_| "could not remove scratch profile".into()); + if profile.is_ok() { + println!("scratch profile cleanup: ok"); + } + combine(result, profile) +} + +fn main() -> ExitCode { + match run() { + Ok(()) => ExitCode::SUCCESS, + Err(error) => { + eprintln!("channel admin QA failed: {error}"); + ExitCode::FAILURE + } + } +} diff --git a/docs/bridge.md b/docs/bridge.md index e9c5c7c..9764d3b 100644 --- a/docs/bridge.md +++ b/docs/bridge.md @@ -657,6 +657,8 @@ Every mutation below is answered only after its real server command result. Perm `admin_context {}` returns `{generation,server_uid,own_client_id,catalog_received,permissions,permissions_catalog,permission_error?}`. Permissions are the official named hint values (null if unknown); catalog entries are `{id,name,description}`. +For an isolated Windows beta14 fixture at `127.0.0.1:19987`, set `TEAMSPEACH_QA_CORE` to the absolute diagnostic core executable and run `cargo run --locked -p teamspeach-core --example channel_admin_qa`. It checks a newly created temporary channel, edit acknowledgements and independent readbacks. A missing wire property is unreported, not false. A server permission refusal is reported separately from an accepted write. + | Command | Arguments / result | |---|---| | `channel_create` | `{generation,parent_id,properties}` → `{channel_id}` from own channel-created event | diff --git a/docs/mobile-port-progress.md b/docs/mobile-port-progress.md index 1a77f60..bd65ce6 100644 --- a/docs/mobile-port-progress.md +++ b/docs/mobile-port-progress.md @@ -46,6 +46,7 @@ 718 требований в `native/compatibility.json` не менялись. - Последующая Windows release-сборка (`xtask build`, Skia + WebRTC) успешно слинкована; запуск `teamspeach.exe --version` вернул `TeamsPeach 0.1.7 (Rust + Slint)`. Это сборка из рабочего дерева, не установка или приёмка на физической гарнитуре. - В `target/evidence/pc5232-identity-cancel-02/result.json` проверены создание, выбор по UID при одинаковых именах, сохранение ключа, уровня, закладки и ника после перезапуска, отказ удаления используемой идентичности и отмена экспорта из меню указателем и клавиатурой. Отмена активного поиска подтверждена за 172 мс и за 180 мс после перезапуска; второй поиск продолжился с контрольной точки первого. Отдельно прошли `about_workflows` и `bookmark_contact_workflows` (3 теста). Это не подтверждение экспорта через системный диалог, изменения ника на сервере или визуального паритета. +- Административные формы: 9 адресных Windows-тестов (`admin_editor_`, `server_edit_`, `channel_admin_tests`) прошли. `channel_admin_qa` с отдельным beta14 подтвердил создание временного канала, смену темы без изменения имени/качества кодека, отказ по неверному качеству и старому поколению, чтение обычного и семейного лимита. `channel_flag_maxfamilyclients_inherited` у корневого канала не прислан; перенос под родителя гостю запрещён (TS 2568). Канал исчез после выхода; сервер подтвердил отключение. Рабочий сервер не менялся. - Отдельно два CLI-клиента ядра через изолированный официальный beta 14 одновременно передали по 100 кадров с тонами 500/900 Гц: 99/101 и 100/101 декодированных кадров совпали по спектру и идентификатору отправителя; оба клиента отключились штатно. Реальных устройств и официального клиента