85 lines
4.9 KiB
JavaScript
85 lines
4.9 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const styles = fs.readFileSync(path.join(root, 'styles.css'), 'utf8');
|
|
const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
|
|
const app = fs.readFileSync(path.join(root, 'app.js'), 'utf8');
|
|
const transport = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'AndroidMailTransport.kt'), 'utf8');
|
|
const mainActivity = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'MainActivity.java'), 'utf8');
|
|
const plugin = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'EpMailPlugin.kt'), 'utf8');
|
|
const androidMailService = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'AndroidMailService.kt'), 'utf8');
|
|
const productivity = fs.readFileSync(path.join(root, 'productivity.js'), 'utf8');
|
|
const androidBridge = fs.readFileSync(path.join(root, 'scripts', 'android-bridge.js'), 'utf8');
|
|
const androidPgp = fs.readFileSync(path.join(root, 'scripts', 'android-pgp.js'), 'utf8');
|
|
const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
|
|
|
test('mobile layout removes desktop minimum width and provides a compact reader flow', () => {
|
|
assert.match(styles, /min-width:320px/);
|
|
assert.match(styles, /@media\(max-width:1000px\),\(max-height:500px\) and \(orientation:landscape\)/);
|
|
assert.match(styles, /@media\(max-height:500px\) and \(orientation:landscape\)/);
|
|
assert.match(styles, /overflow-wrap:anywhere;word-break:break-word/);
|
|
assert.match(styles, /\.hidden,\[hidden\]\{display:none!important\}/);
|
|
assert.match(styles, /body\.reader-open \.mail-layout \.list-pane/);
|
|
assert.match(app, /id="reader-back"/);
|
|
assert.match(app, /classList\.add\('reader-open'\)/);
|
|
assert.match(app, /\$\$\('\.folder'\)\.forEach/);
|
|
assert.match(app, /if\(!m\)\{state\.activeMessage=null;document\.body\.classList\.remove\('reader-open'\);return;\}/);
|
|
});
|
|
|
|
test('mailbox setup exposes ports and TLS modes and submits them to Android', () => {
|
|
for (const id of ['mail-account-imap-port', 'mail-account-imap-secure', 'mail-account-smtp-port', 'mail-account-smtp-secure']) {
|
|
assert.ok(mailUi.includes(`id="${id}"`), `missing account field ${id}`);
|
|
}
|
|
assert.match(mailUi, /imapPort,/);
|
|
assert.match(mailUi, /imapSecure:/);
|
|
assert.match(mailUi, /smtpPort,/);
|
|
assert.match(mailUi, /smtpSecure:/);
|
|
});
|
|
|
|
test('Android mail transport supports verified implicit TLS and required STARTTLS modes', () => {
|
|
assert.match(transport, /"imaps" else "imap"/);
|
|
assert.match(transport, /mail\.\$protocol\.starttls\.required/);
|
|
assert.match(transport, /mail\.smtp\.ssl\.enable/);
|
|
assert.match(transport, /mail\.smtp\.starttls\.required/);
|
|
assert.match(transport, /ssl\.checkserveridentity/);
|
|
});
|
|
|
|
test('Capacitor mail plugin is registered before BridgeActivity creates the bridge', () => {
|
|
assert.ok(mainActivity.indexOf('registerPlugin(EpMailPlugin.class)') < mainActivity.indexOf('super.onCreate(savedInstanceState)'));
|
|
});
|
|
|
|
test('OpenPGP.js is pinned to the exact version in the lockfile pending security review', () => {
|
|
assert.equal(packageJson.dependencies.openpgp, packageLock.packages['node_modules/openpgp'].version);
|
|
assert.match(packageJson.dependencies.openpgp, /^\d+\.\d+\.\d+$/);
|
|
});
|
|
|
|
test('Android app lock is native-enforced and requires a secure device credential', () => {
|
|
assert.match(plugin, /fun getAppLockSettings/);
|
|
assert.match(plugin, /fun setAppLockEnabled/);
|
|
assert.match(plugin, /keyguard\.isDeviceSecure/);
|
|
assert.match(mainActivity, /setJavaScriptEnabled\(false\)/);
|
|
assert.match(mainActivity, /createConfirmDeviceCredentialIntent/);
|
|
assert.match(mainActivity, /android\.R\.id\.content/);
|
|
assert.match(androidBridge, /getAppLockSettings/);
|
|
assert.match(androidBridge, /setAppLockEnabled/);
|
|
assert.match(productivity, /Lock when leaving ep-mail/);
|
|
});
|
|
|
|
test('Android OpenPGP uses the encrypted vault and queues only built MIME data', () => {
|
|
assert.match(plugin, /fun pgpLoadStore/);
|
|
assert.match(plugin, /fun pgpSaveStore/);
|
|
assert.match(plugin, /fun pgpGetMessageSource/);
|
|
assert.match(androidPgp, /curve25519Legacy/);
|
|
assert.match(androidPgp, /multipart\/encrypted/);
|
|
assert.match(androidPgp, /MAX_MESSAGE_BYTES = 25 \* 1024 \* 1024/);
|
|
assert.match(androidBridge, /buildOutgoing\(message\)/);
|
|
assert.match(androidBridge, /rawBase64, envelope: \{ from, to \}, text: '', attachments: \[\]/);
|
|
assert.match(androidMailService, /Only an OpenPGP MIME message can use the encrypted send path/);
|
|
assert.match(androidMailService, /"send" -> send\(account, data\)/);
|
|
assert.match(androidMailService, /private fun isEncryptedMessage/);
|
|
});
|