@@ -741,4 +741,134 @@ describe("1165: Jobs test filters and access", () => {
741741 j3 . datasetDetails . should . be . an ( "array" ) . to . have . lengthOf ( 3 ) ;
742742 } ) ;
743743 } ) ;
744+
745+ it ( "0120: Create job with a datasetList item missing pid should return 422 and validation error" , async ( ) => {
746+ return request ( appUrl )
747+ . post ( "/api/v4/Jobs" )
748+ . send ( {
749+ type : "dataset_access" ,
750+ ownerUser : "admin" ,
751+ ownerGroup : "admin" ,
752+ jobParams : {
753+ datasetList : [ { files : [ ] } ] ,
754+ } ,
755+ } )
756+ . set ( "Accept" , "application/json" )
757+ . auth ( accessTokenAdmin , { type : "bearer" } )
758+ . expect ( TestData . UnprocessableEntityStatusCode )
759+ . expect ( "Content-Type" , / j s o n / )
760+ . then ( ( res ) => {
761+ res . body . should . have . property ( "message" ) ;
762+ res . body . message . should . contain ( "Invalid dataset list." ) ;
763+ } ) ;
764+ } ) ;
765+
766+ it ( "0130: Create job with a datasetList item with empty pid should return 422 and validation error" , async ( ) => {
767+ return request ( appUrl )
768+ . post ( "/api/v4/Jobs" )
769+ . send ( {
770+ type : "dataset_access" ,
771+ ownerUser : "admin" ,
772+ ownerGroup : "admin" ,
773+ jobParams : {
774+ datasetList : [ { pid : "" , files : [ ] } ] ,
775+ } ,
776+ } )
777+ . set ( "Accept" , "application/json" )
778+ . auth ( accessTokenAdmin , { type : "bearer" } )
779+ . expect ( TestData . UnprocessableEntityStatusCode )
780+ . expect ( "Content-Type" , / j s o n / )
781+ . then ( ( res ) => {
782+ res . body . should . have . property ( "message" ) ;
783+ res . body . message . should . contain ( "Invalid dataset list." ) ;
784+ } ) ;
785+ } ) ;
786+
787+ it ( "0140: Create job with a datasetList item with non-string pid should return 422 and validation error" , async ( ) => {
788+ return request ( appUrl )
789+ . post ( "/api/v4/Jobs" )
790+ . send ( {
791+ type : "dataset_access" ,
792+ ownerUser : "admin" ,
793+ ownerGroup : "admin" ,
794+ jobParams : {
795+ datasetList : [ { pid : 12345 , files : [ ] } ] ,
796+ } ,
797+ } )
798+ . set ( "Accept" , "application/json" )
799+ . auth ( accessTokenAdmin , { type : "bearer" } )
800+ . expect ( TestData . UnprocessableEntityStatusCode )
801+ . expect ( "Content-Type" , / j s o n / )
802+ . then ( ( res ) => {
803+ res . body . should . have . property ( "message" ) ;
804+ res . body . message . should . contain ( "Invalid dataset list." ) ;
805+ } ) ;
806+ } ) ;
807+
808+ it ( "0150: Create job with a datasetList item with non-array files should return 422 and validation error" , async ( ) => {
809+ return request ( appUrl )
810+ . post ( "/api/v4/Jobs" )
811+ . send ( {
812+ type : "dataset_access" ,
813+ ownerUser : "admin" ,
814+ ownerGroup : "admin" ,
815+ jobParams : {
816+ datasetList : [ { pid : datasetPid1 , files : "not-an-array" } ] ,
817+ } ,
818+ } )
819+ . set ( "Accept" , "application/json" )
820+ . auth ( accessTokenAdmin , { type : "bearer" } )
821+ . expect ( TestData . UnprocessableEntityStatusCode )
822+ . expect ( "Content-Type" , / j s o n / )
823+ . then ( ( res ) => {
824+ res . body . should . have . property ( "message" ) ;
825+ res . body . message . should . contain ( "Invalid dataset list." ) ;
826+ } ) ;
827+ } ) ;
828+
829+ it ( "0160: Create job with a datasetList item with non-string entries in files array should return 422 and validation error" , async ( ) => {
830+ return request ( appUrl )
831+ . post ( "/api/v4/Jobs" )
832+ . send ( {
833+ type : "dataset_access" ,
834+ ownerUser : "admin" ,
835+ ownerGroup : "admin" ,
836+ jobParams : {
837+ datasetList : [ { pid : datasetPid1 , files : [ 123 , 456 ] } ] ,
838+ } ,
839+ } )
840+ . set ( "Accept" , "application/json" )
841+ . auth ( accessTokenAdmin , { type : "bearer" } )
842+ . expect ( TestData . UnprocessableEntityStatusCode )
843+ . expect ( "Content-Type" , / j s o n / )
844+ . then ( ( res ) => {
845+ res . body . should . have . property ( "message" ) ;
846+ res . body . message . should . contain ( "Invalid dataset list." ) ;
847+ } ) ;
848+ } ) ;
849+
850+ it ( "0170: Create job with multiple datasetList items where one has an invalid pid should return 422 and validation error listing the failing property" , async ( ) => {
851+ return request ( appUrl )
852+ . post ( "/api/v4/Jobs" )
853+ . send ( {
854+ type : "dataset_access" ,
855+ ownerUser : "admin" ,
856+ ownerGroup : "admin" ,
857+ jobParams : {
858+ datasetList : [
859+ { pid : datasetPid1 , files : [ ] } ,
860+ { pid : "" , files : [ ] } ,
861+ ] ,
862+ } ,
863+ } )
864+ . set ( "Accept" , "application/json" )
865+ . auth ( accessTokenAdmin , { type : "bearer" } )
866+ . expect ( TestData . UnprocessableEntityStatusCode )
867+ . expect ( "Content-Type" , / j s o n / )
868+ . then ( ( res ) => {
869+ res . body . should . have . property ( "message" ) ;
870+ res . body . message . should . contain ( "Invalid dataset list." ) ;
871+ res . body . message . should . contain ( "pid" ) ;
872+ } ) ;
873+ } ) ;
744874} ) ;
0 commit comments