* Test tampering detection
()
| 375 | * Test tampering detection |
| 376 | */ |
| 377 | async function testTamperingDetection() { |
| 378 | // Create a copy and sign it |
| 379 | const testFile = path.join(TEST_DIR, "test-tampered.dxt"); |
| 380 | fs.copyFileSync(TEST_MCPB, testFile); |
| 381 | signMcpbFile(testFile, SELF_SIGNED_CERT, SELF_SIGNED_KEY); |
| 382 | |
| 383 | // Read the signed file |
| 384 | const signedContent = fs.readFileSync(testFile); |
| 385 | |
| 386 | // Tamper with the content (change a byte in the ZIP portion) |
| 387 | const tamperedContent = Buffer.from(signedContent); |
| 388 | tamperedContent[10] = (tamperedContent[10] + 1) % 256; |
| 389 | fs.writeFileSync(testFile, tamperedContent); |
| 390 | |
| 391 | // Try to verify - should fail |
| 392 | const result = await verifyMcpbFile(testFile); |
| 393 | expect(result.status).toBe("unsigned"); |
| 394 | |
| 395 | // Clean up |
| 396 | fs.unlinkSync(testFile); |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Test unsigned file verification |
no test coverage detected
searching dependent graphs…