Skip to content

Ensure at least one permission is selected during member role creation

What does this MR do and why?

  • Adds a validation to the MemberRole model to ensure at least one permission is selected during creation.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
before after

How to set up and validate locally

  1. Log-in as admin and navigate to GraphQL explorer, /-/graphql-explorer
  2. Run the following query which creates a member role with no permissions enabled. This should result in an error.
mutation createMemberRole($input: MemberRoleCreateInput!) {
  memberRoleCreate(input: $input) {
    memberRole {
      id
      enabledPermissions {
        edges {
          node {
            name
          }
        }
      }
    }
    errors
  }
}
# QUERY VARIABLES
{
  "input": {
    "name": "Test",
    "baseAccessLevel": "GUEST",
    "permissions": []
  }
}
  1. Next, update the query variables to include permissions. This request should be successful.
# QUERY VARIABLES
{
  "input": {
    "name": "Test",
    "baseAccessLevel": "GUEST",
    "permissions": ["READ_CODE"]
  }
}

Related to #435612 (closed)

Edited by Hinam Mehra

Merge request reports