فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(A07): exercise correct WebView2 origin parsing and remote-origin rejection

davoodmehraban89 committed Oct 16, 2026 at 19:10 UTC beaaa9fdb3902945e6d5c5a3d7d6df486f4ec49f
1 file changed +29
tests/windows-vm-native-origin.test.mjs new
+29
@@ -0,0 +1,29 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { createRequire } from 'node:module';
4 +const require = createRequire(import.meta.url);
5 +const { verifyNativeOrigin } = require('./windows-vm-native-origin.cjs');
6 +
7 +test('A07: accepts only packaged Tauri local document origins', () => {
8 + assert.equal(verifyNativeOrigin('http://tauri.localhost/#dashboard'),
9 + 'http://tauri.localhost');
10 + assert.equal(verifyNativeOrigin('https://tauri.localhost/invoices?test=1'),
11 + 'https://tauri.localhost');
12 + const scheme = verifyNativeOrigin('tauri://localhost/index.html');
13 + assert.ok(scheme.startsWith('tauri:'));
14 +});
15 +
16 +test('A07: rejects remote origins, deceptive subdomains, credentials and malformed URLs', () => {
17 + for (const url of [
18 + 'https://some-remote-service.example/login',
19 + 'https://tauri.localhost.attack.test/',
20 + 'http://localhost:4173/',
21 + 'https://tauri.localhost@attacker.example/',
22 + 'https://bob:secret@tauri.localhost/',
23 + 'about:blank', 'file:///c:/windows/system32',
24 + '//tauri.localhost/dashboard',
25 + 'bad-url'
26 + ]) {
27 + assert.throws(() => verifyNativeOrigin(url), Error, url);
28 + }
29 +});