code: def test_rbac_describe_role() -> None:
      with logged_in_user(conf.ADMIN_CREDENTIALS):
          # Role doesn't exist.
          det_cmd_expect_error(
              ["rbac", "describe-role", "roleDoesntExist"],
              "could not find role name",
          )
  
          # Role is assigned to our group and user.
          api_utils.configure_token_store(conf.ADMIN_CREDENTIALS)
          test_user_creds = api_utils.create_test_user()
          group_name = api_utils.get_random_string()
  
          det_cmd(["user-group", "create", group_name], check=True)
          det_cmd(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  group_name,
              ],
              check=True,
          )
          det_cmd(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  group_name,
                  "--workspace-name",
                  "Uncategorized",
              ],
              check=True,
          )
  
          sess = api_utils.determined_test_session(
              conf.ADMIN_CREDENTIALS
          )
          user_id = api.usernames_to_user_ids(
              sess, [test_user_creds.username]
          )[0]
          group_id = api.group_name_to_group_id(sess, group_name)
  
          det_cmd(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--username-to-assign",
                  test_user_creds.username,
              ],
              check=True,
          )
          det_cmd(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--username-to-assign",
                  test_user_creds.username,
                  "--workspace-name",
                  "Uncategorized",
              ],
              check=True,
          )
  
          # No errors printing non-json output.
          det_cmd(["rbac", "describe-role", "Viewer"], check=True)
  
          # Output is returned correctly.
          json_out = det_cmd_json(
              ["rbac", "describe-role", "Viewer", "--json"]
          )
          assert json_out["role"]["name"] == "Viewer"
  
          group_assign = [
              a
              for a in json_out["groupRoleAssignments"]
              if a["groupId"] == group_id
          ]
          assert len(group_assign) == 2
          group_assign.sort(
              key=lambda x: -1
              if x["roleAssignment"]["scopeWorkspaceId"] is None
              else 1
          )
          assert (
              group_assign[0]["roleAssignment"]["scopeWorkspaceId"]
              is None
          )
          assert (
              group_assign[1]["roleAssignment"]["scopeWorkspaceId"] == 1
          )
  
          user_assign = [
              a
              for a in json_out["userRoleAssignments"]
              if a["userId"] == user_id
          ]
          assert len(user_assign) == 2
          user_assign.sort(
              key=lambda x: -1
              if x["roleAssignment"]["scopeWorkspaceId"] is None
              else 1
          )
          assert (
              user_assign[0]["roleAssignment"]["scopeWorkspaceId"]
              is None
          )
          assert (
              user_assign[1]["roleAssignment"]["scopeWorkspaceId"] == 1
          )
  
imports: import contextlib
  from typing import Any, Callable, Dict, Generator, List, NamedTuple, Optional, Tuple
  import pytest
  from determined.common import api
  from determined.common.api import authentication, bindings, errors
  from tests import api_utils
  from tests import config
  from tests.cluster.test_workspace_org import setup_workspaces
  from .test_groups import det_cmd, det_cmd_expect_error, det_cmd_json
  from .test_users import logged_in_user
label_desc: Use image node_id 12 for calling a global function with example usage: test_rbac_describe_role() without return types