@@ -654,6 +654,44 @@ describe('Parse.File testing', () => {
654
654
} ) ;
655
655
} ) ;
656
656
657
+ describe ( 'getting files' , ( ) => {
658
+ it ( 'does not crash on file request with invalid app ID' , async ( ) => {
659
+ const res1 = await request ( {
660
+ url : 'http://localhost:8378/1/files/invalid-id/invalid-file.txt' ,
661
+ } ) . catch ( e => e ) ;
662
+ expect ( res1 . status ) . toBe ( 403 ) ;
663
+ expect ( res1 . data ) . toEqual ( { code : 119 , error : 'Invalid application ID.' } ) ;
664
+ // Ensure server did not crash
665
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
666
+ expect ( res2 . status ) . toEqual ( 200 ) ;
667
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
668
+ } ) ;
669
+
670
+ it ( 'does not crash on file request with invalid path' , async ( ) => {
671
+ const res1 = await request ( {
672
+ url : 'http://localhost:8378/1/files/invalid-id//invalid-path/%20/invalid-file.txt' ,
673
+ } ) . catch ( e => e ) ;
674
+ expect ( res1 . status ) . toBe ( 403 ) ;
675
+ expect ( res1 . data ) . toEqual ( { error : 'unauthorized' } ) ;
676
+ // Ensure server did not crash
677
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
678
+ expect ( res2 . status ) . toEqual ( 200 ) ;
679
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
680
+ } ) ;
681
+
682
+ it ( 'does not crash on file metadata request with invalid app ID' , async ( ) => {
683
+ const res1 = await request ( {
684
+ url : `http://localhost:8378/1/files/invalid-id/metadata/invalid-file.txt` ,
685
+ } ) ;
686
+ expect ( res1 . status ) . toBe ( 200 ) ;
687
+ expect ( res1 . data ) . toEqual ( { } ) ;
688
+ // Ensure server did not crash
689
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
690
+ expect ( res2 . status ) . toEqual ( 200 ) ;
691
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
692
+ } ) ;
693
+ } ) ;
694
+
657
695
xdescribe ( 'Gridstore Range tests' , ( ) => {
658
696
it ( 'supports range requests' , done => {
659
697
const headers = {
0 commit comments