nexstream-api / backend /tests /api /keychanger.fuzz.test.ts
circleci
deploy ccb248c
65fc551
Raw
History Blame Contribute Delete
815 Bytes
import { describe, it, expect } from 'vitest';
import request from 'supertest';
import app from '../../src/app.js';
import path from 'node:path';
describe('KeyChanger API - Fuzzing & Corrupt Payloads', () => {
it('POST /api/key-changer/convert should gracefully reject non-audio payloads without crashing', async () => {
// corrupt file
const corruptFilePath = path.resolve(
__dirname,
'../fixtures/audio/corrupted_payload.mp3'
);
const res = await request(app)
.post('/api/key-changer/convert')
.attach('song', corruptFilePath)
.field('originalKey', 'C')
.field('targetKey', 'G');
// verify error
// check 500
expect(res.status).toBe(500);
expect(res.body.error).toBeDefined();
expect(res.body.success).toBeUndefined();
}, 10000);
});