auto(agent): enhance profile route tests and coverage
This commit is contained in:
parent
b4edaead35
commit
fb436cb3d6
3 changed files with 113 additions and 2 deletions
|
|
@ -15,3 +15,83 @@ test('decryptText should throw error for invalid payload format', () => {
|
||||||
message: 'Invalid encrypted payload format'
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
LAST_ROUTE=offers.js
|
LAST_ROUTE=profile.js
|
||||||
UPDATED_AT=2026-03-06T20:34:06Z
|
UPDATED_AT=2026-03-06T20:36:17Z
|
||||||
|
|
|
||||||
31
tailscale_kasm_integration.md
Normal file
31
tailscale_kasm_integration.md
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue