mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-04-30 12:06:46 +00:00
Compare commits
4 Commits
copilot/su
...
copilot/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbb5ddca0a | ||
|
|
3b0f7af382 | ||
|
|
7f6ad472c4 | ||
|
|
8f9dda5a8d |
118
.github/workflows/nightly-e2e.yml
vendored
118
.github/workflows/nightly-e2e.yml
vendored
@@ -1,118 +0,0 @@
|
|||||||
name: Nightly E2E Full
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '30 18 * * *' # 02:30 Asia/Shanghai
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
e2e-nightly:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 50
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup JDK 21
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: '21'
|
|
||||||
cache: maven
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
cache-dependency-path: tests/e2e/package-lock.json
|
|
||||||
|
|
||||||
- name: Setup Python 3.11
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install LibreOffice + archive tools
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libreoffice zip p7zip-full
|
|
||||||
|
|
||||||
- name: Setup Python deps for office fixtures
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r tests/e2e/requirements.txt
|
|
||||||
|
|
||||||
- name: Build kkFileView
|
|
||||||
run: mvn -q -pl server -DskipTests package
|
|
||||||
|
|
||||||
- name: Install E2E deps
|
|
||||||
working-directory: tests/e2e
|
|
||||||
run: |
|
|
||||||
npm ci
|
|
||||||
npx playwright install --with-deps chromium
|
|
||||||
|
|
||||||
- name: Start fixture server
|
|
||||||
run: |
|
|
||||||
cd tests/e2e/fixtures
|
|
||||||
python3 -m http.server 18080 > /tmp/fixture-server.log 2>&1 &
|
|
||||||
|
|
||||||
- name: Start kkFileView
|
|
||||||
run: |
|
|
||||||
JAR_PATH=$(ls server/target/kkFileView-*.jar | head -n 1)
|
|
||||||
nohup env KK_TRUST_HOST='*' KK_NOT_TRUST_HOST='10.*,172.16.*,192.168.*' java -jar "$JAR_PATH" > /tmp/kkfileview.log 2>&1 &
|
|
||||||
|
|
||||||
- name: Wait for services
|
|
||||||
run: |
|
|
||||||
fixture_ready=false
|
|
||||||
for i in {1..60}; do
|
|
||||||
if curl -fsS http://127.0.0.1:18080/sample.txt >/dev/null; then
|
|
||||||
fixture_ready=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
if [ "$fixture_ready" != "true" ]; then
|
|
||||||
echo "Error: fixture server did not become ready within 60 seconds." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
kkfileview_ready=false
|
|
||||||
for i in {1..120}; do
|
|
||||||
if curl -fsS http://127.0.0.1:8012/ >/dev/null; then
|
|
||||||
kkfileview_ready=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
if [ "$kkfileview_ready" != "true" ]; then
|
|
||||||
echo "Error: kkFileView service did not become ready within 120 seconds." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run nightly E2E suites
|
|
||||||
working-directory: tests/e2e
|
|
||||||
env:
|
|
||||||
KK_BASE_URL: http://127.0.0.1:8012
|
|
||||||
FIXTURE_BASE_URL: http://127.0.0.1:18080
|
|
||||||
E2E_MAX_PREVIEW_MS: 20000
|
|
||||||
run: npm run test:ci
|
|
||||||
|
|
||||||
- name: Upload Playwright report
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: nightly-playwright-report
|
|
||||||
path: tests/e2e/playwright-report
|
|
||||||
|
|
||||||
- name: Upload service logs
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: nightly-e2e-service-logs
|
|
||||||
path: |
|
|
||||||
/tmp/kkfileview.log
|
|
||||||
/tmp/fixture-server.log
|
|
||||||
9
.github/workflows/pr-e2e-mvp.yml
vendored
9
.github/workflows/pr-e2e-mvp.yml
vendored
@@ -36,10 +36,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- name: Install LibreOffice + archive tools
|
- name: Install LibreOffice + zip
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libreoffice zip p7zip-full
|
sudo apt-get install -y libreoffice zip
|
||||||
|
|
||||||
- name: Setup Python deps for office fixtures
|
- name: Setup Python deps for office fixtures
|
||||||
run: |
|
run: |
|
||||||
@@ -55,6 +55,11 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npx playwright install --with-deps chromium
|
npx playwright install --with-deps chromium
|
||||||
|
|
||||||
|
- name: Generate fixtures
|
||||||
|
run: |
|
||||||
|
node tests/e2e/scripts/generate-fixtures.mjs
|
||||||
|
python3 tests/e2e/scripts/generate-office-fixtures.py
|
||||||
|
|
||||||
- name: Start fixture server
|
- name: Start fixture server
|
||||||
run: |
|
run: |
|
||||||
cd tests/e2e/fixtures
|
cd tests/e2e/fixtures
|
||||||
|
|||||||
1
tests/e2e/.gitignore
vendored
1
tests/e2e/.gitignore
vendored
@@ -3,7 +3,6 @@ playwright-report/
|
|||||||
test-results/
|
test-results/
|
||||||
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
fixtures/archive-tmp/
|
|
||||||
fixtures/zip-tmp/
|
fixtures/zip-tmp/
|
||||||
fixtures/sample.docx
|
fixtures/sample.docx
|
||||||
fixtures/sample.xlsx
|
fixtures/sample.xlsx
|
||||||
|
|||||||
@@ -6,13 +6,11 @@ This folder contains a first MVP of end-to-end automated tests.
|
|||||||
|
|
||||||
- Basic preview smoke checks for common file types (txt/md/json/xml/csv/html/png)
|
- Basic preview smoke checks for common file types (txt/md/json/xml/csv/html/png)
|
||||||
- Office Phase-2 smoke checks (docx/xlsx/pptx)
|
- Office Phase-2 smoke checks (docx/xlsx/pptx)
|
||||||
- Archive smoke checks (zip/tar/tgz/7z/rar)
|
- Archive smoke check (zip)
|
||||||
- Basic endpoint reachability
|
- Basic endpoint reachability
|
||||||
- Security regression checks for blocked internal-network hosts (`10.*`) on:
|
- Security regression checks for blocked internal-network hosts (`10.*`) on:
|
||||||
- `/onlinePreview`
|
- `/onlinePreview`
|
||||||
- `/getCorsFile`
|
- `/getCorsFile`
|
||||||
- Basic performance smoke checks (configurable threshold): txt/docx/xlsx preview response time
|
|
||||||
- CI combined run command available via `npm run test:ci`
|
|
||||||
|
|
||||||
## Local run
|
## Local run
|
||||||
|
|
||||||
@@ -31,13 +29,12 @@ npx playwright install --with-deps chromium
|
|||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
> Prerequisite: ensure `python3`, `zip`, and `7z` (or `bsdtar` as a fallback) are available in PATH for archive fixtures.
|
|
||||||
|
|
||||||
3. Generate fixtures and start fixture server:
|
3. Generate fixtures and start fixture server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/kkFileView
|
cd /path/to/kkFileView
|
||||||
npm run gen:all
|
node tests/e2e/scripts/generate-fixtures.mjs
|
||||||
|
python3 tests/e2e/scripts/generate-office-fixtures.py
|
||||||
cd tests/e2e/fixtures && python3 -m http.server 18080
|
cd tests/e2e/fixtures && python3 -m http.server 18080
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -54,16 +51,3 @@ KK_TRUST_HOST='*' KK_NOT_TRUST_HOST='10.*,172.16.*,192.168.*' java -jar "$JAR_PA
|
|||||||
cd tests/e2e
|
cd tests/e2e
|
||||||
KK_BASE_URL=http://127.0.0.1:8012 FIXTURE_BASE_URL=http://127.0.0.1:18080 npm test
|
KK_BASE_URL=http://127.0.0.1:8012 FIXTURE_BASE_URL=http://127.0.0.1:18080 npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
Optional:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# smoke only (self-contained: will auto-generate fixtures)
|
|
||||||
npm run test:smoke
|
|
||||||
|
|
||||||
# perf smoke (self-contained; default threshold 15000ms)
|
|
||||||
E2E_MAX_PREVIEW_MS=15000 npm run test:perf
|
|
||||||
|
|
||||||
# CI-style combined run (single fixture generation)
|
|
||||||
E2E_MAX_PREVIEW_MS=20000 npm run test:ci
|
|
||||||
```
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,12 +9,7 @@
|
|||||||
"gen:all": "npm run gen:fixtures && npm run gen:office",
|
"gen:all": "npm run gen:fixtures && npm run gen:office",
|
||||||
"pretest": "npm run gen:all",
|
"pretest": "npm run gen:all",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"test:headed": "playwright test --headed",
|
"test:headed": "playwright test --headed"
|
||||||
"pretest:smoke": "npm run gen:all",
|
|
||||||
"test:smoke": "playwright test specs/preview-smoke.spec.ts",
|
|
||||||
"pretest:perf": "npm run gen:all",
|
|
||||||
"test:perf": "playwright test specs/perf-smoke.spec.ts",
|
|
||||||
"test:ci": "npm run gen:all && playwright test specs/preview-smoke.spec.ts specs/perf-smoke.spec.ts"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.55.0"
|
"@playwright/test": "^1.55.0"
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ export default defineConfig({
|
|||||||
testDir: './specs',
|
testDir: './specs',
|
||||||
timeout: 30_000,
|
timeout: 30_000,
|
||||||
expect: { timeout: 10_000 },
|
expect: { timeout: 10_000 },
|
||||||
retries: process.env.CI ? 1 : 0,
|
|
||||||
reporter: [['list'], ['html', { outputFolder: 'playwright-report', open: 'never' }]],
|
reporter: [['list'], ['html', { outputFolder: 'playwright-report', open: 'never' }]],
|
||||||
use: {
|
use: {
|
||||||
baseURL: process.env.KK_BASE_URL || 'http://127.0.0.1:8012',
|
baseURL: process.env.KK_BASE_URL || 'http://127.0.0.1:8012',
|
||||||
trace: 'on-first-retry',
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,87 +16,17 @@ write('sample.xml', '<root><name>kkFileView</name><e2e>true</e2e></root>');
|
|||||||
write('sample.csv', 'name,value\nkkFileView,1\ne2e,1\n');
|
write('sample.csv', 'name,value\nkkFileView,1\ne2e,1\n');
|
||||||
write('sample.html', '<!doctype html><html><body><h1>kkFileView fixture</h1></body></html>');
|
write('sample.html', '<!doctype html><html><body><h1>kkFileView fixture</h1></body></html>');
|
||||||
|
|
||||||
// archive fixtures (contains inner.txt) - generate if missing
|
// zip (contains txt) - only generate if missing to avoid noisy local diffs
|
||||||
const archiveWork = path.join(fixturesDir, 'archive-tmp');
|
const zipPath = path.join(fixturesDir, 'sample.zip');
|
||||||
fs.mkdirSync(archiveWork, { recursive: true });
|
if (!fs.existsSync(zipPath)) {
|
||||||
const innerFile = path.join(archiveWork, 'inner.txt');
|
const zipWork = path.join(fixturesDir, 'zip-tmp');
|
||||||
fs.writeFileSync(innerFile, 'kkFileView archive inner file');
|
fs.mkdirSync(zipWork, { recursive: true });
|
||||||
|
fs.writeFileSync(path.join(zipWork, 'inner.txt'), 'kkFileView zip inner file');
|
||||||
const ensureArchive = (name, generator) => {
|
|
||||||
const out = path.join(fixturesDir, name);
|
|
||||||
if (fs.existsSync(out)) return;
|
|
||||||
try {
|
try {
|
||||||
generator(out);
|
execFileSync('zip', ['-X', '-q', '-r', zipPath, 'inner.txt'], { cwd: zipWork });
|
||||||
} catch (err) {
|
|
||||||
try {
|
|
||||||
fs.rmSync(out, { force: true });
|
|
||||||
} catch {
|
} catch {
|
||||||
// ignore cleanup errors; original error will be rethrown
|
// fallback: keep going if zip is not available locally
|
||||||
}
|
}
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const buildDeterministicTar = (out, gzip = false) => {
|
|
||||||
const py = String.raw`import io, tarfile, gzip
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
out = Path(r'''${out}''')
|
|
||||||
inner_path = Path(r'''${innerFile}''')
|
|
||||||
data = inner_path.read_bytes()
|
|
||||||
use_gzip = ${gzip ? 'True' : 'False'}
|
|
||||||
|
|
||||||
if use_gzip:
|
|
||||||
with out.open('wb') as f:
|
|
||||||
with gzip.GzipFile(filename='', mode='wb', fileobj=f, mtime=0) as gz:
|
|
||||||
with tarfile.open(fileobj=gz, mode='w', format=tarfile.USTAR_FORMAT) as tf:
|
|
||||||
info = tarfile.TarInfo('inner.txt')
|
|
||||||
info.size = len(data)
|
|
||||||
info.mtime = 946684800 # 2000-01-01 00:00:00 UTC
|
|
||||||
info.uid = 0
|
|
||||||
info.gid = 0
|
|
||||||
info.uname = 'root'
|
|
||||||
info.gname = 'root'
|
|
||||||
tf.addfile(info, io.BytesIO(data))
|
|
||||||
else:
|
|
||||||
with tarfile.open(out, mode='w', format=tarfile.USTAR_FORMAT) as tf:
|
|
||||||
info = tarfile.TarInfo('inner.txt')
|
|
||||||
info.size = len(data)
|
|
||||||
info.mtime = 946684800 # 2000-01-01 00:00:00 UTC
|
|
||||||
info.uid = 0
|
|
||||||
info.gid = 0
|
|
||||||
info.uname = 'root'
|
|
||||||
info.gname = 'root'
|
|
||||||
tf.addfile(info, io.BytesIO(data))
|
|
||||||
`;
|
|
||||||
execFileSync('python3', ['-c', py]);
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
ensureArchive('sample.zip', out => {
|
|
||||||
execFileSync('zip', ['-X', '-q', '-r', out, 'inner.txt'], { cwd: archiveWork });
|
|
||||||
});
|
|
||||||
|
|
||||||
ensureArchive('sample.tar', out => {
|
|
||||||
buildDeterministicTar(out, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
ensureArchive('sample.tgz', out => {
|
|
||||||
buildDeterministicTar(out, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
ensureArchive('sample.7z', out => {
|
|
||||||
try {
|
|
||||||
execFileSync('7z', ['a', '-bd', '-y', out, 'inner.txt'], { cwd: archiveWork, stdio: 'ignore' });
|
|
||||||
} catch {
|
|
||||||
execFileSync('bsdtar', ['-a', '-cf', out, 'inner.txt'], { cwd: archiveWork });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to create archive fixtures. Ensure python3, zip, 7z (or bsdtar) are available in PATH.');
|
|
||||||
throw err instanceof Error ? err : new Error(String(err));
|
|
||||||
} finally {
|
|
||||||
fs.rmSync(archiveWork, { recursive: true, force: true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1x1 png
|
// 1x1 png
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import { test, expect, request as playwrightRequest } from '@playwright/test';
|
|
||||||
import type { APIRequestContext } from '@playwright/test';
|
|
||||||
|
|
||||||
const fixtureBase = process.env.FIXTURE_BASE_URL || 'http://127.0.0.1:18080';
|
|
||||||
const DEFAULT_MAX_MS = 15000;
|
|
||||||
const envMaxMs = Number(process.env.E2E_MAX_PREVIEW_MS);
|
|
||||||
const maxMs = Number.isFinite(envMaxMs) && envMaxMs >= 1 ? Math.floor(envMaxMs) : DEFAULT_MAX_MS;
|
|
||||||
|
|
||||||
function b64(v: string): string {
|
|
||||||
return Buffer.from(v).toString('base64');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function timedPreview(request: APIRequestContext, fileUrl: string) {
|
|
||||||
const started = Date.now();
|
|
||||||
const resp = await request.get(`/onlinePreview?url=${encodeURIComponent(b64(fileUrl))}`);
|
|
||||||
const elapsed = Date.now() - started;
|
|
||||||
return { resp, elapsed };
|
|
||||||
}
|
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
|
||||||
const api = await playwrightRequest.newContext();
|
|
||||||
const required = ['sample.txt', 'sample.docx', 'sample.xlsx'];
|
|
||||||
try {
|
|
||||||
for (const name of required) {
|
|
||||||
const resp = await api.get(`${fixtureBase}/${name}`);
|
|
||||||
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
await api.dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('perf: txt preview response under threshold', async ({ request }) => {
|
|
||||||
const { resp, elapsed } = await timedPreview(request, `${fixtureBase}/sample.txt`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
expect(elapsed).toBeLessThan(maxMs);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('perf: docx preview response under threshold', async ({ request }) => {
|
|
||||||
const { resp, elapsed } = await timedPreview(request, `${fixtureBase}/sample.docx`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
expect(elapsed).toBeLessThan(maxMs);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('perf: xlsx preview response under threshold', async ({ request }) => {
|
|
||||||
const { resp, elapsed } = await timedPreview(request, `${fixtureBase}/sample.xlsx`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
expect(elapsed).toBeLessThan(maxMs);
|
|
||||||
});
|
|
||||||
@@ -7,38 +7,18 @@ function b64(v: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function openPreview(request: any, fileUrl: string) {
|
async function openPreview(request: any, fileUrl: string) {
|
||||||
const encoded = encodeURIComponent(b64(fileUrl));
|
const encoded = b64(fileUrl);
|
||||||
return request.get(`/onlinePreview?url=${encoded}`);
|
return request.get(`/onlinePreview?url=${encoded}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
const api = await playwrightRequest.newContext();
|
const api = await playwrightRequest.newContext();
|
||||||
const required = [
|
const required = ['sample.txt', 'sample.docx', 'sample.xlsx', 'sample.pptx', 'sample.zip'];
|
||||||
'sample.txt',
|
|
||||||
'sample.md',
|
|
||||||
'sample.json',
|
|
||||||
'sample.xml',
|
|
||||||
'sample.csv',
|
|
||||||
'sample.html',
|
|
||||||
'sample.png',
|
|
||||||
'sample.docx',
|
|
||||||
'sample.xlsx',
|
|
||||||
'sample.pptx',
|
|
||||||
'sample.zip',
|
|
||||||
'sample.tar',
|
|
||||||
'sample.tgz',
|
|
||||||
'sample.7z',
|
|
||||||
'sample.rar',
|
|
||||||
];
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (const name of required) {
|
for (const name of required) {
|
||||||
const resp = await api.get(`${fixtureBase}/${name}`);
|
const resp = await api.get(`${fixtureBase}/${name}`);
|
||||||
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
expect(resp.ok(), `fixture missing or unavailable: ${name}`).toBeTruthy();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
await api.dispose();
|
await api.dispose();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('01 home/index reachable', async ({ request }) => {
|
test('01 home/index reachable', async ({ request }) => {
|
||||||
@@ -101,33 +81,13 @@ test('12 zip preview', async ({ request }) => {
|
|||||||
expect(resp.status()).toBe(200);
|
expect(resp.status()).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('13 tar preview', async ({ request }) => {
|
test('13 security: block 10.x host in onlinePreview', async ({ request }) => {
|
||||||
const resp = await openPreview(request, `${fixtureBase}/sample.tar`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('14 tgz preview', async ({ request }) => {
|
|
||||||
const resp = await openPreview(request, `${fixtureBase}/sample.tgz`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('15 7z preview', async ({ request }) => {
|
|
||||||
const resp = await openPreview(request, `${fixtureBase}/sample.7z`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('16 rar preview', async ({ request }) => {
|
|
||||||
const resp = await openPreview(request, `${fixtureBase}/sample.rar`);
|
|
||||||
expect(resp.status()).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('17 security: block 10.x host in onlinePreview', async ({ request }) => {
|
|
||||||
const resp = await openPreview(request, `http://10.1.2.3/a.pdf`);
|
const resp = await openPreview(request, `http://10.1.2.3/a.pdf`);
|
||||||
const body = await resp.text();
|
const body = await resp.text();
|
||||||
expect(body).toContain('不受信任');
|
expect(body).toContain('不受信任');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('18 security: block 10.x host in getCorsFile', async ({ request }) => {
|
test('14 security: block 10.x host in getCorsFile', async ({ request }) => {
|
||||||
const encoded = b64('http://10.1.2.3/a.pdf');
|
const encoded = b64('http://10.1.2.3/a.pdf');
|
||||||
const resp = await request.get(`/getCorsFile?urlPath=${encoded}`);
|
const resp = await request.get(`/getCorsFile?urlPath=${encoded}`);
|
||||||
const body = await resp.text();
|
const body = await resp.text();
|
||||||
|
|||||||
Reference in New Issue
Block a user