mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-01-12 17:22:47 +08:00
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
- console: fix row delete for relationships in data browser (#4433)
|
||||
- console: prevent trailing spaces while creating new role (close #3871) (#4497)
|
||||
- docs: add API docs for using environment variables as webhook urls in event triggers
|
||||
- server: fix recreating action's permissions (close #4377)
|
||||
|
||||
## `v1.2.0-beta.4`
|
||||
|
||||
|
||||
@@ -249,8 +249,8 @@ runCreateActionPermission
|
||||
runCreateActionPermission createActionPermission = do
|
||||
actionInfo <- getActionInfo actionName
|
||||
void $ onJust (Map.lookup role $ _aiPermissions actionInfo) $ const $
|
||||
throw400 AlreadyExists $ "permission for role: " <> role
|
||||
<<> "is already defined on " <>> actionName
|
||||
throw400 AlreadyExists $ "permission for role " <> role
|
||||
<<> " is already defined on " <>> actionName
|
||||
persistCreateActionPermission createActionPermission
|
||||
buildSchemaCacheFor $ MOActionPermission actionName role
|
||||
pure successMsg
|
||||
@@ -282,6 +282,7 @@ runDropActionPermission dropActionPermission = do
|
||||
throw400 NotExists $
|
||||
"permission for role: " <> role <<> " is not defined on " <>> actionName
|
||||
liftTx $ deleteActionPermissionFromCatalog actionName role
|
||||
buildSchemaCacheFor $ MOActionPermission actionName role
|
||||
return successMsg
|
||||
where
|
||||
actionName = _dapAction dropActionPermission
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# For https://github.com/hasura/graphql-engine/issues/4377
|
||||
- description: Create permission for action
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
message: success
|
||||
query:
|
||||
type: create_action_permission
|
||||
args:
|
||||
action: create_user
|
||||
role: user
|
||||
- description: Drop the permission
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
message: success
|
||||
query:
|
||||
type: drop_action_permission
|
||||
args:
|
||||
action: create_user
|
||||
role: user
|
||||
|
||||
- description: Recreate action permission
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
message: success
|
||||
query:
|
||||
type: create_action_permission
|
||||
args:
|
||||
action: create_user
|
||||
role: user
|
||||
21
server/tests-py/queries/actions/metadata/setup.yaml
Normal file
21
server/tests-py/queries/actions/metadata/setup.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: set_custom_types
|
||||
args:
|
||||
objects:
|
||||
- name: User
|
||||
fields:
|
||||
- name: user_id
|
||||
type: ID!
|
||||
- name: name
|
||||
type: String!
|
||||
- type: create_action
|
||||
args:
|
||||
name: create_user
|
||||
definition:
|
||||
kind: synchronous
|
||||
arguments:
|
||||
- name: name
|
||||
type: String!
|
||||
output_type: User!
|
||||
handler: http://127.0.0.1:5593/create-user
|
||||
7
server/tests-py/queries/actions/metadata/teardown.yaml
Normal file
7
server/tests-py/queries/actions/metadata/teardown.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: drop_action
|
||||
args:
|
||||
name: create_user
|
||||
- type: set_custom_types
|
||||
args: {}
|
||||
@@ -377,3 +377,13 @@ class TestSetCustomTypes:
|
||||
|
||||
def test_create_action_pg_scalar(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir() + '/create_action_pg_scalar.yaml')
|
||||
|
||||
@pytest.mark.usefixtures('per_class_tests_db_state')
|
||||
class TestActionsMetadata:
|
||||
|
||||
@classmethod
|
||||
def dir(cls):
|
||||
return 'queries/actions/metadata'
|
||||
|
||||
def test_recreate_permission(self, hge_ctx):
|
||||
check_query_f(hge_ctx, self.dir() + '/recreate_permission.yaml')
|
||||
|
||||
Reference in New Issue
Block a user