Files
WoW-Hybrid-gateway/tests/source_profile5_worker_fixture.c
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

68 lines
5.5 KiB
C

/* Real account worker, synthetic dispatcher: profile-5 preflight port is frozen. */
#define GW_SOURCE_ONLY_PROFILE 5
#define GW_ACCOUNT_TEST_PORT 3725
#define GW_ACCOUNT_SINGLETON_TEST 1
#define fixture_start existing_account_fixture_start
#include "native_account_memory_fixture.c"
#undef fixture_start
static unsigned int preflight_calls;static int profile_failure;
static LONG singleton_kind=5;static int singleton_endpoint_allowed=1;
struct gw_session_retirement_control gw_wire_session_retirement_data={.abi=1,.size=sizeof(struct gw_session_retirement_control),.next_credentials_generation=1};
LONG WINAPI gw_source_profile_kind(void){return singleton_kind;}
LONG WINAPI gw_source_profile_read(struct gw_source_profile* p){if(!p||p->abi!=1||p->size!=sizeof(*p))return -1;p->kind=5;p->auth_port=3725;__builtin_memcpy(p->hostname,"127.0.0.1",10);return profile_failure?-1:5;}
int gw_private_worker_resolve(unsigned int profile,char out[16]){(void)profile;(void)out;return -1;}
int gw_private_source_realm_endpoint_eligible(unsigned int kind,const unsigned char a[4],uint16_t port){return singleton_endpoint_allowed&&(kind==5||kind==4)&&a&&a[0]==198&&a[1]==51&&a[2]==100&&a[3]==23&&port==8090;}
int gw_source_preflight_consume_session(uint32_t generation,const char address[16],uint32_t port){++preflight_calls;return (generation==1||generation==2)&&port==3725&&!__builtin_memcmp(address,"192.0.2.7",10)?0:-1;}
void fixture_start(void){
message("GW_PROFILE5_WORKER entry\n");configure();publish(1,14,18);set_explicit_profile();gw_wire_auth_data.auth_port=3725;auth_failure=1;
check(!gw_wire_account_start()&&preflight_calls==1,1);
/* An externally changed UI POD cannot redirect the authenticated worker. */
gw_wire_auth_data.auth_port=9999;run_worker();
check(explicit_calls==1&&gw_wire_auth_data.auth_result==-2&&!gw_wire_auth_data.server_proof_verified,2);
configure();publish(2,14,18);set_explicit_profile();gw_wire_auth_data.auth_port=3725;
check(!gw_wire_account_start(),3);profile_failure=1;run_worker();profile_failure=0;
check(explicit_calls==1&&gw_wire_auth_credentials_data.state==-1&&all_zero(gw_wire_auth_credentials_data.username,100),4);
/* A frame-owned fresh local login uses its immutable loopback endpoint
* directly; the worker still reports the genuine synthetic auth failure. */
gw_wire_session_retirement_data=(struct gw_session_retirement_control){.abi=1,.size=sizeof(struct gw_session_retirement_control),.state=2,.expected_credentials_generation=2,.completed_credentials_generation=2,.next_credentials_generation=3,.owner=0x1234};
configure();publish(3,14,18);set_explicit_profile();__builtin_memcpy(gw_wire_endpoint_profile_data.auth_ipv4,"127.0.0.1",10);gw_wire_auth_data.auth_port=3725;
fixture_expected_explicit_auth="127.0.0.1";check(!gw_wire_account_start_owned((void*)0x1234) && preflight_calls==2,5);
check(gw_wire_auth_data.state==1 && !gw_wire_auth_data.server_proof_verified,6);run_worker();
check(explicit_calls==2 && gw_wire_auth_data.auth_result==-2 && !gw_wire_auth_data.server_proof_verified,7);
/* Standalone, wrong owner/generation/endpoint/port and cancellation cannot
* use this path when the real preflight has not admitted them. */
for(unsigned i=0;i<6;i++){
configure();publish(4,14,18);set_explicit_profile();__builtin_memcpy(gw_wire_endpoint_profile_data.auth_ipv4,"127.0.0.1",10);gw_wire_auth_data.auth_port=3725;
gw_wire_session_retirement_data=(struct gw_session_retirement_control){.abi=1,.size=sizeof(struct gw_session_retirement_control),.state=2,.expected_credentials_generation=3,.completed_credentials_generation=3,.next_credentials_generation=4,.owner=0x1234};
if(i==1)gw_wire_session_retirement_data.next_credentials_generation=5;
if(i==2)gw_wire_session_retirement_data.owner=0x4321;
if(i==3)gw_wire_endpoint_profile_data.auth_ipv4[8]='2';
if(i==4)gw_wire_auth_data.auth_port=3726;
if(i==5)gw_wire_auth_data.cancel=1;
check((i==0?gw_wire_account_start():gw_wire_account_start_owned((void*)0x1234))==-1,8+i);
wiped(-1,20+i);check(!gw_wire_auth_data.server_proof_verified && !pending,30+i);
}
/* Exercise the real worker with genuine synthetic discovery results. The
* profile-5 shortcut only applies to one permitted advertised row; all other
* cases must retain explicit selection or wait for the existing picker. */
for(unsigned i=0;i<8;i++){
unsigned before=explicit_transports;
configure();credentials_generation=0;publish(1,14,18);set_explicit_profile();gw_wire_auth_data.auth_port=3725;
fixture_expected_explicit_auth="192.0.2.7";singleton_kind=5;singleton_endpoint_allowed=1;auth_failure=0;
singleton_realm_count=1;singleton_waits=singleton_bad_realm=0;singleton_open_index=99;
if(i==1)singleton_realm_count=2;
if(i==2)singleton_endpoint_allowed=0;
if(i==3){singleton_realm_count=2;gw_wire_auth_data.selected_index=1;}
if(i==4)singleton_bad_realm=1;
if(i==5)singleton_kind=4;
if(i==6)auth_failure=1;
if(i==7)singleton_realm_count=0;
check(!gw_wire_account_start(),50+i);run_worker();auth_failure=0;
if(i==0)check(explicit_transports==before+1 && singleton_open_index==0 && !singleton_waits && gw_wire_auth_data.server_proof_verified,60+i);
else if(i==3)check(explicit_transports==before+1 && singleton_open_index==1 && !singleton_waits && gw_wire_auth_data.server_proof_verified,60+i);
else if(i==6)check(explicit_transports==before && !gw_wire_auth_data.server_proof_verified && !realm_reads,60+i);
else check(explicit_transports==before && singleton_waits==1 && gw_wire_auth_data.server_proof_verified,60+i);
}
message("GW_PROFILE5_WORKER complete\n");ExitProcess(0);
}