Files
WoW-Hybrid-gateway/tests/private_capture_notice_sink_fixture.cpp
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

29 lines
2.3 KiB
C++

// Consumes notices emitted through actual Windows account admission, then
// executes the shared production Unix notice/sink. Synthetic scope/data only.
#include "../native/private_gameplay_capture.hpp"
#include <fstream>
#include <iostream>
#include <iterator>
#include <sstream>
#include <stdexcept>
static void check(bool v,const char* message){if(!v)throw std::runtime_error(message);}
int main(int argc,char**argv){try{
check(argc==2,"notice-file argument");char folder[]="/tmp/gw-capture-admission-XXXXXX";check(mkdtemp(folder),"private fixture folder");std::string path=std::string(folder)+"/capture.jsonl";setenv("GW_PRIVATE_GAMEPLAY_CAPTURE",path.c_str(),1);
const std::vector<uint8_t> query={0xc3,0x06,0,0},private_join={0xde,0xad,0xbe,0xef};unsigned notices=0,successes=0;
{PrivateGameplayCapture capture;std::ifstream input(argv[1]);std::string line;
while(std::getline(input,line)){
if(!line.starts_with("NOTICE "))continue;
std::istringstream fields(line);std::string marker;uint32_t kind,opcode,bytes;check(bool(fields>>marker>>kind>>opcode>>bytes),"typed admitted notice");
if(kind==3)capture.stage_source_out(true,123,0x60,query);
if(kind==2){if(!successes++)capture.stage_source_out(true,123,0x60,query);else capture.stage_source_out(true,123,0x97,private_join);}
check(capture.notice(kind,true,123,opcode,bytes),"production Unix notice accepted");++notices;
if(kind==3)check(capture.count()==1,"failed send cannot commit staged source body");
}
check(notices==6 && successes==2 && capture.count()==3 && !capture.error(),"notice/sink boundary counts");check(!capture.notice(99,true,123,0,0),"unknown notice kind rejected");}
std::ifstream input(path);std::string records((std::istreambuf_iterator<char>(input)),{});
check(records.find("\"direction\":\"native_out\"")!=std::string::npos,"native request metadata recorded");check(records.find("\"direction\":\"source_out\"")!=std::string::npos,"successful source send recorded");
check(records.find("c3060000")!=std::string::npos && records.find("deadbeef")==std::string::npos,"query body retained and join body omitted");
check(records.find("4456449")==std::string::npos,"native auth packet excluded");std::filesystem::remove_all(folder);
std::cout<<"PASS actual Windows admission to shared Unix ACK/metadata sink\n";return 0;
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}