def METHOD_NAME(self, privilege, grant_target_name, user_name, node=None):
    """Check that user is only able to execute `SYSTEM SHUTDOWN` when they have the necessary privilege.
    """
    cluster = self.context.cluster
    exitcode, message = errors.not_enough_privileges(name=user_name)
    if node is None:
        node = self.context.node
    with Scenario("SYSTEM SHUTDOWN without privilege"):
        with When("I grant the user NONE privilege"):
            node.query(f"GRANT NONE TO {grant_target_name}")
        with And("I grant the user USAGE privilege"):
            node.query(f"GRANT USAGE ON *.* TO {grant_target_name}")
        with Then("I check the user can't use SYSTEM SHUTDOWN"):
            node.query(f"SYSTEM SHUTDOWN", settings=[("user",user_name)],
                exitcode=exitcode, message=message)
    with Scenario("SYSTEM SHUTDOWN with privilege"):
        timeout = 60
        try:
            with When(f"I grant {privilege}"):
                node.query(f"GRANT {privilege} ON *.* TO {grant_target_name}")
            with Then("I check the user can use SYSTEM SHUTDOWN"):
                node.query(f"SYSTEM SHUTDOWN", settings = [("user", f"{user_name}")])
            with And("I close all connections to the node"):
                node.close_bashes()
            with And("I check that system is down"):
                command = f"echo -e \"SELECT 1\" | {cluster.docker_compose} exec -T {node.name} clickhouse client -n"
                start_time = time.time()
                while True:
                    r = cluster.bash(None)(command)
                    if r.exitcode != 0:
                        break
                    if time.time() - start_time > timeout:
                        break
                    time.sleep(1)
                assert r.exitcode != 0, error(r.output)
        finally:
            with Finally("I relaunch the server"):
                node.restart(safe=False)
    with Scenario("SYSTEM SHUTDOWN with revoked privilege"):
        with When(f"I grant {privilege}"):
            node.query(f"GRANT {privilege} ON *.* TO {grant_target_name}")
        with And(f"I revoke {privilege}"):
            node.query(f"REVOKE {privilege} ON *.* FROM {grant_target_name}")
        with Then("I check the user cannot use SYSTEM SHUTDOWN"):
            node.query(f"SYSTEM SHUTDOWN", settings=[("user",user_name)],
                exitcode=exitcode, message=message)