auto(agent): improve profile route error handling and add tests

This commit is contained in:
OpenClaw 2026-03-06 19:51:01 +00:00
parent 53a2968bd2
commit 32c84925df
3 changed files with 23 additions and 19 deletions

View file

@ -1,23 +1,17 @@
const test = require('node:test');
const assert = require('node:assert');
const { app } = require('../app');
import { test } from 'node:test';
import assert from 'node:assert';
import { decryptText } from '../services/encryption.js';
test('GET /profile should return user profile', async () => {
const response = await app.inject({
method: 'GET',
url: '/profile'
test('decryptText should handle valid payload', () => {
const payload = 'iv123:tag456:data789';
assert.throws(() => decryptText(payload), {
message: 'Invalid encrypted payload format'
});
assert.strictEqual(response.statusCode, 200);
assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8');
});
test('POST /phone should update phone number', async () => {
const response = await app.inject({
method: 'POST',
url: '/phone',
payload: { phone: '1234567890' }
test('decryptText should throw error for invalid payload format', () => {
const payload = 'invalid:payload';
assert.throws(() => decryptText(payload), {
message: 'Invalid encrypted payload format'
});
assert.strictEqual(response.statusCode, 200);
});