feat: default developer mode to nodevm and remove vm2 (#6187)

This commit is contained in:
lohit
2025-11-29 00:04:55 +05:30
committed by GitHub
parent 8c06a229e9
commit 4f8d2c0c67
24 changed files with 249 additions and 405 deletions

View File

@@ -0,0 +1,14 @@
{
"version": "1",
"name": "should_allow_fs",
"type": "collection",
"ignore": [
"node_modules",
".git"
],
"scripts": {
"filesystemAccess": {
"allow": true
}
}
}

View File

@@ -0,0 +1,15 @@
meta {
name: request
type: http
seq: 1
}
post {
url: https://echo.usebruno.com
body: none
auth: none
}
script:pre-request {
const fs = require('fs');
}

View File

@@ -0,0 +1,14 @@
{
"version": "1",
"name": "should_disallow_fs",
"type": "collection",
"ignore": [
"node_modules",
".git"
],
"scripts": {
"filesystemAccess": {
"allow": false
}
}
}

View File

@@ -0,0 +1,15 @@
meta {
name: request
type: http
seq: 1
}
post {
url: https://echo.usebruno.com
body: none
auth: none
}
script:pre-request {
const fs = require('fs');
}

View File

@@ -0,0 +1,80 @@
import { test } from '../../../../playwright';
import { setSandboxMode, runCollection, validateRunnerResults } from '../../../utils/page';
test.describe.serial('`fs` library', () => {
test.describe('should allow `fs` library', () => {
test('developer mode', async ({ pageWithUserData: page }) => {
test.setTimeout(2 * 60 * 1000);
// Set up developer mode
await setSandboxMode(page, 'should_allow_fs', 'developer');
// Run the collection
await runCollection(page, 'should_allow_fs');
// Validate test results
await validateRunnerResults(page, {
totalRequests: 1,
passed: 1,
failed: 0,
skipped: 0
});
});
test('safe mode', async ({ pageWithUserData: page }) => {
test.setTimeout(2 * 60 * 1000);
// Set up safe mode
await setSandboxMode(page, 'should_allow_fs', 'safe');
// Run the collection
await runCollection(page, 'should_allow_fs');
// Validate test results
await validateRunnerResults(page, {
totalRequests: 1,
passed: 0,
failed: 1,
skipped: 0
});
});
});
test.describe('should disallow `fs` library', () => {
test('developer mode', async ({ pageWithUserData: page }) => {
test.setTimeout(2 * 60 * 1000);
// Set up developer mode
await setSandboxMode(page, 'should_disallow_fs', 'developer');
// Run the collection
await runCollection(page, 'should_disallow_fs');
// Validate test results
await validateRunnerResults(page, {
totalRequests: 1,
passed: 0,
failed: 1,
skipped: 0
});
});
test('safe mode', async ({ pageWithUserData: page }) => {
test.setTimeout(2 * 60 * 1000);
// Set up safe mode
await setSandboxMode(page, 'should_disallow_fs', 'safe');
// Run the collection
await runCollection(page, 'should_disallow_fs');
// Validate test results
await validateRunnerResults(page, {
totalRequests: 1,
passed: 0,
failed: 1,
skipped: 0
});
});
});
});

View File

@@ -0,0 +1,7 @@
{
"maximized": true,
"lastOpenedCollections": [
"{{projectRoot}}/tests/scripting/inbuilt-libraries/fs/fixtures/collections/should_allow_fs",
"{{projectRoot}}/tests/scripting/inbuilt-libraries/fs/fixtures/collections/should_disallow_fs"
]
}