Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Portal: Reconnect replaces New keys and the connection sheet (QR, Key,
File, and the menu's QR, key and .conf items). It gives the device new
keys, shows it as "Not set up yet" until it connects with them (in the
admin too) and opens the set-up sheet on the new configuration; "Update
the connection" goes the same way. Reconnect is orange in the menu
- iPhone: "Open in AmneziaVPN" is "Send to AmneziaVPN": the key goes in as
a .vpn file from the share sheet. AmneziaVPN takes vpn:// links only on
Android; on iOS Safari said the address was invalid, or another app that
claims vpn:// got the key. The desktop "Open in AmneziaVPN" link is gone
- A computer set up from a phone: get the app, add the connection, then
"Or open your link on the computer"; "Another app" offers AmneziaWG and
WireGuard there too and step 2 follows the pick. "Other" devices pick any
system (iPhone/iPad, Android, Windows, Mac, Linux); the page counts as the
device in hand only when the pick is its own system
- Import steps in each app's own words (iOS "+ → Create from file or
archive", Android "+ → Import from file or archive", Mac, Windows "Add
Tunnel → Import tunnel(s) from file"); Linux gets the awg-quick command
- Files are shared only on iOS (on Android the apps take no shared files:
a download there), and alone: with a title, "Save to Files" also wrote
the title as a .txt
- Files and tunnels are named after the server ("Outline Home" →
Outline-Home.conf and .vpn) in the form every client accepts: letters,
digits and "-", 15 characters, no Windows device names. The admin's
downloads keep the device in the name. The AmneziaVPN key's description
is the server's name alone
- The AmneziaVPN QR code holds the key without "vpn://": AmneziaVPN's
scanner decodes the text as it is and failed on the prefix
- "This device" also when the page is opened beside the tunnel: the apps
route the VPN's own address, which the portal shares, around their
tunnel, so the one online device whose tunnel comes from the page's
address is the one
- Fixed: "Already has AmneziaVPN?Copy the key" lost its space
118 lines
5.4 KiB
TypeScript
118 lines
5.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import {
|
||
appsFor,
|
||
deviceNoun,
|
||
importPath,
|
||
importSteps,
|
||
inWebview,
|
||
keyFileName,
|
||
opensKeyLinks,
|
||
osGroup,
|
||
platformOf,
|
||
sameDevice,
|
||
scanPath,
|
||
setupFromHash,
|
||
setupLink,
|
||
storeFor,
|
||
updateLine,
|
||
} from '../src/portal/setup';
|
||
|
||
const IPHONE =
|
||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1';
|
||
const IPAD_AS_MAC = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15';
|
||
const ANDROID = 'Mozilla/5.0 (Linux; Android 14; SM-S921B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Mobile Safari/537.36';
|
||
const WINDOWS = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36';
|
||
const LINUX = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36';
|
||
|
||
describe('setup', () => {
|
||
it('reads the platform from the browser, iPad included', () => {
|
||
expect(platformOf(IPHONE)).toBe('ios');
|
||
expect(platformOf(IPAD_AS_MAC, 5)).toBe('ios');
|
||
expect(platformOf(IPAD_AS_MAC, 0)).toBe('mac');
|
||
expect(platformOf(ANDROID)).toBe('android');
|
||
expect(platformOf(WINDOWS)).toBe('windows');
|
||
expect(platformOf(LINUX)).toBe('linux');
|
||
expect(platformOf('Mozilla/5.0 (X11; CrOS x86_64)')).toBe('unknown');
|
||
});
|
||
|
||
it('links straight to the set-up of a device through the fragment, and reads only that back', () => {
|
||
const page = 'https://engage.example.eu:4500/abcdef-ghijkl-mnopqr';
|
||
expect(setupLink(page, 'd_bf0b30e9')).toBe(`${page}#setup=d_bf0b30e9`);
|
||
expect(setupFromHash('#setup=d_bf0b30e9')).toBe('d_bf0b30e9');
|
||
expect(setupFromHash('')).toBeNull();
|
||
expect(setupFromHash('#setup=')).toBeNull();
|
||
expect(setupFromHash('#setup=d_bf0b30e9&x=1')).toBeNull();
|
||
expect(setupFromHash('#setup=../../api')).toBeNull();
|
||
});
|
||
|
||
it('names the device being set up by its kind, not its name', () => {
|
||
expect(deviceNoun('phone')).toBe('phone');
|
||
expect(deviceNoun('computer')).toBe('computer');
|
||
expect(deviceNoun('other')).toBe('device');
|
||
});
|
||
|
||
it('knows whether the page is open on the device being set up', () => {
|
||
expect(sameDevice('phone', 'ios')).toBe(true);
|
||
expect(sameDevice('phone', 'mac')).toBe(false);
|
||
expect(sameDevice('computer', 'windows')).toBe(true);
|
||
expect(sameDevice('computer', 'android')).toBe(false);
|
||
expect(sameDevice('router', 'linux')).toBe(false);
|
||
expect(sameDevice('phone', 'unknown')).toBe(false);
|
||
});
|
||
|
||
it('lets the person pick the system of a computer or an "other" device', () => {
|
||
expect(osGroup('computer')).toEqual(['windows', 'mac', 'linux']);
|
||
expect(osGroup('other')).toEqual(['ios', 'android', 'windows', 'mac', 'linux']);
|
||
expect(osGroup('phone')).toEqual([]);
|
||
expect(osGroup('router')).toEqual([]);
|
||
});
|
||
|
||
it('lists the apps a disguise allows, AmneziaVPN first', () => {
|
||
expect(appsFor('max').map((a) => a.id)).toEqual(['vpn', 'awg']);
|
||
expect(appsFor('off').map((a) => a.id)).toEqual(['vpn', 'awg', 'wg']);
|
||
expect(appsFor('balanced')[0].need).toBe('4.8.12');
|
||
expect(updateLine(appsFor('balanced')[0])).toContain('4.8.12 or newer');
|
||
expect(updateLine(appsFor('max')[0])).toContain('the current version');
|
||
expect(updateLine(appsFor('off')[0])).toBe('');
|
||
});
|
||
|
||
it('sends people to the store first and to GitHub where no store has the app', () => {
|
||
expect(storeFor('vpn', 'ios')?.mark).toBe('appstore');
|
||
expect(storeFor('vpn', 'android')?.alt?.mark).toBe('github');
|
||
expect(storeFor('vpn', 'windows')?.href).toContain('github.com/amnezia-vpn/amnezia-client');
|
||
expect(storeFor('awg', 'mac')?.main).toBe('Mac App Store');
|
||
expect(storeFor('wg', 'ios')?.alt).toBeUndefined();
|
||
expect(storeFor('vpn', 'unknown')).toBeNull();
|
||
});
|
||
|
||
it('opens vpn:// links only where AmneziaVPN registers them, and names the key file for the rest', () => {
|
||
expect(opensKeyLinks('android')).toBe(true);
|
||
expect(opensKeyLinks('ios')).toBe(false);
|
||
expect(opensKeyLinks('windows')).toBe(false);
|
||
expect(opensKeyLinks('mac')).toBe(false);
|
||
expect(keyFileName('outline-iphone.conf')).toBe('outline-iphone.vpn');
|
||
expect(keyFileName('home')).toBe('home.vpn');
|
||
});
|
||
|
||
it('words the import as each platform’s app does', () => {
|
||
expect(importPath('awg', 'ios')).toBe('+ → Create from file or archive');
|
||
expect(importPath('awg', 'android')).toBe('+ → Import from file or archive');
|
||
expect(importPath('wg', 'windows')).toBe('Add Tunnel → Import tunnel(s) from file');
|
||
expect(importPath('vpn', 'ios')).toBe('Add server → Insert key');
|
||
expect(scanPath('awg', 'android')).toBe('+ → Scan from QR code');
|
||
expect(scanPath('awg')).toBe('+ → Create from QR code (Android: Scan from QR code)');
|
||
expect(importSteps('awg', 'mac', 'Outline-Home.conf', false)).toEqual([
|
||
['Open AmneziaWG', ''],
|
||
['+ → ', 'Import tunnel(s) from file'],
|
||
['Pick the file and connect', ''],
|
||
]);
|
||
expect(importSteps('awg', 'linux', 'Outline-Home.conf', false)[1]).toEqual(['Run ', 'sudo awg-quick up ./Outline-Home.conf']);
|
||
expect(importSteps('wg', 'linux', 'Outline-Home.conf', false)[1][1]).toContain('wg-quick up');
|
||
});
|
||
|
||
it('spots in-app browsers', () => {
|
||
expect(inWebview(`${ANDROID} Telegram-Android/10.0`)).toBe(true);
|
||
expect(inWebview(IPHONE)).toBe(false);
|
||
});
|
||
});
|