@@ -85,12 +85,12 @@ describe('Checksum verification', () => {
8585 vi . spyOn ( os , 'platform' ) . mockReturnValue ( 'linux' ) ;
8686 vi . spyOn ( os , 'arch' ) . mockReturnValue ( 'x64' ) ;
8787
88- delete process . env . CAPISCIO_REQUIRE_CHECKSUM ;
88+ delete process . env . CAPISCIO_SKIP_CHECKSUM ;
8989 } ) ;
9090
9191 afterEach ( ( ) => {
9292 vi . restoreAllMocks ( ) ;
93- delete process . env . CAPISCIO_REQUIRE_CHECKSUM ;
93+ delete process . env . CAPISCIO_SKIP_CHECKSUM ;
9494 } ) ;
9595
9696 /**
@@ -169,36 +169,35 @@ describe('Checksum verification', () => {
169169 ) ;
170170 } ) ;
171171
172- it ( 'should skip verification when checksums.txt fetch fails and CAPISCIO_REQUIRE_CHECKSUM is not set ' , async ( ) => {
172+ it ( 'should throw when checksums.txt fetch fails (fail-closed default) ' , async ( ) => {
173173 await setupMocks ( new Error ( 'Network error' ) ) ;
174- const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
175174
176175 const { BinaryManager } = await import ( '../../src/utils/binary-manager' ) ;
177176 const instance = BinaryManager . getInstance ( ) ;
178177
179- await expect ( instance . getBinaryPath ( ) ) . resolves . toBeDefined ( ) ;
180- expect ( warnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Could not fetch checksums.txt' ) ) ;
181- warnSpy . mockRestore ( ) ;
178+ await expect ( instance . getBinaryPath ( ) ) . rejects . toThrow (
179+ 'Checksum verification failed' ,
180+ ) ;
181+ expect ( fs . rmSync ) . toHaveBeenCalledWith (
182+ expect . stringContaining ( 'capiscio' ) ,
183+ { force : true } ,
184+ ) ;
182185 } ) ;
183186
184- it ( 'should throw when checksums.txt fetch fails and CAPISCIO_REQUIRE_CHECKSUM =true' , async ( ) => {
185- process . env . CAPISCIO_REQUIRE_CHECKSUM = 'true' ;
187+ it ( 'should skip verification when checksums.txt fetch fails and CAPISCIO_SKIP_CHECKSUM =true' , async ( ) => {
188+ process . env . CAPISCIO_SKIP_CHECKSUM = 'true' ;
186189 await setupMocks ( new Error ( 'Network error' ) ) ;
190+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
187191
188192 const { BinaryManager } = await import ( '../../src/utils/binary-manager' ) ;
189193 const instance = BinaryManager . getInstance ( ) ;
190194
191- await expect ( instance . getBinaryPath ( ) ) . rejects . toThrow (
192- 'Checksum verification required' ,
193- ) ;
194- expect ( fs . rmSync ) . toHaveBeenCalledWith (
195- expect . stringContaining ( 'capiscio' ) ,
196- { force : true } ,
197- ) ;
195+ await expect ( instance . getBinaryPath ( ) ) . resolves . toBeDefined ( ) ;
196+ expect ( warnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Could not fetch checksums.txt' ) ) ;
197+ warnSpy . mockRestore ( ) ;
198198 } ) ;
199199
200- it ( 'should throw when asset not found in checksums.txt and CAPISCIO_REQUIRE_CHECKSUM=true' , async ( ) => {
201- process . env . CAPISCIO_REQUIRE_CHECKSUM = 'true' ;
200+ it ( 'should throw when asset not found in checksums.txt (fail-closed default)' , async ( ) => {
202201 // checksums.txt exists but does not contain our asset
203202 await setupMocks ( {
204203 data : 'abc123 some-other-asset\n' ,
@@ -216,7 +215,8 @@ describe('Checksum verification', () => {
216215 ) ;
217216 } ) ;
218217
219- it ( 'should skip verification when asset not found in checksums.txt and require is off' , async ( ) => {
218+ it ( 'should skip verification when asset not found in checksums.txt and CAPISCIO_SKIP_CHECKSUM=true' , async ( ) => {
219+ process . env . CAPISCIO_SKIP_CHECKSUM = 'true' ;
220220 await setupMocks ( {
221221 data : 'abc123 some-other-asset\n' ,
222222 } ) ;
@@ -230,7 +230,7 @@ describe('Checksum verification', () => {
230230 warnSpy . mockRestore ( ) ;
231231 } ) ;
232232
233- it ( 'should accept CAPISCIO_REQUIRE_CHECKSUM values: 1, yes, TRUE' , async ( ) => {
233+ it ( 'should accept CAPISCIO_SKIP_CHECKSUM values: 1, yes, TRUE' , async ( ) => {
234234 for ( const val of [ '1' , 'yes' , 'TRUE' ] ) {
235235 resetBinaryManager ( ) ;
236236 vi . clearAllMocks ( ) ;
@@ -251,13 +251,16 @@ describe('Checksum verification', () => {
251251 vi . spyOn ( os , 'platform' ) . mockReturnValue ( 'linux' ) ;
252252 vi . spyOn ( os , 'arch' ) . mockReturnValue ( 'x64' ) ;
253253
254- process . env . CAPISCIO_REQUIRE_CHECKSUM = val ;
254+ process . env . CAPISCIO_SKIP_CHECKSUM = val ;
255255 await setupMocks ( new Error ( 'fetch failed' ) ) ;
256+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
256257
257258 const { BinaryManager } = await import ( '../../src/utils/binary-manager' ) ;
258259 const instance = BinaryManager . getInstance ( ) ;
259260
260- await expect ( instance . getBinaryPath ( ) ) . rejects . toThrow ( 'Checksum verification required' ) ;
261+ await expect ( instance . getBinaryPath ( ) ) . resolves . toBeDefined ( ) ;
262+ expect ( warnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Could not fetch checksums.txt' ) ) ;
263+ warnSpy . mockRestore ( ) ;
261264 }
262265 } ) ;
263266} ) ;
0 commit comments