File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -2334,6 +2334,10 @@ class File extends ServiceObject<File> {
23342334
23352335 const method = ActionToHTTPMethod [ cfg . action ] ;
23362336
2337+ if ( ! method ) {
2338+ throw new Error ( 'The action is not provided or invalid.' ) ;
2339+ }
2340+
23372341 const name = encodeURIComponent ( this . name ) ;
23382342 const resource = `/${ this . bucket . name } /${ name } ` ;
23392343
Original file line number Diff line number Diff line change @@ -2556,6 +2556,28 @@ describe('File', () => {
25562556 } , / I n v a l i d s i g n e d U R L v e r s i o n : v 4 2 \. S u p p o r t e d v e r s i o n s a r e ' v 2 ' a n d ' v 4 ' \. / ) ;
25572557 } ) ;
25582558
2559+ it ( 'should error if action is null' , ( ) => {
2560+ const config = Object . assign ( { } , CONFIG , { action : null } ) ;
2561+ assert . throws ( ( ) => {
2562+ file . getSignedUrl ( config , ( ) => { } ) ;
2563+ } , / T h e a c t i o n i s n o t p r o v i d e d o r i n v a l i d ./ ) ;
2564+ } ) ;
2565+
2566+ it ( 'should error if action is undefined' , ( ) => {
2567+ const config = Object . assign ( { } , CONFIG ) ;
2568+ delete config . action ;
2569+ assert . throws ( ( ) => {
2570+ file . getSignedUrl ( config , ( ) => { } ) ;
2571+ } , / T h e a c t i o n i s n o t p r o v i d e d o r i n v a l i d ./ ) ;
2572+ } ) ;
2573+
2574+ it ( 'should error for an invalid action' , ( ) => {
2575+ const config = Object . assign ( { } , CONFIG , { action : 'watch' } ) ;
2576+ assert . throws ( ( ) => {
2577+ file . getSignedUrl ( config , ( ) => { } ) ;
2578+ } , / T h e a c t i o n i s n o t p r o v i d e d o r i n v a l i d ./ ) ;
2579+ } ) ;
2580+
25592581 describe ( 'v4 signed URL' , ( ) => {
25602582 beforeEach ( ( ) => {
25612583 CONFIG . version = 'v4' ;
You can’t perform that action at this time.
0 commit comments