@@ -14,6 +14,82 @@ beforeAll(async () => {
1414} ) ;
1515
1616describe ( "self-hosted firmware activation" , ( ) => {
17+ it ( "carries an active public installer through later website-only deployments" , ( ) => {
18+ const stagedBranch = script . indexOf (
19+ "if [[ -n ${PYBLE_FIRMWARE_STAGED_ROOT:-} ]]; then" ,
20+ ) ;
21+ const build = script . indexOf ( "NEXT_TELEMETRY_DISABLED=1 npm run check" ) ;
22+ const marker = ".pyble-firmware-release-selection.json" ;
23+ const currentRelease = script . indexOf ( "/srv/pyble/current" ) ;
24+ const authenticatedRetrieval = script . search (
25+ / \b (?: s s h | r s y n c ) \b [ \s \S ] { 0 , 2400 } \. p y b l e - f i r m w a r e - r e l e a s e - s e l e c t i o n \. j s o n / ,
26+ ) ;
27+ const preservedValidation = script . indexOf (
28+ "--verify-staged" ,
29+ authenticatedRetrieval ,
30+ ) ;
31+
32+ expect . soft ( script ) . toContain ( marker ) ;
33+ expect . soft ( currentRelease ) . toBeGreaterThan ( - 1 ) ;
34+ expect
35+ . soft (
36+ authenticatedRetrieval ,
37+ "the current selector and immutable firmware must be retrieved over the authenticated deployment transport" ,
38+ )
39+ . toBeGreaterThan ( - 1 ) ;
40+ expect . soft ( authenticatedRetrieval ) . toBeLessThan ( build ) ;
41+ expect . soft ( preservedValidation ) . toBeGreaterThan ( authenticatedRetrieval ) ;
42+ expect . soft ( preservedValidation ) . toBeLessThan ( build ) ;
43+ expect
44+ . soft ( script . slice ( authenticatedRetrieval , build ) )
45+ . toContain ( "PYBLE_FLASH_SELECTION_FILE" ) ;
46+ expect
47+ . soft ( script . slice ( stagedBranch , build ) )
48+ . toMatch ( / d e p l o y m e n t \s * ! = = \s * " p u b l i c " [ \s \S ] * h i l S t a t u s \s * ! = = \s * " p a s s e d " / ) ;
49+ } ) ;
50+
51+ it ( "requires an unambiguous explicit operation to disable an active installer" , ( ) => {
52+ const flag = "PYBLE_EXPLICITLY_DISABLE_PUBLIC_INSTALLER" ;
53+ const flagIndex = script . indexOf ( flag ) ;
54+ const stagedBranch = script . indexOf (
55+ "if [[ -n ${PYBLE_FIRMWARE_STAGED_ROOT:-} ]]; then" ,
56+ ) ;
57+ const build = script . indexOf ( "NEXT_TELEMETRY_DISABLED=1 npm run check" ) ;
58+
59+ expect . soft ( flagIndex ) . toBeGreaterThan ( - 1 ) ;
60+ expect . soft ( flagIndex ) . toBeLessThan ( stagedBranch ) ;
61+ expect
62+ . soft ( script . slice ( flagIndex , build ) )
63+ . toMatch ( / (?: 0 \| 1 | " 0 " \| " 1 " | ! = \s * " 0 " [ \s \S ] * ! = \s * " 1 " ) / ) ;
64+ expect
65+ . soft ( script . slice ( flagIndex , build ) )
66+ . toMatch (
67+ / P Y B L E _ E X P L I C I T L Y _ D I S A B L E _ P U B L I C _ I N S T A L L E R [ \s \S ] { 0 , 1600 } P Y B L E _ F I R M W A R E _ S T A G E D _ R O O T [ \s \S ] { 0 , 800 } (?: R e f u s i n g | e x i t \s + 6 5 ) / ,
68+ ) ;
69+ expect
70+ . soft ( script . slice ( flagIndex , build ) )
71+ . toMatch ( / (?: d i s a b l e d | u n a v a i l a b l e ) [ \s \S ] { 0 , 1200 } (?: f l a s h \. h t m l | s m o k e ) / i) ;
72+ } ) ;
73+
74+ it ( "retains the validated selector as hidden state in each active website release" , ( ) => {
75+ const marker = ".pyble-firmware-release-selection.json" ;
76+ const build = script . indexOf ( "NEXT_TELEMETRY_DISABLED=1 npm run check" ) ;
77+ const markerCopy = script . indexOf ( marker , build ) ;
78+ const upload = script . search ( / \b r s y n c \b / ) ;
79+ const smoke = script . indexOf ( "for route in / /privacy /support /flash" ) ;
80+
81+ expect ( markerCopy ) . toBeGreaterThan ( build ) ;
82+ expect ( markerCopy ) . toBeLessThan ( upload ) ;
83+ expect
84+ . soft ( script . slice ( markerCopy - 300 , markerCopy + 600 ) )
85+ . toMatch ( / (?: c p | i n s t a l l ) [ \s \S ] * \$ \{ s t a g e d _ s e l e c t i o n \} / ) ;
86+ expect
87+ . soft ( script . slice ( smoke ) )
88+ . toMatch (
89+ / \. p y b l e - f i r m w a r e - r e l e a s e - s e l e c t i o n \. j s o n [ \s \S ] { 0 , 2400 } (?: f l a s h \. h t m l | \/ f l a s h ) / ,
90+ ) ;
91+ } ) ;
92+
1793 it ( "accepts only a canonically validated all-HIL-passed public staged release" , ( ) => {
1894 const stagedBranch = script . indexOf (
1995 "if [[ -n ${PYBLE_FIRMWARE_STAGED_ROOT:-} ]]; then" ,
0 commit comments