@@ -623,6 +623,44 @@ describe('Parse.File testing', () => {
623
623
} ) ;
624
624
} ) ;
625
625
626
+ describe ( 'getting files' , ( ) => {
627
+ it ( 'does not crash on file request with invalid app ID' , async ( ) => {
628
+ const res1 = await request ( {
629
+ url : 'http://localhost:8378/1/files/invalid-id/invalid-file.txt' ,
630
+ } ) . catch ( e => e ) ;
631
+ expect ( res1 . status ) . toBe ( 403 ) ;
632
+ expect ( res1 . data ) . toEqual ( { code : 119 , error : 'Invalid application ID.' } ) ;
633
+ // Ensure server did not crash
634
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
635
+ expect ( res2 . status ) . toEqual ( 200 ) ;
636
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
637
+ } ) ;
638
+
639
+ it ( 'does not crash on file request with invalid path' , async ( ) => {
640
+ const res1 = await request ( {
641
+ url : 'http://localhost:8378/1/files/invalid-id//invalid-path/%20/invalid-file.txt' ,
642
+ } ) . catch ( e => e ) ;
643
+ expect ( res1 . status ) . toBe ( 403 ) ;
644
+ expect ( res1 . data ) . toEqual ( { error : 'unauthorized' } ) ;
645
+ // Ensure server did not crash
646
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
647
+ expect ( res2 . status ) . toEqual ( 200 ) ;
648
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
649
+ } ) ;
650
+
651
+ it ( 'does not crash on file metadata request with invalid app ID' , async ( ) => {
652
+ const res1 = await request ( {
653
+ url : `http://localhost:8378/1/files/invalid-id/metadata/invalid-file.txt` ,
654
+ } ) ;
655
+ expect ( res1 . status ) . toBe ( 200 ) ;
656
+ expect ( res1 . data ) . toEqual ( { } ) ;
657
+ // Ensure server did not crash
658
+ const res2 = await request ( { url : 'http://localhost:8378/1/health' } ) ;
659
+ expect ( res2 . status ) . toEqual ( 200 ) ;
660
+ expect ( res2 . data ) . toEqual ( { status : 'ok' } ) ;
661
+ } ) ;
662
+ } ) ;
663
+
626
664
xdescribe ( 'Gridstore Range tests' , ( ) => {
627
665
it ( 'supports range requests' , done => {
628
666
const headers = {
0 commit comments