okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Removing the API key while sharing or Cloudflare runs is allowed (the key is optional); the remove dialog warns plainlya4f797532

main
1.3 KiB23 linesraw
1/** The API key is optional (owner decision, 0.2.2): removing it while sharing or the Cloudflare tunnel runs is allowed, and the key stays removed. */
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { mkdtempSync, rmSync } from 'node:fs';
5import { tmpdir } from 'node:os';
6import { join } from 'node:path';
7
8const home = mkdtempSync(join(tmpdir(), 'strata-serving-key-'));
9process.env.STRATA_HOME = home;
10const serving = await import('../server/serving.mjs');
11
12test('removing the API key while local sharing and the tunnel run is allowed', () => {
13  serving.init({ send() {} }, { port: 8080, host: '127.0.0.1' });
14  serving.patch({ generateKey: true });
15  assert.equal(serving.state().access.apiKeySet, true);
16  serving.setSharing({ active: true, url: 'http://192.168.1.5:8792/v1' });
17  serving.setTunnel({ status: 'connected', mode: 'quick', url: 'https://example.trycloudflare.com', error: null, installed: true, originUrl: null });
18  assert.equal(serving.state().access.otherDevices, true);
19  const after = serving.patch({ apiKey: null });
20  assert.equal(after.access.apiKeySet, false);
21  assert.equal(serving.authorized({ headers: {} }), true);
22});
23test.after(() => { try { rmSync(home, { recursive: true, force: true }); } catch { /* temp folder */ } });