From 87cfa592521bc2c64397b7f1519f5e71468c479b Mon Sep 17 00:00:00 2001 From: omar Date: Sat, 28 Nov 2026 10:04:25 +0300 Subject: [PATCH] test: verify live beta14 channel banner fetch Reject zero channel IDs at the fetch_banner command boundary. Verify exact classic download bytes and rendered Slint row pixels, permission refusal, missing-file fallback and stale-reference rejection on disposable loopback beta14. --- FEATURE_COMPATIBILITY.md | 2 + core/src/protocol.rs | 14 ++ .../channel-fetch-banner-beta14.md | 32 ++++ docs/mobile-port-progress.md | 2 + native/src/app/runtime/channel_banners.rs | 9 +- native/src/app/runtime/context.rs | 2 + native/src/app/runtime/mod.rs | 1 + native/src/smoke/channel_banners.rs | 12 +- native/src/smoke/channel_banners_live.rs | 152 ++++++++++++++++++ native/tests/fixtures/beta14-server-admin.ps1 | 42 ++++- native/tests/fixtures/channel-banner.png.b64 | 1 + 11 files changed, 261 insertions(+), 8 deletions(-) create mode 100644 docs/evidence/official-parity/channel-fetch-banner-beta14.md create mode 100644 native/src/smoke/channel_banners_live.rs create mode 100644 native/tests/fixtures/channel-banner.png.b64 diff --git a/FEATURE_COMPATIBILITY.md b/FEATURE_COMPATIBILITY.md index 84f6a39..7f19d51 100644 --- a/FEATURE_COMPATIBILITY.md +++ b/FEATURE_COMPATIBILITY.md @@ -2,6 +2,8 @@ ## Current Windows account-free checkpoint (2026-11-26) +**Channel banner fetch (Windows):** On private classic beta14, `fetch_banner` returned the exact seeded 74-byte PNG and Slint painted its color inside the selected channel row. A restricted channel with the same file returned `PermissionsClientInsufficient`. Replacing the banner with a missing file cleared the artwork without changing the neighboring row or selection outline; the former banner token was rejected. An HTTPS reference produced no tree fetch action. Raw command validation also rejects zero and unknown fields. See the [live receipt](docs/evidence/official-parity/channel-fetch-banner-beta14.md) for scope and reproduction. + **Server host button (Windows):** On private beta14, the Slint editor rejected 1,025 ASCII characters in each of the tooltip, link URL, and image URL fields. Cancel preserved the seeded values. A second guest independently verified three single-field saves, a combined save, and exact restoration; fresh editors showed the acknowledged values. The 1,024-character editor limit is not a measured server limit. The `.invalid` URLs were never opened or downloaded. See the [host button receipt](docs/evidence/official-parity/server-host-button-beta14.md). **Server host banner (Windows):** On private beta14, Slint rejected oversized URLs, invalid interval and mode values, and a wrong server-name confirmation. Cancel preserved both seeded URLs, interval 120, and mode 0. Each of the four controls saved alone, then all four saved together, and the original values were restored. A second guest independently read all four fields after each step, and fresh editors showed the acknowledged values. The URLs used `.invalid`; no browser or image fetch, rendering, or refresh timing was tested. See the [banner receipt](docs/evidence/official-parity/server-host-banner-beta14.md). diff --git a/core/src/protocol.rs b/core/src/protocol.rs index 3f2d0b9..6ed5a95 100644 --- a/core/src/protocol.rs +++ b/core/src/protocol.rs @@ -717,6 +717,7 @@ pub fn validate_command(mut command: Command) -> Result check_stream_id(stream_id)?, Command::FetchIcon { icon_id: 0 } => return Err(bad("icon_id 0 means no icon")), + Command::FetchBanner { channel_id: 0 } => return Err(bad("channel_id must be positive")), Command::ClientContext(a) => crate::menu::validate_target(a)?, Command::ClientAction(a) => crate::menu::validate_action(a)?, Command::Admin(a) => crate::admin::validate(a)?, @@ -800,6 +801,19 @@ mod tests { } } + #[test] + fn fetch_banner_requires_only_a_positive_channel_id() { + let parse = |args: &str| parse_line(&format!(r#"{{"id":"banner","cmd":"fetch_banner","args":{args}}}"#)); + assert!(matches!(parse(r#"{"channel_id":7}"#), Input::Request { + cmd: ValidatedCommand(Command::FetchBanner { channel_id: 7 }), .. + })); + for bad in [r#"{}"#, r#"{"channel_id":0}"#, r#"{"channel_id":-1}"#, r#"{"channel_id":1.5}"#, + r#"{"channel_id":"7"}"#, r#"{"channel_id":7,"url":"https://banner.invalid/"}"#] { + assert!(matches!(parse(bad), Input::Invalid { error, .. } if error.code == ErrorCode::BadRequest), "{bad}"); + } + assert_eq!(validate_command(Command::FetchBanner { channel_id: 0 }).unwrap_err().code, ErrorCode::BadRequest); + } + #[test] fn requests_need_valid_id_and_known_args() { assert!(matches!( diff --git a/docs/evidence/official-parity/channel-fetch-banner-beta14.md b/docs/evidence/official-parity/channel-fetch-banner-beta14.md new file mode 100644 index 0000000..397e1cf --- /dev/null +++ b/docs/evidence/official-parity/channel-fetch-banner-beta14.md @@ -0,0 +1,32 @@ +# Windows beta14 `command:fetch_banner` receipt + +Base: `b370474999` on `work/integration-verified`. The compatibility entry requires a positive channel ID, rejection of unknown fields, server-authorized fetching, selected-channel artwork, and a fallback on missing or failed artwork without opening arbitrary URLs. + +**Pass on private classic beta14.** The runner seeded an 8 x 2 PNG in disposable classic storage and advertised a `ts3image://` reference on the scratch channel. A real native guest retrieved the exact 74 bytes, MIME `image/png`, SHA-256 `fbedfd286063b8b7ad2108d4c6b67107330671d3b8fa88a89bfb2a94b6aa92bc`. The selected channel row painted RGB `[213, 37, 107]`; its neighbor stayed `[27, 35, 54]` and the selection outline stayed `[21, 136, 250]`. + +- The same PNG in a restricted channel returned beta14's `PermissionsClientInsufficient`; the fixture did not override that restriction. +- A channel without a banner returned `not_found`. A missing file returned beta14's `FileNotFound`. Changing the reference removed the old image without changing the adjacent row or selection outline, and replaying the former token did not restore it. +- An advertised `.invalid` HTTPS URL did not produce a Slint tree fetch action. Calling the core returned `external_media`. The runtime was isolated with public network services and OS actions disabled; the test-only switch enabled the real banner request on the fixed loopback session. No HTTP or browser navigation was used. +- The parser test accepted a positive channel ID and rejected a missing, zero, negative, fractional, or string ID and an extra `url` field. The live test also rejected a typed zero ID as `bad_request`. + +The live test passed in 34.59 s (1 passed, 824 filtered out); the core parser test passed (1 passed, 261 filtered out). The runner stopped the server and removed its private runtime. The post-run check found zero listeners on UDP 19987 and TCP 30053/19080 and zero matching private runtime directories. Local logs: `target/fetch-banner-live-3.log`, `target/fetch-banner-protocol.log`. Screenshots: `target/fetch-banner-live/fetch-banner-live.png` and `target/fetch-banner-live/fetch-banner-missing.png`. + +This receipt covers only `command:fetch_banner` on Windows classic beta14. It does not claim a `command:fetch_server_banner` or `preference:showChannelBanners` pass, HTTP image fetching, a cross-session or late in-flight network response test, or S3/HTTPFT parity. The stale case here is a token for a live channel whose advertised reference was replaced. Compatibility status entries were left unchanged. + +## Reproduce + +Use a staged Windows beta14 release and pinned WebRTC. Keep UDP 19987 and TCP 30053/19080 free. The runner uses private temporary state and an ephemeral bootstrap key; Query is off while the client test runs. + +```powershell +$env:TEAMSPEACH_BETA14_RELEASE = 'C:/path/to/staged/beta14/release' +$env:LK_CUSTOM_WEBRTC = 'C:/path/to/pinned/webrtc' +$env:CARGO_TARGET_DIR = Join-Path $PWD 'target' +$env:TEAMSPEACH_CHANNEL_BANNER_EVIDENCE = Join-Path $PWD 'target/fetch-banner-live' +$runner = (Resolve-Path 'native/tests/fixtures/beta14-server-admin.ps1').Path +$env:CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER = "powershell.exe -NoProfile -ExecutionPolicy Bypass -File $runner" +cargo test --offline --locked --target x86_64-pc-windows-msvc -p teamspeach-native --no-default-features --features webrtc,test-harness --lib -- --include-ignored --test-threads=1 --nocapture --exact smoke::channel_banners::live::fetch_banner_renders_classic_beta14_channel_row +Remove-Item Env:CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER +cargo test --offline --locked --target x86_64-pc-windows-msvc -p teamspeach-core --lib protocol::tests::fetch_banner_requires_only_a_positive_channel_id -- --exact +``` + +Use a worktree path without spaces for the Cargo runner variable. diff --git a/docs/mobile-port-progress.md b/docs/mobile-port-progress.md index e2ff7a4..e7e8218 100644 --- a/docs/mobile-port-progress.md +++ b/docs/mobile-port-progress.md @@ -15,6 +15,8 @@ - `8a5afa2814` интегрирован слиянием `e94e6c770f`: регистрация точного теста Host Button подтверждена, один автономный тест ожидания подтверждения в Slint прошёл. Живой beta14 не запускался повторно; [исходный прогон и проверки интеграции](evidence/official-parity/server-host-button-beta14.md) записаны отдельно. +- На базе `b370474999` проверен `command:fetch_banner`: приватный classic beta14 выдал точные 74 байта PNG, а Slint нарисовал цвет в выбранной строке канала. Сервер отказал гостю без права скачивания. При отсутствующем файле изображение исчезло; старый токен отклонён, HTTPS-адрес не стал действием дерева. Проверки живого пути и аргументов прошли; стенд снят. [Снимки, границы и команды](evidence/official-parity/channel-fetch-banner-beta14.md). + - Из `302ba80958` на базе `c4fe77d128` перенесены только изменения баннеров каналов. При совмещении остались ветви флагов стран, лампы командира, фон без изображения, редактор кнопки сервера и выбор источника захвата. Один адресный прогон под Windows с `webrtc,test-harness` дал **7 passed, 0 failed, 817 filtered out** (83.78 с). Журнал: `target/channel-banner-integration/test.log`, снимки: `target/channel-banner-integration/{en,ru}-{dark,light}-*.png`. Тест подал настоящие PNG через автономную тестовую границу транспорта: штатный декодер и дерево Slint подтвердили замену, очистку, сохранение видимости, отказ записи и отбрасывание позднего результата. Живой сервер, передача файлов, HTTP(S)-баннеры и физический захват не проверялись. Тест редактора проверял сохранение черновика до совпадающего подтверждения, а не живой Host Button. Для повторения из worktree интеграции: активировать MSVC и закреплённый WebRTC через `target/tools/build-native.cmd` исходной копии (только чтение), выставить `CARGO_TARGET_DIR` на `target/` worktree, `TEMP` и `TMP` на локальный временный каталог, `TEAMSPEACH_CHANNEL_BANNER_EVIDENCE` на свежий локальный каталог снимков, `CARGO_PROFILE_DEV_DEBUG=0`, `CARGO_PROFILE_TEST_DEBUG=0` и `CARGO_INCREMENTAL=0`. Точные аргументы Cargo для одного прогона: diff --git a/native/src/app/runtime/channel_banners.rs b/native/src/app/runtime/channel_banners.rs index e40a784..0cfc31e 100644 --- a/native/src/app/runtime/channel_banners.rs +++ b/native/src/app/runtime/channel_banners.rs @@ -111,7 +111,14 @@ async fn load(ctx: &RuntimeServices, source: &Source) -> Option { // channel's announced ts3image reference against its own current server and port. parse_ts3image(&source.reference, None).ok()?; if !source.current(&ctx.connected.connections.snapshot()) { return None; } - let reply = if ctx.network_enabled { + #[cfg(all(test, windows))] + let loopback_fixture = ctx.fixture_live_channel_banners.load(std::sync::atomic::Ordering::Acquire) + && !ctx.policy.allow_os_actions + && ctx.connected.connections.snapshot().get(&source.key.connection_id) + .is_some_and(|tab| tab.key == source.key && tab.address == "127.0.0.1:19987"); + #[cfg(not(all(test, windows)))] + let loopback_fixture = false; + let reply = if ctx.network_enabled || loopback_fixture { ctx.request(&source.key, Command::FetchBanner { channel_id: source.channel }).await.ok()? } else { #[cfg(test)] diff --git a/native/src/app/runtime/context.rs b/native/src/app/runtime/context.rs index e20c2f9..3f3fafa 100644 --- a/native/src/app/runtime/context.rs +++ b/native/src/app/runtime/context.rs @@ -100,6 +100,8 @@ pub struct RuntimeServices { pub network_enabled:bool, #[cfg(test)] pub(crate) fixture_channel_banners: Mutex)>>, + #[cfg(all(test, windows))] + pub(crate) fixture_live_channel_banners: AtomicBool, #[cfg(test)] pub(crate) fixture_channel_banner_completions: std::sync::atomic::AtomicUsize, pub version:&'static str, diff --git a/native/src/app/runtime/mod.rs b/native/src/app/runtime/mod.rs index fc32d1a..a7fc895 100644 --- a/native/src/app/runtime/mod.rs +++ b/native/src/app/runtime/mod.rs @@ -92,6 +92,7 @@ async fn construct(config:&AppConfig,profile:ProfileServices,runtime:Weak Value { let mut bytes = Vec::new(); PngEncoder::new(&mut bytes).write_image(&color.repeat(1600 * 400), 1600, 400, image::ExtendedColorType::Rgb8).unwrap(); @@ -32,10 +36,14 @@ fn roster(key: &SessionKey, reference: Option<&str>) -> Value { } fn paint(ui: &AppWindow) -> SmokeResult<[[u8; 3]; 3]> { + paint_rows(ui, "Lobby", "Control room") +} + +fn paint_rows(ui: &AppWindow, selected: &str, control: &str) -> SmokeResult<[[u8; 3]; 3]> { let pixels = ui.window().take_snapshot().map_err(|e| e.to_string())?; let sample = |label, dy| -> SmokeResult<[u8; 3]> { let item = focus::visible_selector(ui, label, AccessibleRole::ListItem)?; - if label == "Lobby" { + if label == selected { assert_eq!(item.accessible_string_property(Prop::ItemSelected).unwrap().as_str(), "true"); } let rect = headless::visible_bounds(ui.window(), &item).ok_or("tree row is not rendered")?; @@ -45,7 +53,7 @@ fn paint(ui: &AppWindow) -> SmokeResult<[[u8; 3]; 3]> { let offset = 4 * (y * pixels.width() as usize + x); pixels.as_bytes().get(offset..offset+3).ok_or("tree samples outside viewport")?.try_into().map_err(|_| "missing pixel".into()) }; - Ok([sample("Lobby",22.)?, sample("Control room",22.)?, sample("Lobby",7.)?]) + Ok([sample(selected,22.)?, sample(control,22.)?, sample(selected,7.)?]) } async fn expect(ui: &AppWindow, point: &str, fill: [u8;3], outline: [u8;3], output: Option<&std::path::Path>) -> SmokeResult<()> { diff --git a/native/src/smoke/channel_banners_live.rs b/native/src/smoke/channel_banners_live.rs new file mode 100644 index 0000000..c3412b6 --- /dev/null +++ b/native/src/smoke/channel_banners_live.rs @@ -0,0 +1,152 @@ +use super::{AppConfig, AppRuntime, AppWindow, ComponentHandle, PhysicalSize, ProfileServices, RED_RGB, + SmokeResult, Source, STANDARD, focus, headless, initialize_native_root, json, paint_rows, run_ui, screenshot, until}; +use crate::{ShellBridge, app::{connections::{ConnectionState, SessionKey}, runtime::context::RuntimeServices}, + smoke::tabs::pace_beta14, services::ServiceError}; +use base64::Engine; +use i_slint_core::{accessibility::AccessibleStringProperty as Prop, items::AccessibleRole}; +use serde_json::Value; +use sha2::{Digest, Sha256}; +use slint::Model; +use std::{path::PathBuf, sync::atomic::Ordering}; +use teamspeach_core::{admin::{AdminCommand, Properties}, protocol::{Command, ConnectArgs}}; + +const FIXTURE: &str = "TeamsPeach Fetch Banner QA Fixture"; +const ART: &str = "Banner Artwork QA"; +const DENIED: &str = "Banner Refused QA"; +const CONTROL: &str = "Banner Control QA"; +const ADDRESS: &str = "127.0.0.1:19987"; +const EXTERNAL: &str = "https://banner.invalid/never-open.png"; +const PNG: &str = include_str!("../../tests/fixtures/channel-banner.png.b64"); + +#[test] +#[ignore = "requires exclusive classic loopback beta14 from native/tests/fixtures/beta14-server-admin.ps1"] +fn fetch_banner_renders_classic_beta14_channel_row() { + if !headless::install_for_test() { return; } + let temporary = tempfile::tempdir().unwrap(); + let root = temporary.path().join("profile"); + initialize_native_root(&root).unwrap(); + let identity = { + let mut profile = ProfileServices::open(&root).unwrap(); + profile.prefs.set(json!({"language":"en","theme":"dark","showChannelBackground":true,"showChannelBanners":true})).unwrap(); + profile.identities.onboard("Fetch Banner QA").unwrap()["uid"].as_str().unwrap().to_owned() + }; + run_ui(&AppConfig::isolated(root), async move |runtime, ui| { + ui.show().map_err(|e| e.to_string())?; + ui.window().set_size(PhysicalSize::new(1280, 1100)); + until("private profile is ready", || runtime.snapshot().settings.loaded).await?; + let owner = runtime.services.lock().unwrap().upgrade().ok_or("runtime closed")?; + assert!(!owner.network_enabled && !owner.policy.allow_os_actions); + let manager = &owner.connected.connections; + let idle = manager.key("c1").await.map_err(|e| e.to_string())?; + owner.fixture_live_channel_banners.store(true, Ordering::Release); + manager.request(&idle, Command::SetAudio { input_muted: Some(true), output_muted: Some(true) }).await.map_err(|e| e.to_string())?; + // Only this private test opens a socket while public services are disabled. + manager.request(&idle, Command::Connect(ConnectArgs { + address: ADDRESS.into(), identity_id: Some(identity), nickname: None, channel: None, + server_password: None, channel_password: None, + })).await.map_err(|e| e.to_string())?; + let key = manager.key("c1").await.map_err(|e| e.to_string())?; + let exercise = exercise(runtime, ui, &owner, &key).await; + pace_beta14().await?; + let disconnected = async { + manager.request(&key, Command::Disconnect { message: None }).await.map_err(|e| e.to_string())?; + until("fixture connection disconnected", || { + runtime.snapshot().connections.get(&key.connection_id).is_some_and(|tab| tab.state == ConnectionState::Disconnected) + }).await + }.await; + exercise.and(disconnected) + }).unwrap(); +} + +async fn exercise(runtime: &AppRuntime, ui: &AppWindow, owner: &RuntimeServices, key: &SessionKey) -> SmokeResult<()> { + let snapshot = || runtime.snapshot().connections.get(&key.connection_id).filter(|tab| tab.key == *key).and_then(|tab| tab.server.clone()); + let channel = |name| snapshot().and_then(|server| { + (server["server"]["name"] == FIXTURE && server["server"]["version"].as_str().is_some_and(|s| s.contains("beta14"))) + .then_some(())?; + server["channels"].as_array()?.iter().find(|row| row["name"] == name)?.get("id")?.as_u64() + }); + let row = |title| focus::visible_selector(ui, title, AccessibleRole::ListItem); + until("three real fixture rows", || [ART, DENIED, CONTROL].into_iter().all(|name| channel(name).is_some() && row(name).is_ok())).await?; + let (id, denied_id, no_banner) = (channel(ART).unwrap(), channel(DENIED).unwrap(), channel(CONTROL).unwrap()); + let shell = ui.global::(); + let row_id = format!("tree/channel:{id}"); + let banner_row = || shell.get_tree().iter().find(|entry| entry.id == row_id); + let reference = format!("ts3image://127.0.0.1?port=19987&channel={id}&path=/&filename=banner.png"); + focus::activate(row(ART)?)?; + until("artwork row selected", || row(ART).is_ok_and(|item| item.accessible_string_property(Prop::ItemSelected).is_some_and(|v| v == "true"))).await?; + + let initial = banner_row().ok_or("missing projected banner row")?; + let token = initial.banner_request; + if !Source::from_token(&runtime.snapshot().connections, token.as_str()).is_some_and(|source| source.reference.as_ref() == reference && source.channel == id) { + return Err(format!("banner did not retain the exact advertised source and channel: {token:?}")); + } + + let fetch = |channel_id| owner.request(key, Command::FetchBanner { channel_id }); + require_error(fetch(0).await, |err| err.code == "bad_request", "zero channel ID")?; + require_error(fetch(no_banner).await, |err| err.code == "not_found", "channel with no banner")?; + pace_beta14().await?; + let response = fetch(id).await.map_err(|e| format!("classic fetch_banner failed: {} ({})", e.message, e.code))?; + let expected = STANDARD.decode(PNG.trim()).map_err(|e| e.to_string())?; + let actual = response["data"].as_str().ok_or("missing banner data").and_then(|base64| STANDARD.decode(base64).map_err(|_| "invalid banner Base64"))?; + if actual != expected || response["bytes"] != actual.len() || response["mime"] != "image/png" { + return Err("classic fetch_banner did not return the exact seeded PNG and metadata".into()); + } + println!("fetch_banner: channel {id}, {} bytes, SHA-256 {}", actual.len(), base16ct::lower::encode_string(&Sha256::digest(&actual))); + let mut observed = None; + until("Slint paints the live artwork in the selected channel row", || { + observed = paint_rows(ui, ART, CONTROL).ok(); + observed.is_some_and(|pixels| pixels[0] == RED_RGB && pixels[1] != RED_RGB) + }).await.map_err(|err| format!("{err}; sampled {observed:?}; decoded assets={}", runtime.snapshot().channel_banners.len()))?; + let pixels = observed.unwrap(); + let output = std::env::var_os("TEAMSPEACH_CHANNEL_BANNER_EVIDENCE").map(PathBuf::from); + if let Some(dir) = &output { + std::fs::create_dir_all(dir).map_err(|e| e.to_string())?; + screenshot(ui, dir, "fetch-banner-live.png")?; + } + println!("live Slint fill, neighboring fill, and outline pixels: {pixels:?}"); + + pace_beta14().await?; + require_error(fetch(denied_id).await, |err| err.code == "server_error" && err.message.contains("PermissionsClientInsufficient"), "channel download permission")?; + let change = async |value: &str| -> SmokeResult<()> { + pace_beta14().await?; + let properties = Properties::channel_edit(serde_json::Map::from_iter([("channel_banner_gfx_url".into(), json!(value))])) + .map_err(|e| e.message)?; + owner.request(key, Command::Admin(AdminCommand::ChannelEdit { generation: key.generation, channel_id: id, properties })) + .await.map_err(|e| format!("changing scratch banner reference: {}", e.message))?; + until("authoritative replacement reference and cleared artwork", || { + let current = snapshot(); + let advertised = current.as_ref().and_then(|server| server["channels"].as_array()).and_then(|channels| { + channels.iter().find(|row| row["id"] == id) + }); + advertised.is_some_and(|row| row["banner_url"] == value) && banner_row().is_some_and(|r| r.banner.size().width == 0) + && paint_rows(ui, ART, CONTROL).is_ok_and(|[fill, control, outline]| fill != RED_RGB && control == pixels[1] && outline == pixels[2]) + }).await + }; + let missing = reference.replace("filename=banner.png", "filename=missing.png"); + change(&missing).await?; + if Source::from_token(&runtime.snapshot().connections, token.as_str()).is_some() { + return Err("former live banner token was accepted after the server changed the reference".into()); + } + shell.invoke_request_channel_banner(token); + pace_beta14().await?; + require_error(fetch(id).await, |err| err.code == "server_error" && err.message.contains("FileNotFound"), "missing banner file")?; + if paint_rows(ui, ART, CONTROL)?[0] == RED_RGB { return Err("old pixels returned after the stale token and missing file".into()); } + if let Some(dir) = &output { screenshot(ui, dir, "fetch-banner-missing.png")?; } + + change(EXTERNAL).await?; + if banner_row().is_none_or(|r| !r.banner_request.is_empty()) { return Err("external reference became a Slint fetch action".into()); } + require_error(fetch(id).await, |err| err.code == "external_media", "external banner reference")?; + let final_state = runtime.snapshot(); + if !final_state.channel_banners.is_empty() || final_state.audio_input_starts != 0 || final_state.audio_output_starts != 0 { + return Err("failed banner left an asset or started an audio device".into()); + } + Ok(()) +} + +fn require_error(result: Result, matches: impl FnOnce(&ServiceError) -> bool, label: &str) -> SmokeResult<()> { + match result { + Ok(_) => Err(format!("{label} unexpectedly returned data")), + Err(err) if matches(&err) => { println!("{label}: {} ({})", err.message, err.code); Ok(()) } + Err(err) => Err(format!("unexpected {label} response: {} ({})", err.message, err.code)), + } +} diff --git a/native/tests/fixtures/beta14-server-admin.ps1 b/native/tests/fixtures/beta14-server-admin.ps1 index 8216cdc..08e6239 100644 --- a/native/tests/fixtures/beta14-server-admin.ps1 +++ b/native/tests/fixtures/beta14-server-admin.ps1 @@ -22,6 +22,10 @@ switch -CaseSensitive ($testName) { $fixtureName = 'TeamsPeach Host Button QA Fixture' $permission = 'b_virtualserver_modify_hostbutton' } + 'smoke::channel_banners::live::fetch_banner_renders_classic_beta14_channel_row' { + $fixtureName = 'TeamsPeach Fetch Banner QA Fixture' + $permission = $null + } default { throw 'Specify one exact supported beta14 test.' } } $release = $env:TEAMSPEACH_BETA14_RELEASE @@ -158,14 +162,17 @@ try { }) $id = [int]$created[0].sid if ($id -le 0) { throw 'WebQuery did not return a virtual server ID.' } - $perm = @(Invoke-Query $client 'permidgetbyname' @{permsid=$permission}) - $permId = [int]$perm[0].permid $info = @(Invoke-Query $client "$id/serverinfo") $group = [int]$info[0].virtualserver_default_server_group - if ($group -le 0 -or $permId -le 0 -or [string]$info[0].virtualserver_weblist_enabled -cne '0' -or [int]$info[0].virtualserver_port -ne $voicePort) { - throw 'WebQuery did not confirm the guest group, permission, listing opt-out, and loopback port.' + if ($group -le 0 -or [string]$info[0].virtualserver_weblist_enabled -cne '0' -or [int]$info[0].virtualserver_port -ne $voicePort) { + throw 'WebQuery did not confirm the guest group, listing opt-out, and loopback port.' + } + if ($permission) { + $perm = @(Invoke-Query $client 'permidgetbyname' @{permsid=$permission}) + $permId = [int]$perm[0].permid + if ($permId -le 0) { throw 'WebQuery did not confirm the fixture permission.' } + [void](Invoke-Query $client "$id/servergroupaddperm" @{sgid=$group;permid=$permId;permvalue=1;permnegated=0;permskip=0}) } - [void](Invoke-Query $client "$id/servergroupaddperm" @{sgid=$group;permid=$permId;permvalue=1;permnegated=0;permskip=0}) if ($permission -eq 'b_virtualserver_modify_ft_settings') { $seed = @{virtualserver_max_download_total_bandwidth='1048576'; virtualserver_max_upload_total_bandwidth='2097152'} [void](Invoke-Query $client "$id/serveredit" $seed) @@ -202,6 +209,31 @@ try { if ([string]$info[0].$field -cne $seed[$field]) { throw "WebQuery did not confirm the host button baseline for $field." } } Write-Output 'Bootstrap serverinfo confirmed host button tooltip and both .invalid URLs; public listing off.' + } elseif ($fixtureName -eq 'TeamsPeach Fetch Banner QA Fixture') { + $image = [Convert]::FromBase64String([IO.File]::ReadAllText((Join-Path $PSScriptRoot 'channel-banner.png.b64')).Trim()) + foreach ($name in 'Banner Artwork QA','Banner Refused QA','Banner Control QA') { + $room = @(Invoke-Query $client "$id/channelcreate" @{channel_name=$name;channel_flag_permanent=1}) + $cid = [int]$room[0].cid + if ($cid -le 0) { throw "WebQuery did not create $name." } + if ($name -eq 'Banner Control QA') { continue } + $permissions = if ($name -eq 'Banner Artwork QA') { + @{b_channel_modify_banner=1;i_ft_file_download_power=1;i_ft_needed_file_download_power=1} + } else { + @{i_ft_needed_file_download_power=100} + } + foreach ($grant in $permissions.Keys) { + $perm = @(Invoke-Query $client 'permidgetbyname' @{permsid=$grant}) + if ([int]$perm[0].permid -le 0) { throw "WebQuery did not resolve $grant." } + [void](Invoke-Query $client "$id/channeladdperm" @{cid=$cid;permid=$perm[0].permid;permvalue=$permissions[$grant]}) + } + $directory = [IO.Directory]::CreateDirectory((Join-Path $runtime.FullName "files/virtualserver_$id/channel_$cid")) + [IO.File]::WriteAllBytes((Join-Path $directory.FullName 'banner.png'), $image) + $reference = "ts3image://127.0.0.1?port=$voicePort&channel=$cid&path=/&filename=banner.png" + [void](Invoke-Query $client "$id/channeledit" @{cid=$cid;channel_banner_gfx_url=$reference;channel_banner_mode=2}) + $room = @(Invoke-Query $client "$id/channelinfo" @{cid=$cid}) + if ([string]$room[0].channel_banner_gfx_url -cne $reference) { throw "WebQuery did not confirm $name artwork." } + } + Write-Output 'Bootstrap verified classic banner files in the permitted and restricted channels; control has no banner.' } else { $room = @(Invoke-Query $client "$id/channelcreate" @{ channel_name='Channel Edit Receipt QA'; channel_topic='Fixture seed'; channel_flag_permanent=1 diff --git a/native/tests/fixtures/channel-banner.png.b64 b/native/tests/fixtures/channel-banner.png.b64 new file mode 100644 index 0000000..2afe0db --- /dev/null +++ b/native/tests/fixtures/channel-banner.png.b64 @@ -0,0 +1 @@ +iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAIAAADq9gq6AAAAEUlEQVR4nGO4qpqNFTHgkgAANMAWUVjZLg0AAAAASUVORK5CYII=