@@ -349,6 +349,69 @@ Feature: Authorization checking
349
349
And the header "Content-Type" should be equal to "application/json"
350
350
And the JSON node "data.createSecuredDummy.securedDummy.owner" should be equal to "dunglas"
351
351
352
+ Scenario : An admin can create a secured resource with an owner-only property if they will be the owner
353
+ When I add "Authorization" header equal to "Basic YWRtaW46a2l0dGVu"
354
+ And I send the following GraphQL request:
355
+ """
356
+ mutation {
357
+ createSecuredDummy(input: {owner: "admin", title: "Hi", description: "Desc", adminOnlyProperty: "secret", ownerOnlyProperty: "it works"}) {
358
+ securedDummy {
359
+ ownerOnlyProperty
360
+ }
361
+ }
362
+ }
363
+ """
364
+ Then the response status code should be 200
365
+ And the response should be in JSON
366
+ And the header "Content-Type" should be equal to "application/json"
367
+ And the JSON node "data.createSecuredDummy.securedDummy.ownerOnlyProperty" should be equal to the string "it works"
368
+ And I add "Authorization" header equal to "Basic YWRtaW46a2l0dGVu"
369
+ And I send the following GraphQL request:
370
+ """
371
+ {
372
+ securedDummies {
373
+ edges {
374
+ node {
375
+ ownerOnlyProperty
376
+ }
377
+ }
378
+ }
379
+ }
380
+ """
381
+ Then the response status code should be 200
382
+ And the response should be in JSON
383
+ And the JSON node "data.securedDummies.edges[2].node.ownerOnlyProperty" should be equal to "it works"
384
+
385
+ Scenario : An admin can't create a secured resource with an owner-only property if they won't be the owner
386
+ When I add "Authorization" header equal to "Basic YWRtaW46a2l0dGVu"
387
+ And I send the following GraphQL request:
388
+ """
389
+ mutation {
390
+ createSecuredDummy(input: {owner: "dunglas", title: "Hi", description: "Desc", adminOnlyProperty: "secret", ownerOnlyProperty: "should not be set"}) {
391
+ securedDummy {
392
+ ownerOnlyProperty
393
+ }
394
+ }
395
+ }
396
+ """
397
+ Then the response status code should be 200
398
+ And the response should be in JSON
399
+ And the header "Content-Type" should be equal to "application/json"
400
+ And the JSON node "data.createSecuredDummy.securedDummy.ownerOnlyProperty" should exist
401
+ And the JSON node "data.createSecuredDummy.securedDummy.ownerOnlyProperty" should be null
402
+ And I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
403
+ And I send the following GraphQL request:
404
+ """
405
+ {
406
+ securedDummy(id: "/secured_dummies/4") {
407
+ ownerOnlyProperty
408
+ }
409
+ }
410
+ """
411
+ Then the response status code should be 200
412
+ And the response should be in JSON
413
+ And the JSON node "data.securedDummy.ownerOnlyProperty" should be equal to the string ""
414
+
352
415
Scenario : A user cannot retrieve an item they doesn't own
353
416
When I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
354
417
And I send the following GraphQL request:
@@ -419,6 +482,66 @@ Feature: Authorization checking
419
482
And the header "Content-Type" should be equal to "application/json"
420
483
And the JSON node "data.securedDummy.adminOnlyProperty" should be null
421
484
485
+ Scenario : A user can see a secured owner-only property on an object they own
486
+ When I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
487
+ And I send the following GraphQL request:
488
+ """
489
+ {
490
+ securedDummy(id: "/secured_dummies/2") {
491
+ ownerOnlyProperty
492
+ }
493
+ }
494
+ """
495
+ Then the response status code should be 200
496
+ And the response should be in JSON
497
+ And the header "Content-Type" should be equal to "application/json"
498
+ And the JSON node "data.securedDummy.ownerOnlyProperty" should exist
499
+ And the JSON node "data.securedDummy.ownerOnlyProperty" should not be null
500
+
501
+ Scenario : A user can update a secured owner-only property on an object they own
502
+ When I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
503
+ And I send the following GraphQL request:
504
+ """
505
+ mutation {
506
+ updateSecuredDummy(input: {id: "/secured_dummies/2", ownerOnlyProperty: "updated"}) {
507
+ securedDummy {
508
+ ownerOnlyProperty
509
+ }
510
+ }
511
+ }
512
+ """
513
+ Then the response status code should be 200
514
+ And the response should be in JSON
515
+ And the header "Content-Type" should be equal to "application/json"
516
+ And the JSON node "data.updateSecuredDummy.securedDummy.ownerOnlyProperty" should be equal to the string "updated"
517
+ And I add "Authorization" header equal to "Basic ZHVuZ2xhczprZXZpbg=="
518
+ And I send the following GraphQL request:
519
+ """
520
+ {
521
+ securedDummy(id: "/secured_dummies/2") {
522
+ ownerOnlyProperty
523
+ }
524
+ }
525
+ """
526
+ Then the response status code should be 200
527
+ And the response should be in JSON
528
+ And the JSON node "data.securedDummy.ownerOnlyProperty" should be equal to the string "updated"
529
+
530
+ Scenario : An admin can't see a secured owner-only property on an object they don't own
531
+ When I add "Authorization" header equal to "Basic YWRtaW46a2l0dGVu"
532
+ And I send the following GraphQL request:
533
+ """
534
+ {
535
+ securedDummy(id: "/secured_dummies/2") {
536
+ ownerOnlyProperty
537
+ }
538
+ }
539
+ """
540
+ Then the response status code should be 200
541
+ And the response should be in JSON
542
+ And the header "Content-Type" should be equal to "application/json"
543
+ And the JSON node "data.securedDummy.ownerOnlyProperty" should be null
544
+
422
545
Scenario : A user can't assign to themself an item they doesn't own
423
546
When I add "Authorization" header equal to "Basic YWRtaW46a2l0dGVu"
424
547
And I send the following GraphQL request:
0 commit comments