Skip to content

Commit 9f622e3

Browse files
authored
add new tests to documentation (#83)
* add new tests to documentation * fix rendering * make filters look nicer
1 parent d66737c commit 9f622e3

File tree

2 files changed

+282
-8
lines changed

2 files changed

+282
-8
lines changed

Development/v4.x/backend/authorization/authorization_jobs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ graph LR;
5151
| -------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
5252
| POST | Jobs | _JobCreate_ | _JobCreateConfiguration_ | _JobCreateConfiguration_ | Any<br>_JobsCreateOwner_ | __no__ | Any<br>_JobsCreateAny_ | __no__ |
5353
| GET | Jobs | _JobReadMany_ | __no__ | Has Access<br>_JobReadAccess_ | Has Access<br>_JobReadAccess_ | __no__ | Any<br>_JobReadAny_ | __no__ |
54+
| GET | Jobs/datasetDetails | _JobReadMany_ | __no__ | Has Access<br>_JobReadAccess_ | Has Access<br>_JobReadAccess_ | __no__ | Any<br>_JobReadAny_ | __no__ |
5455
| GET | Jobs/_jid_ | _JobReadOne_ | __no__ | Has Access<br>_JobReadAccess_ | Has Access<br>_JobReadAccess_ | __no__ | Any<br>_JobReadAny_ | __no__ |
5556
| PATCH | Jobs/_jid_ | _JobUpdate_ | __no__ | _JobUpdateConfiguration_ | __no__ | Owner<br>_JobUpdateOwner_ | Any<br>_JobUpdateAny_ | __no__ |
5657
| DELETE | Jobs/_jid_ | _JobDelete_ | __no__ | __no__ | __no__ | __no__ | __no__ | __no__ |

Development/v4.x/backend/testing/jobs.md

Lines changed: 281 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
218218
| 0130 | Add a new job as user from CREATE_JOB_PRIVILEGED_GROUPS for different ownerUser and ownerGroup for #datasetAccess, which should be forbidden | POST | /api.v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
219219
| 0140 | Add a new job as user from CREATE_JOB_PRIVILEGED_GROUPS for different ownerUser and no ownerGroup for #datasetAccess | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
220220
| 0150 | Add a new job as user from CREATE_JOB_PRIVILEGED_GROUPS for different ownerUser and no ownerGroup for #datasetAccess, which should be forbidden | POST | /api.v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
221-
222221
| 0160 | Add a new job as user from CREATE_JOB_PRIVILEGED_GROUPS for anonymous user in #datasetAccess with published datasets | POST | /api.v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
223222
| 0170 | Add a new job as user from CREATE_JOB_PRIVILEGED_GROUPS for anonymous user in #datasetAccess with one unpublished dataset, which should be forbidden | POST | /api.v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
224223
| 0180 | Add a new job as a normal user for himself/herself in '#datasetAccess' configuration with access to datasets | POST | /api/v4/Jobs | user5.1 | 201 | ```EntryCreatedStatusCode``` |
@@ -260,7 +259,7 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
260259
| 0150 | Add a new job as a normal user for himself/herself in '#datasetOwner' configuration with datasets not owned by his/her group, which should be forbidden | POST | /api/v4/Jobs | user5.1 | 403 | ```AccessForbiddenStatusCode``` |
261260
| 0160 | Add a new job as a user from ADMIN_GROUPS for group2 and user1 in '#datasetOwner' configuration | POST | /api/v4/Jobs| admin | 200 | ```EntryCreatedStatusCode``` |
262261
| 0170 | Add a new job as a user from ADMIN_GROUPS for group1 and user2 in '#datasetOwner' configuration | POST | /api/v4/Jobs | admin | 200 | ```EntryCreatedStatusCode``` |
263-
| 0180 | , where the user is not an owner of some of these datasets, which should be forbidden | POST | /api/v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
262+
| 0180 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for another user in '#datasetOwner' configuration, where the user is not an owner of some of these datasets, which should be forbidden | POST | /api/v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
264263
| 0190 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for another user in '#datasetOwner' configuration, where the user is owner of these datasets | POST | /api/v4/Jobs | user1 | 200 | ```EntryCreatedStatusCode``` |
265264
| 0200 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for group1 and user3 in '#datasetOwner' configuration, which should be forbidden | POST | /api/v4/Jobs | user1 | 403 | ```AccessForbiddenStatusCode``` |
266265
| 0210 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for anonymous user in '#datasetOwner' configuration, which should be forbidden | POST | /api/v4/Jobs | user1 | 401 | ```CreationUnauthorizedStatusCode``` |
@@ -308,6 +307,181 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
308307
| 0140 | Add a new job as anonymous user in '#datasetPublic' configuration with all published datasets | POST | /api/v4/Jobs | unauthenticated | 201 | ```EntryCreatedStatusCode``` |
309308
| 0150 | Add a new job as anonymous user in '#datasetPublic' configuration with one unpublished dataset, which should be forbidden | POST | /api/v4/Jobs | unauthenticated | 403 | ```AccessForbiddenStatusCode``` |
310309

310+
### 1165: Jobs test filters and access
311+
312+
<table>
313+
<tr>
314+
<th>Test Number</th>
315+
<th>Description</th>
316+
<th>HTTP Method</th>
317+
<th>Endpoint</th>
318+
<th>Filter</th>
319+
<th>Authenticated User</th>
320+
<th>Expected Request Status</th>
321+
<th>Expected Request Code</th>
322+
</tr>
323+
<tr>
324+
<td>0010</td>
325+
<td>Access jobs as a user from ADMIN_GROUPS with wrong include query</td>
326+
<td>GET</td>
327+
<td>/api/v4/Jobs</td>
328+
<td>
329+
<pre><code>{
330+
"include": ["datasets", "datasets.datablocks"]
331+
}</code></pre>
332+
</td>
333+
<td>admin</td>
334+
<td>400</td>
335+
<td><code>BadRequestStatusCode</code></td>
336+
</tr>
337+
<tr>
338+
<td>0020</td>
339+
<td>Access jobs and dataset details as a user from ADMIN_GROUPS with include query, which is not allowed</td>
340+
<td>GET</td>
341+
<td>/api/v4/Jobs/datasetDetails</td>
342+
<td>
343+
<pre><code>{
344+
"include": ["datasets", "datasets.datablocks"]
345+
}</code></pre>
346+
</td>
347+
<td>admin</td>
348+
<td>400</td>
349+
<td><code>BadRequestStatusCode</code></td>
350+
</tr>
351+
<tr>
352+
<td>0030</td>
353+
<td>Access jobs as a user from ADMIN_GROUPS with a correct include query and fields query</td>
354+
<td>GET</td>
355+
<td>/api/v4/Jobs</td>
356+
<td>
357+
<pre><code>{
358+
"include": ["datasets"],
359+
"fields": [
360+
"id",
361+
"type",
362+
"datasets.pid",
363+
"datasets.keywords"
364+
]
365+
}</code></pre>
366+
</td>
367+
<td>admin</td>
368+
<td>200</td>
369+
<td><code>SuccessfulGetStatusCode</code></td>
370+
</tr>
371+
<tr>
372+
<td>0040</td>
373+
<td>Access jobs as a user from ADMIN_GROUPS with where filter</td>
374+
<td>GET</td>
375+
<td>/api/v4/Jobs</td>
376+
<td>
377+
<pre><code>{
378+
"where": {"ownerGroup": "group1"},
379+
"include": ["datasets"],
380+
"fields": [
381+
"id",
382+
"type",
383+
"ownerGroup",
384+
"datasets.pid",
385+
"datasets.keywords"
386+
]
387+
}</code></pre>
388+
</td>
389+
<td>admin</td>
390+
<td>200</td>
391+
<td><code>SuccessfulGetStatusCode</code></td>
392+
</tr>
393+
<tr>
394+
<td>0050</td>
395+
<td>Access jobs as a user from ADMIN_GROUPS with an include filter specified as all</td>
396+
<td>GET</td>
397+
<td>/api/v4/Jobs</td>
398+
<td>
399+
<pre><code>{
400+
"include": ["all"],
401+
"fields": [
402+
"id",
403+
"type",
404+
"datasets.pid",
405+
"datasets.keywords"
406+
]
407+
}</code></pre>
408+
</td>
409+
<td>admin</td>
410+
<td>200</td>
411+
<td><code>SuccessfulGetStatusCode</code></td>
412+
</tr>
413+
<tr>
414+
<td>0060</td>
415+
<td>Access jobs datasetDetails as a user from ADMIN_GROUPS with no fields query that should return all properties of JobClass</td>
416+
<td>GET</td>
417+
<td>/api/v4/Jobs/datasetDetails</td>
418+
<td></td>
419+
<td>admin</td>
420+
<td>200</td>
421+
<td><code>SuccessfulGetStatusCode</code></td>
422+
</tr>
423+
<tr>
424+
<td>0070</td>
425+
<td>Access jobs and datasetDetails, information should be returned based on correct access</td>
426+
<td>GET</td>
427+
<td>/api/v4/Jobs/datasetDetails</td>
428+
<td></td>
429+
<td>user1</td>
430+
<td>200</td>
431+
<td><code>SuccessfulGetStatusCode</code></td>
432+
</tr>
433+
<tr>
434+
<td>0080</td>
435+
<td>Access jobs and datasetDetails, apply fields filter</td>
436+
<td>GET</td>
437+
<td>/api/v4/Jobs/datasetDetails</td>
438+
<td>
439+
<pre><code>{
440+
"fields": [
441+
"id",
442+
"datasetDetails.pid",
443+
"datasetDetails.datablocks._id",
444+
"datasetDetails.datablocks.size",
445+
"datasetDetails.origdatablocks._id",
446+
"datasetDetails.origdatablocks.chkAlg"
447+
]
448+
}</code></pre>
449+
</td>
450+
<td>user1</td>
451+
<td>200</td>
452+
<td><code>SuccessfulGetStatusCode</code></td>
453+
</tr>
454+
<tr>
455+
<td>0090</td>
456+
<td>Access jobs, datasets and instruments, that should be returned based on correct access</td>
457+
<td>GET</td>
458+
<td>/api/v4/Jobs/datasetDetails</td>
459+
<td></td>
460+
<td>user5.1</td>
461+
<td>200</td>
462+
<td><code>SuccessfulGetStatusCode</code></td>
463+
</tr>
464+
<tr>
465+
<td>0100</td>
466+
<td>Access jobs, datasets and instruments, that should be returned based on correct access</td>
467+
<td>GET</td>
468+
<td>/api/v4/Jobs/datasetDetails</td>
469+
<td></td>
470+
<td>user3</td>
471+
<td>200</td>
472+
<td><code>SuccessfulGetStatusCode</code></td>
473+
</tr>
474+
<tr>
475+
<td>0110</td>
476+
<td>Access jobs, datasets and instruments, that should be returned based on correct access</td>
477+
<td>GET</td>
478+
<td>/api/v4/Jobs/datasetDetails</td>
479+
<td></td>
480+
<td>adminIngestor</td>
481+
<td>200</td>
482+
<td><code>SuccessfulGetStatusCode</code></td>
483+
</tr>
484+
</table>
311485

312486
### 1170: Jobs: Test New Job Model Authorization for job_admin jobs type
313487
| Test Number | Description | HTTP Method | Endpoint | Authenticated User | Expected Request Status | Expected Request Code |
@@ -316,13 +490,13 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
316490
| 0020 | Add dataset 2 as Admin Ingestor | POST | /api/v3/Datasets | adminIngestor | 201 | ```EntryCreatedStatusCode``` |
317491
| 0030 | Add dataset 3 as Admin Ingestor | POST | /api/v3/Datasets | adminIngestor | 201 | ```EntryCreatedStatusCode``` |
318492
| 0040 | Add a new job as a user from ADMIN_GROUPS for himself/herself in '#jobAdmin' configuration | POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
319-
| 0050 | Add a new job as a user from ADMIN_GROUPS for another user in '#jobAdmin' configuration POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
320-
| 0060 | Add a new job as a user from ADMIN_GROUPS for another group in '#jobAdmin' configuration POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
493+
| 0050 | Add a new job as a user from ADMIN_GROUPS for another user in '#jobAdmin' configuration | POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
494+
| 0060 | Add a new job as a user from ADMIN_GROUPS for another group in '#jobAdmin' configuration | POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
321495
| 0070 | Add a new job as a user from ADMIN_GROUPS for anonymous user in '#jobAdmin' configuration | POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
322496
| 0080 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for himself/herself in '#jobAdmin' configuration with dataset owned by his/her group | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
323497
| 0090 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for himself/herself in '#jobAdmin' configuration with only one of two datasets owned by his/her group | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
324-
| 0100 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for another user in '#jobAdmin' configuration POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
325-
| 0110 | Add a new job as a normal user for himself/herself in '#jobAdmin' configuration with datasets owned by his/her group, which should be forbidden POST | /api/v4/Jobs | user51 | 403 | ```AccessForbiddenStatusCode``` |
498+
| 0100 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for another user in '#jobAdmin' configuration | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
499+
| 0110 | Add a new job as a normal user for himself/herself in '#jobAdmin' configuration with datasets owned by his/her group, which should be forbidden | POST | /api/v4/Jobs | user51 | 403 | ```AccessForbiddenStatusCode``` |
326500
| 0120 | Add a new job as a user from UPDATE_JOB_PRIVILEGED_GROUPS for himself/herself in '#jobAdmin' configuration with datasets owned by his/her group, which should be forbidden | POST | /api/v4/Jobs | user3 | 403 | ```AccessForbiddenStatusCode``` |
327501
| 0130 | Add a status update to a job as a user from ADMIN_GROUPS for his/her job in '#jobAdmin' configuration | PATCH | /api/v4/Jobs/${encodedJobOwnedByAdmin} | Admin | 200 | ```SuccessfulPatchStatusCode``` |
328502
| 0140 | Add a Status update to a job as a user from ADMIN_GROUPS for another group's job in '#jobAdmin' configuration | PATCH | /api/v4/Jobs/${encodedJobOwnedByUser1} | Admin | 200 | ```SuccessfulPatchStatusCode``` |
@@ -349,7 +523,7 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
349523
| 0090 | Add a new job as a user from ADMIN_GROUPS for anonymous user in '#@group5' configuration | POST | /api/v4/Jobs | admin | 201 | ```EntryCreatedStatusCode``` |
350524
| 0100 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for his/her own group in '#@group5' configuration | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
351525
| 0110 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for user 5.1 in '#@group5' configuration | POST | /api/v4/Jobs | user1 | 201 | ```EntryCreatedStatusCode``` |
352-
| 0120 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for user 4 in '#@group5' configuration | POST | /api/v4/Jobs/ user1 | 201 | ```EntryCreatedStatusCode``` |
526+
| 0120 | Add a new job as a user from CREATE_JOB_PRIVILEGED_GROUPS for user 4 in '#@group5' configuration | POST | /api/v4/Jobs/ | user1 | 201 | ```EntryCreatedStatusCode``` |
353527
| 0130 | Add a new job as a user from UPDATE_JOB_PRIVILEGED_GROUPS for user 5.1 in '#@group5' configuration, which should be forbidden | POST | /api/v4/Jobs | user3 | 403 | ```AccessForbiddenStatusCode``` |
354528
| 0140 | Add a new job as a user 5.1 for himself/herself in '#@group5' configuration | POST | /api/v4/Jobs | user5.1 | 201 | ```EntryCreatedStatusCode``` |
355529
| 0150 | Add a new job as a user 5.1 for another user in his/her group in '#@group5' configuration | POST | /api/v4/Jobs | user5.1 | 201 | ```EntryCreatedStatusCode``` |
@@ -431,7 +605,7 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
431605
| 0380 | Fullfacet jobs as a user from ADMIN_GROUPS that were created by User5.1 | GET | /api/v4/Jobs/fullfacet?createdBy=user5.1 | admin | 200 | ```SuccessfulGetStatusCode``` |
432606

433607

434-
### 1200: Jobs: Test Backwards Compatibility
608+
### 1191: Jobs: Test Backwards Compatibility
435609

436610
| Test Number | Description | HTTP Method | Endpoint | Authenticated User | Expected Request Status | Expected Request Code |
437611
| ----- | ----- | ----- | ----- | ----- | ----- | ----- |
@@ -478,3 +652,102 @@ Not all files test PATCH and DELETE methods, as these would be redundant.
478652
| 0410 | Get via /api/v3 the anonymous job as a user in CREATE_JOB_PRIVILEGED_GROUPS | GET | /api/v3/Jobs/${encodedJobAnonymous} | user2 | 200 | ```SuccessfulGetStatusCode``` |
479653
| 0420 | Add via /api/v3 a new job for user5.1, as user5.1 in #datasetAccess auth | POST | /api/v3/Jobs | user5.1 | 201 | ```EntryCreatedStatusCode``` |
480654
| 0430 | Get via /api/v4 the previously added job, as user5.1 | GET | /api/v3/Jobs/${encodedJobOwnedByUser51} | user5.1 | 200 | ```SuccessfulGetStatusCode``` |
655+
656+
657+
### 1192: Jobs: Test datasetDetails backwards Compatibility
658+
659+
<table>
660+
<tr>
661+
<th>Test Number</th>
662+
<th>Description</th>
663+
<th>HTTP Method</th>
664+
<th>Endpoint</th>
665+
<th>Filter</th>
666+
<th>Authenticated User</th>
667+
<th>Expected Request Status</th>
668+
<th>Expected Request Code</th>
669+
</tr>
670+
<tr>
671+
<td>0010</td>
672+
<td>Get job and details on dataset for specific jobID and including information on datasets and datablocks as a user from ADMIN_GROUP with v4 endpoint</td>
673+
<td>GET</td>
674+
<td>/api/v4/Jobs/datasetDetails</td>
675+
<td>
676+
<pre><code>{
677+
"where": {"id": "${encodedJob}"},
678+
"fields": [
679+
"datasetDetails.pid",
680+
"datasetDetails.owner",
681+
"datasetDetails.contactEmail",
682+
"datasetDetails.sourceFolder",
683+
"datasetDetails.type",
684+
"datasetDetails.classification",
685+
"datasetDetails.ownerGroup",
686+
"datasetDetails.datasetlifecycle",
687+
"datasetDetails.datablocks.archiveId",
688+
"datasetDetails.datablocks.size",
689+
"datasetDetails.datablocks._id"
690+
]
691+
}</code></pre>
692+
</td>
693+
<td>admin</td>
694+
<td>200</td>
695+
<td><code>SuccessfulGetStatusCode</code></td>
696+
</tr>
697+
<tr>
698+
<td>0020</td>
699+
<td>Should return dataset details from V3 endpoint for a specific job and include datablocks information as a user from ADMIN_GROUP</td>
700+
<td>GET</td>
701+
<td>/api/v3/Jobs/datasetDetails</td>
702+
<td>
703+
<pre><code>{
704+
jobId=${encodedJob}&
705+
datasetFields={
706+
"pid": true,
707+
"sourceFolder": true,
708+
"sourceFolderHost": true,
709+
"contactEmail": true,
710+
"owner": true,
711+
"ownerGroup": true,
712+
"classification": true,
713+
"type": true,
714+
"datasetlifecycle": true,
715+
"createdBy": true
716+
}&include={
717+
"relation":"datablocks"
718+
}&includeFields={
719+
"_id": true,
720+
"archiveId": true,
721+
"size": true,
722+
"datasetId": true
723+
}</code></pre>
724+
</td>
725+
<td>admin</td>
726+
<td>200</td>
727+
<td><code>SuccessfulGetStatusCode</code></td>
728+
</tr>
729+
<tr>
730+
<td>0030</td>
731+
<td>Should return dataset details from V3 endpoint for a specific job and include no further information as a user from ADMIN_GROUP</td>
732+
<td>GET</td>
733+
<td>/api/v4/Jobs/datasetDetails</td>
734+
<td>
735+
<pre><code>{
736+
jobId=${encodedJob}&
737+
datasetFields={
738+
"pid": true,
739+
"sourceFolder": true,
740+
"contactEmail": true,
741+
"owner": true,
742+
"ownerGroup": true,
743+
"classification": true,
744+
"type": true,
745+
"datasetlifecycle": true,
746+
"createdBy": true
747+
}</code></pre>
748+
</td>
749+
<td>admin</td>
750+
<td>200</td>
751+
<td><code>SuccessfulGetStatusCode</code></td>
752+
</tr>
753+
</table>

0 commit comments

Comments
 (0)