@@ -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 = / < L a s t M o d i f i e d > ( [ ^ < ] + ) < \/ L a s t M o d i f i e d > / 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