code wiki / (root) / nx_live_governor_test.nx

nx_live_governor_test.nx source

↩ module page · 31 lines · 1450 B

1// nx_live_governor_test.nx -- smoke for nx_live_governor (grading core). 2// 3// Proves the liveness grading captures every real failure class: 4// - a public page serving correctly -> LIVE (1) 5// - 404 / dead-backend / redirect-loop -> BROKEN (2-4) [the /login bug] 6// - a public asset hidden behind the login wall -> WRONG_WALL (5) 7// - a walled section correctly showing the wall -> LIVE (6) 8// - the login PAGE serving (200, no loop) -> LIVE (7) 9// Exit code = failed assertion number; 0 = all pass. 10 11import "nx_syscalls.nx" 12import "nx_live_governor.nx" 13 14func main() -> i64 { 15 // public page live 16 if nx_lg_grade(200, NX_LG_PUBLIC, 200, 1, 0) != NX_LG_LIVE { return 1 } 17 // 404 18 if nx_lg_grade(200, NX_LG_PUBLIC, 404, 0, 0) != NX_LG_BROKEN { return 2 } 19 // redirect loop / dead backend (status 0) -- the /login self-redirect 20 if nx_lg_grade(200, NX_LG_WALLED, 0, 0, 0) != NX_LG_BROKEN { return 3 } 21 // 200 but wrong/empty content 22 if nx_lg_grade(200, NX_LG_PUBLIC, 200, 0, 0) != NX_LG_BROKEN { return 4 } 23 // public asset hidden behind the login wall 24 if nx_lg_grade(200, NX_LG_PUBLIC, 200, 1, 1) != NX_LG_WRONG_WALL { return 5 } 25 // a walled section correctly showing the wall 26 if nx_lg_grade(200, NX_LG_WALLED, 200, 1, 1) != NX_LG_LIVE { return 6 } 27 // the login page serving its form (200, not looping) 28 if nx_lg_grade(200, NX_LG_WALLED, 200, 1, 0) != NX_LG_LIVE { return 7 } 29 30 return 0 31}