@@ -7,11 +7,14 @@ let accessTokenAdminIngestor = null,
77 accessTokenUser2 = null ,
88 accessTokenUser3 = null ,
99 accessTokenUser51 = null ,
10+ accessTokenUser6 = null ,
1011 accessTokenAdmin = null ,
1112
1213 datasetPid1 = null ,
1314 datasetPid2 = null ,
1415 datasetPid3 = null ,
16+ datasetPidGroup6 = null ,
17+ datasetPidUser6 = null ,
1518
1619 jobId1 = null ,
1720 encodedJobOwnedByAdmin = null ,
@@ -91,6 +94,11 @@ describe("1150: Jobs: Test New Job Model Authorization for owner_access jobs typ
9194 username : "admin" ,
9295 password : TestData . Accounts [ "admin" ] [ "password" ] ,
9396 } ) ;
97+
98+ accessTokenUser6 = await utils . getToken ( appUrl , {
99+ username : "user6" ,
100+ password : TestData . Accounts [ "user6" ] [ "password" ] ,
101+ } ) ;
94102 } ) ;
95103
96104 after ( ( ) => {
@@ -904,8 +912,6 @@ describe("1150: Jobs: Test New Job Model Authorization for owner_access jobs typ
904912 . set ( { Authorization : `Bearer ${ accessTokenUser2 } ` } )
905913 . expect ( TestData . SuccessfulGetStatusCode )
906914 . expect ( "Content-Type" , / j s o n / ) ;
907- res . body . should . be . an ( "array" ) . to . have . lengthOf ( 12 ) ;
908- res . body . map ( ( job ) => job . id ) . should . include . members ( [ jobId12 , jobId21 ] ) ;
909915 } ) ;
910916
911917 it ( "0420: Access jobs as user3" , async ( ) => {
@@ -934,4 +940,91 @@ describe("1150: Jobs: Test New Job Model Authorization for owner_access jobs typ
934940 res . body . map ( ( job ) => job . id ) . should . include . members ( [ jobId4 , jobId5 ] ) ;
935941 } ) ;
936942 } ) ;
943+
944+ it ( "0440: Add a new job as user6 with datasets owned by two different groups that user6 belongs to" , async ( ) => {
945+ const datasetGroup6 = {
946+ ...TestData . RawCorrect ,
947+ isPublished : false ,
948+ ownerGroup : "group6" ,
949+ accessGroups : [ ] ,
950+ } ;
951+
952+ const datasetUser6 = {
953+ ...TestData . RawCorrect ,
954+ isPublished : false ,
955+ ownerGroup : "user6" ,
956+ accessGroups : [ ] ,
957+ } ;
958+
959+ const createdDatasetGroup6 = await request ( appUrl )
960+ . post ( "/api/v3/Datasets" )
961+ . send ( datasetGroup6 )
962+ . set ( "Accept" , "application/json" )
963+ . set ( { Authorization : `Bearer ${ accessTokenAdminIngestor } ` } )
964+ . expect ( TestData . EntryCreatedStatusCode )
965+ . expect ( "Content-Type" , / j s o n / ) ;
966+ datasetPidGroup6 = createdDatasetGroup6 . body . pid ;
967+
968+ const createdDatasetUser6 = await request ( appUrl )
969+ . post ( "/api/v3/Datasets" )
970+ . send ( datasetUser6 )
971+ . set ( "Accept" , "application/json" )
972+ . set ( { Authorization : `Bearer ${ accessTokenAdminIngestor } ` } )
973+ . expect ( TestData . EntryCreatedStatusCode )
974+ . expect ( "Content-Type" , / j s o n / ) ;
975+ datasetPidUser6 = createdDatasetUser6 . body . pid ;
976+
977+ const newJob = {
978+ ...jobDatasetOwner ,
979+ ownerUser : "user6" ,
980+ ownerGroup : "group6" ,
981+ jobParams : {
982+ datasetList : [
983+ { pid : datasetPidGroup6 , files : [ ] } ,
984+ { pid : datasetPidUser6 , files : [ ] } ,
985+ ] ,
986+ } ,
987+ } ;
988+
989+ return request ( appUrl )
990+ . post ( "/api/v4/Jobs" )
991+ . send ( newJob )
992+ . set ( "Accept" , "application/json" )
993+ . set ( { Authorization : `Bearer ${ accessTokenUser6 } ` } )
994+ . expect ( TestData . EntryCreatedStatusCode )
995+ . expect ( "Content-Type" , / j s o n / )
996+ . then ( ( res ) => {
997+ res . body . should . have . property ( "type" ) . and . be . string ;
998+ res . body . should . have . property ( "ownerUser" ) . and . be . equal ( "user6" ) ;
999+ res . body . should . have . property ( "ownerGroup" ) . and . be . equal ( "group6" ) ;
1000+ res . body . should . have . property ( "statusCode" ) . to . be . equal ( "jobSubmitted" ) ;
1001+ } ) ;
1002+ } ) ;
1003+ it ( "0450: Add a new job as user6 with datasets owned by two different groups, one of which user6 does not belong to" , async ( ) => {
1004+ const newJob = {
1005+ ...jobDatasetOwner ,
1006+ ownerUser : "user6" ,
1007+ ownerGroup : "group6" ,
1008+ jobParams : {
1009+ datasetList : [
1010+ { pid : datasetPidGroup6 , files : [ ] } ,
1011+ { pid : datasetPid3 , files : [ ] } ,
1012+ ] ,
1013+ } ,
1014+ } ;
1015+ return request ( appUrl )
1016+ . post ( "/api/v4/Jobs" )
1017+ . send ( newJob )
1018+ . set ( "Accept" , "application/json" )
1019+ . set ( { Authorization : `Bearer ${ accessTokenUser6 } ` } )
1020+ . expect ( TestData . AccessForbiddenStatusCode )
1021+ . expect ( "Content-Type" , / j s o n / )
1022+ . then ( ( res ) => {
1023+ res . body . should . not . have . property ( "id" ) ;
1024+ res . body . should . have
1025+ . property ( "message" )
1026+ . and . be . equal ( "User does not have access to all datasets, cannot create job." ) ;
1027+ } ) ;
1028+ } ) ;
1029+
9371030} ) ;
0 commit comments