Skip to content

Commit 4f11a1f

Browse files
test: assert LastModified is ISO 8601 in LIST XML response
Add a regression test that captures the XML body from the LIST route and verifies all LastModified values match ISO 8601 format, preventing the RFC 2822 date format bug from recurring. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent adc7c94 commit 4f11a1f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/unit/routes/veeam-routes.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,44 @@ describe('Veeam routes - LIST request handling', () => {
532532
});
533533
});
534534

535+
it('should emit LastModified in ISO 8601 format in XML body', done => {
536+
const request = createRequest();
537+
const response = createResponse();
538+
539+
const xmlChunks = [];
540+
response.write.callsFake(chunk => {
541+
xmlChunks.push(Buffer.isBuffer(chunk) ? chunk.toString() : String(chunk));
542+
return true;
543+
});
544+
545+
listVeeamFiles(request, response, bucketMd, log);
546+
547+
giveAsyncCallbackTimeToExecute(() => {
548+
assert(response.writeHead.calledWith(200), 'should return 200');
549+
550+
const body = xmlChunks.join('');
551+
assert(body.length > 0, 'response body should not be empty');
552+
553+
const lastModifiedRegex = /<LastModified>([^<]+)<\/LastModified>/g;
554+
const matches = [];
555+
let match;
556+
while ((match = lastModifiedRegex.exec(body)) !== null) {
557+
matches.push(match[1]);
558+
}
559+
560+
assert(matches.length > 0,
561+
'XML body should contain LastModified elements');
562+
563+
const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
564+
matches.forEach(value => {
565+
assert(iso8601Regex.test(value),
566+
`LastModified "${value}" should be in ISO 8601 format`);
567+
});
568+
569+
done();
570+
});
571+
});
572+
535573
it('should list only available files when some capabilities are missing', done => {
536574
const bucketMdOnlySystem = {
537575
...bucketMd,

0 commit comments

Comments
 (0)