Skip to content

Commit 9684045

Browse files
committed
Merge branch 'bugfix/CLDSRV-857/last-modified-format' into q/9.3
2 parents a9e6f70 + 6002c51 commit 9684045

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

lib/routes/veeam/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function buildXMLResponse(request, arrayOfFiles, versioned = false) {
3838
value: {
3939
IsDeleteMarker: false,
4040
IsNull: true,
41-
LastModified: file['Last-Modified'],
41+
LastModified: new Date(file['Last-Modified']).toISOString(),
4242
// Generated ETag alrady contains quotes, removing them here
4343
ETag: file.ETag.substring(1, file.ETag.length - 1),
4444
Size: file['Content-Length'],

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)