Files
WoW-Hybrid-gateway/tests/gateway_texture_probe_test.lua
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

67 lines
4.1 KiB
Lua

-- Texture request truth, isolation and argument/secret guards; no real client.
local log, secrets, requests, frames = {}, {}, {}, {}
local originalPrint = print
print=function(...) log[#log+1]={...} end
SlashCmdList={}; UIParent={}; GatewayDiagnosticsSaved={unrelated={keep=true}}
issecretvalue=function(v)return secrets[v] or false end
local accepted,returned,path=true,166825,'spells/shadowring.blp'
GetCVar=function(name)assert(name=='overrideArchive');return '0' end
local noop=function()end
CreateFrame=function()
local f={RegisterEvent=noop,SetScript=noop,SetSize=noop,SetPoint=noop,SetFrameStrata=noop,Show=noop}
f.Hide=function()f.hidden=true end
f.CreateTexture=function()
local t={SetSize=noop,SetPoint=noop,SetAllPoints=noop,SetColorTexture=noop}
t.SetTexture=function(self,id)assert(self==t);requests[#requests+1]=id;return accepted end
t.GetTextureFileID=function(self)assert(self==t);return returned end
t.GetTextureFilePath=function(self)assert(self==t);return path end
return t
end
f.CreateFontString=function()return {SetPoint=noop,SetText=noop}end
frames[#frames+1]=f;return f
end
dofile(arg[1]..'/client_addons/GatewayDiagnostics/GatewayDiagnostics.lua')
local slash=SlashCmdList.GATEWAYDIAGNOSTICS
slash('texture-test deadbeef 166825 167125 136224')
local value=GatewayDiagnosticsSaved.textureProbe
assert(#requests==3 and value.run=='deadbeef' and #value.samples==3)
assert(value.overrideArchive=='0' and value.payloadLoadedVerified==false)
assert(value.samples[1].accepted==true and value.samples[1].returnedID==166825)
assert(value.samples[1].path==path and GatewayDiagnosticsSaved.unrelated.keep)
local panel=frames[#frames]
for _,bad in ipairs({'texture-test','texture-test deadbeef 0','texture-test DEADBEEF 1','texture-test deadbeef 1 1','texture-test deadbeef 1 2 3 4 5','texture-test deadbeef 2147483648','texture-test deadbeef 1.5','texture-test deadbeef 1;evil'})do
slash(bad);assert(#requests==3 and GatewayDiagnosticsSaved.textureProbe==value)
end
slash('texture-hide');assert(panel.hidden)
accepted,returned,path=false,0,nil
slash('texture-test 0123abcd 166825')
value=GatewayDiagnosticsSaved.textureProbe;assert(#requests==4)
assert(value.samples[1].accepted==false and value.samples[1].returnedID==0)
local hidden=setmetatable({}, {__tostring=function()error('secret formatted')end,__index=function()error('secret traversed')end})
secrets[hidden]=true;accepted,returned,path=hidden,hidden,hidden
slash('texture-test 0123abcd 166825');value=GatewayDiagnosticsSaved.textureProbe
assert(value.samples[1].accepted==nil and value.samples[1].returnedID==nil and value.samples[1].path==nil)
accepted,returned,path='true',math.huge,string.rep('x',129)
slash('texture-test 0123abcd 166825');value=GatewayDiagnosticsSaved.textureProbe
assert(value.samples[1].accepted==nil and value.samples[1].returnedID==nil and value.samples[1].path==nil)
local loose='interface/icons/ability_warrior_reprisal.blp'
local lookup=-608
GetFileIDFromPath=function(value)assert(value==loose);return lookup end
accepted,returned,path=true,-608,loose
local before=#requests
slash('texture-loose-test aabbccdd '..loose);value=GatewayDiagnosticsSaved.textureProbe
assert(#requests==before+2 and requests[before+1]==loose and requests[before+2]==-608)
assert(value.runtimeID==-608 and value.runtimeHandleOnly and value.portableFileDataID==false)
assert(value.samples[1].returnedID==-608 and value.samples[2].returnedID==-608)
assert(value.payloadLoadedVerified==false and GatewayDiagnosticsSaved.unrelated.keep)
for _,bad in ipairs({'texture-loose-test aabbccdd ../escape.blp','texture-loose-test AABBCCDD '..loose,'texture-loose-test aabbccdd interface/icons/nested/file.blp'})do
slash(bad);assert(#requests==before+2 and GatewayDiagnosticsSaved.textureProbe==value)
end
for _,bad in ipairs({0,132944,hidden,math.huge})do
lookup=bad;slash('texture-loose-test aabbccdd '..loose)
assert(#requests==before+2 and GatewayDiagnosticsSaved.textureProbe==value)
end
GatewayDiagnosticsSaved='invalid';local n=#requests
slash('texture-test 0123abcd 166825');assert(#requests==n)
originalPrint('Gateway texture diagnostics: request/false/secret/bounds/isolation guards PASS; no payload-loading claim')