code: def test_rbac_permission_assignment_errors() -> None:
      api_utils.configure_token_store(conf.ADMIN_CREDENTIALS)
      with logged_in_user(conf.ADMIN_CREDENTIALS):
          # Specifying args incorrectly.
          det_cmd_expect_error(
              ["rbac", "assign-role", "Viewer"],
              "must provide exactly one of",
          )
          det_cmd_expect_error(
              ["rbac", "unassign-role", "Viewer"],
              "must provide exactly one of",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--username-to-assign",
                  "u",
                  "--group-name-to-assign",
                  "g",
              ],
              "must provide exactly one of",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--username-to-assign",
                  "u",
                  "--group-name-to-assign",
                  "g",
              ],
              "must provide exactly one of",
          )
  
          # Non existent role.
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "fakeRoleNameThatDoesntExist",
                  "--username-to-assign",
                  "admin",
              ],
              "could not find role name",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "fakeRoleNameThatDoesntExist",
                  "--username-to-assign",
                  "admin",
              ],
              "could not find role name",
          )
  
          # Non existent user
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--username-to-assign",
                  "fakeUserNotExist",
              ],
              "could not find user",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--username-to-assign",
                  "fakeUserNotExist",
              ],
              "could not find user",
          )
  
          # Non existent group.
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  "fakeGroupNotExist",
              ],
              "could not find user group",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  "fakeGroupNotExist",
              ],
              "could not find user group",
          )
  
          # Non existent workspace
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--workspace-name",
                  "fakeWorkspace",
                  "--username-to-assign",
                  "admin",
              ],
              "not found",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--workspace-name",
                  "fakeWorkspace",
                  "--username-to-assign",
                  "admin",
              ],
              "not found",
          )
  
          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",
                  "--username-to-assign",
                  test_user_creds.username,
              ],
              check=True,
          )
  
          # Assign a role multiple times.
          det_cmd_expect_error(
              [
                  "rbac",
                  "assign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  group_name,
              ],
              "row already exists",
          )
  
          # Unassigned role group doesn't have.
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Editor",
                  "--group-name-to-assign",
                  group_name,
              ],
              "Not Found",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--group-name-to-assign",
                  group_name,
                  "--workspace-name",
                  "Uncategorized",
              ],
              "Not Found",
          )
  
          # Unassigned role user doesn't have.
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Editor",
                  "--username-to-assign",
                  test_user_creds.username,
              ],
              "Not Found",
          )
          det_cmd_expect_error(
              [
                  "rbac",
                  "unassign-role",
                  "Viewer",
                  "--username-to-assign",
                  test_user_creds.username,
                  "--workspace-name",
                  "Uncategorized",
              ],
              "Not Found",
          )
  
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 10 for calling a global function with example usage: test_rbac_permission_assignment_errors() without return types