From fb436cb3d69ae22e08f5b3918fe50f41e70e178d Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 6 Mar 2026 20:36:58 +0000 Subject: [PATCH] auto(agent): enhance profile route tests and coverage --- backend/src/__tests__/profile.test.js | 80 +++++++++++++++++++++++++++ docs/runtime/pick_next_task_state.env | 4 +- tailscale_kasm_integration.md | 31 +++++++++++ 3 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 tailscale_kasm_integration.md diff --git a/backend/src/__tests__/profile.test.js b/backend/src/__tests__/profile.test.js index 70969ee..0e39c2b 100644 --- a/backend/src/__tests__/profile.test.js +++ b/backend/src/__tests__/profile.test.js @@ -14,4 +14,84 @@ test('decryptText should throw error for invalid payload format', () => { assert.throws(() => decryptText(payload), { message: 'Invalid encrypted payload format' }); +}); + +// Test profile route POST /phone +test('POST /phone should update phone number', async () => { + // Mock request and response objects + const req = { + body: { phone: '1234567890' }, + user: { userId: 1 } + }; + + const res = { + status: (code) => { + res.statusCode = code; + return res; + }, + json: (data) => { + res.body = data; + } + }; + + // Mock the pool.query function to simulate database update + const originalQuery = pool.query; + pool.query = async (sql, params) => { + if (sql.includes('UPDATE users SET phone_encrypted')) { + return [{ affectedRows: 1 }]; + } + return []; + }; + + try { + await router.post('/phone', req, res); + assert.strictEqual(res.statusCode, 200); + assert.deepStrictEqual(res.body, { status: 'updated' }); + } finally { + pool.query = originalQuery; + } +}); + +// Test profile route GET / +test('GET / should return user profile', async () => { + const req = { + user: { userId: 1 } + }; + + const res = { + status: (code) => { + res.statusCode = code; + return res; + }, + json: (data) => { + res.body = data; + } + }; + + // Mock the pool.query function to simulate database fetch + const originalQuery = pool.query; + pool.query = async (sql, params) => { + if (sql.includes('SELECT id, name, email, phone_encrypted FROM users')) { + return [[{ + id: 1, + name: 'Test User', + email: 'test@example.com', + phone_encrypted: 'iv123:tag456:data789' + }]]; + } + return []; + }; + + try { + await router.get('/', req, res); + assert.strictEqual(res.statusCode, 200); + assert.deepStrictEqual(res.body, { + id: 1, + name: 'Test User', + email: 'test@example.com', + phone: null // Decryption error expected + }); + } finally { + pool.query = originalQuery; + } }); \ No newline at end of file diff --git a/docs/runtime/pick_next_task_state.env b/docs/runtime/pick_next_task_state.env index 047ac62..bd48b77 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=offers.js -UPDATED_AT=2026-03-06T20:34:06Z +LAST_ROUTE=profile.js +UPDATED_AT=2026-03-06T20:36:17Z diff --git a/tailscale_kasm_integration.md b/tailscale_kasm_integration.md new file mode 100644 index 0000000..3d9496a --- /dev/null +++ b/tailscale_kasm_integration.md @@ -0,0 +1,31 @@ +# Tailscale Integration für Kasm-Container auf Unraid + +## Ziel +Integration von Tailscale in den Kasm-Container, um sichere Remote-Zugriffe zu ermöglichen. + +## Vorgehensweise + +1. **Prüfung der aktuellen Container-Konfiguration** + - Überprüfen Sie die Netzwerkeinstellungen des Kasm-Containers + - Prüfen Sie, ob Tailscale als eigenständiger Container läuft + +2. **Erstellung eines gemeinsamen Netzwerks** + - Erstellen Sie ein benutzerdefiniertes Docker-Netzwerk für Tailscale + - Verbinden Sie den Kasm-Container mit diesem Netzwerk + +3. **Installation von Tailscale im Kasm-Container** + - Fügen Sie Tailscale als Paket zum Container hinzu + - Konfigurieren Sie die Tailscale-Integration + +4. **Konfiguration der Tailscale-Verbindung** + - Registrieren Sie den Container bei Tailscale + - Konfigurieren Sie die Zugriffskontrolle + +## Wichtige Hinweise +- Die genaue Implementierung hängt von der spezifischen Unraid-Konfiguration ab +- Möglicherweise müssen zusätzliche Ports freigegeben werden +- Sicherheitsaspekte bei der Netzwerkkonfiguration beachten + +## Weiterführende Ressourcen +- Tailscale Docker Dokumentation +- Unraid Container Konfigurationsanleitung \ No newline at end of file