-
-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GraphQL: honor access control rules (#1602)
- Loading branch information
Showing
30 changed files
with
534 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Feature: Authorization checking | ||
In order to use the GraphQL API | ||
As a client software user | ||
I need to be authorized to access a given resource. | ||
|
||
@createSchema | ||
Scenario: An anonymous user tries to retrieve a secured item | ||
Given there are 1 SecuredDummy objects | ||
When I send the following GraphQL request: | ||
""" | ||
{ | ||
securedDummy(id: "/secured_dummies/1") { | ||
title | ||
description | ||
} | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/json" | ||
And the JSON node "errors[0].message" should be equal to "Access Denied." | ||
|
||
Scenario: An anonymous user tries to retrieve a secured collection | ||
Given there are 1 SecuredDummy objects | ||
When I send the following GraphQL request: | ||
""" | ||
{ | ||
securedDummies { | ||
edges { | ||
node { | ||
title | ||
description | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/json" | ||
And the JSON node "errors[0].message" should be equal to "Access Denied." | ||
|
||
@dropSchema | ||
Scenario: An anonymous user tries to create a resource he is not allowed to | ||
When I send the following GraphQL request: | ||
""" | ||
mutation { | ||
createSecuredDummy(input: {owner: "me", title: "Hi", description: "Desc", clientMutationId: "auth"}) { | ||
title | ||
owner | ||
} | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/json" | ||
And the JSON node "errors[0].message" should be equal to "Access Denied." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.