Skip to content

Commit 6002c51

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.
1 parent adc7c94 commit 6002c51

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
@@ -493,6 +493,44 @@ describe('Veeam routes - LIST request handling', () => {
493493
});
494494
});
495495

496+
it('should emit LastModified in ISO 8601 format in XML body', done => {
497+
const request = createRequest();
498+
const response = createResponse();
499+
500+
const xmlChunks = [];
501+
response.write.callsFake(chunk => {
502+
xmlChunks.push(Buffer.isBuffer(chunk) ? chunk.toString() : String(chunk));
503+
return true;
504+
});
505+
506+
listVeeamFiles(request, response, bucketMd, log);
507+
508+
giveAsyncCallbackTimeToExecute(() => {
509+
assert(response.writeHead.calledWith(200), 'should return 200');
510+
511+
const body = xmlChunks.join('');
512+
assert(body.length > 0, 'response body should not be empty');
513+
514+
const lastModifiedRegex = /<LastModified>([^<]+)<\/LastModified>/g;
515+
const matches = [];
516+
let match;
517+
while ((match = lastModifiedRegex.exec(body)) !== null) {
518+
matches.push(match[1]);
519+
}
520+
521+
assert.strictEqual(matches.length, 3,
522+
'should have 3 LastModified entries (system.xml, capacity.xml, folder)');
523+
524+
const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
525+
matches.forEach(value => {
526+
assert(iso8601Regex.test(value),
527+
`LastModified "${value}" should be in ISO 8601 format`);
528+
});
529+
530+
done();
531+
});
532+
});
533+
496534
it('should handle versions query parameter', done => {
497535
const request = createRequest({ versions: '' });
498536
const response = createResponse();

0 commit comments

Comments
 (0)