def METHOD_NAME(grant_target_name, user_name, node=None):
    """Run scenarios to check the user's access with different privileges.
    """
    exitcode, message = errors.not_enough_privileges(name=f"{user_name}")
    with Scenario("user without privilege"):
        dict_name = f"dict_{getuid()}"
        try:
            with Given("I have a dictionary"):
                node.query(f"CREATE DICTIONARY {dict_name}(x Int32, y Int32) PRIMARY KEY x LAYOUT(FLAT()) SOURCE(CLICKHOUSE()) LIFETIME(0)")
            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 attempt to detach a dictionary without privilege"):
                node.query(f"DETACH DICTIONARY {dict_name}", settings = [("user", user_name)], exitcode=exitcode, message=message)
        finally:
            with Finally("I reattach the dictionary", flags=TE):
                node.query(f"ATTACH DICTIONARY IF NOT EXISTS {dict_name}")
            with And("I drop the dictionary", flags=TE):
                node.query(f"DROP DICTIONARY IF EXISTS {dict_name}")
    with Scenario("user with privilege"):
        dict_name = f"dict_{getuid()}"
        try:
            with Given("I have a dictionary"):
                node.query(f"CREATE DICTIONARY {dict_name}(x Int32, y Int32) PRIMARY KEY x LAYOUT(FLAT()) SOURCE(CLICKHOUSE()) LIFETIME(0)")
            with When("I grant drop dictionary privilege"):
                node.query(f"GRANT DROP DICTIONARY ON {dict_name} TO {grant_target_name}")
            with Then("I attempt to detach a dictionary"):
                node.query(f"DETACH DICTIONARY {dict_name}", settings = [("user", user_name)])
        finally:
            with Finally("I reattach the dictionary", flags=TE):
                node.query(f"ATTACH DICTIONARY IF NOT EXISTS {dict_name}")
            with And("I drop the dictionary", flags=TE):
                node.query(f"DROP DICTIONARY IF EXISTS {dict_name}")
    with Scenario("user with revoked privilege"):
        dict_name = f"dict_{getuid()}"
        try:
            with Given("I have a dictionary"):
                node.query(f"CREATE DICTIONARY {dict_name}(x Int32, y Int32) PRIMARY KEY x LAYOUT(FLAT()) SOURCE(CLICKHOUSE()) LIFETIME(0)")
            with When("I grant the drop dictionary privilege"):
                node.query(f"GRANT DROP DICTIONARY ON {dict_name} TO {grant_target_name}")
            with And("I revoke the drop dictionary privilege"):
                node.query(f"REVOKE DROP DICTIONARY ON {dict_name} FROM {grant_target_name}")
            with Then("I attempt to detach a dictionary"):
                node.query(f"DETACH DICTIONARY {dict_name}", settings = [("user", user_name)], exitcode=exitcode, message=message)
        finally:
            with Finally("I reattach the dictionary", flags=TE):
                node.query(f"ATTACH DICTIONARY IF NOT EXISTS {dict_name}")
            with And("I drop the dictionary", flags=TE):
                node.query(f"DROP DICTIONARY IF EXISTS {dict_name}")
    with Scenario("user with revoked ALL privilege"):
        dict_name = f"dict_{getuid()}"
        try:
            with Given("I have a dictionary"):
                node.query(f"CREATE DICTIONARY {dict_name}(x Int32, y Int32) PRIMARY KEY x LAYOUT(FLAT()) SOURCE(CLICKHOUSE()) LIFETIME(0)")
            with When("I grant the drop dictionary privilege"):
                node.query(f"GRANT DROP DICTIONARY ON {dict_name} TO {grant_target_name}")
            with And("I revoke ALL privilege"):
                node.query(f"REVOKE ALL ON *.* FROM {grant_target_name}")
            with Then("I attempt to detach a dictionary"):
                node.query(f"DETACH DICTIONARY {dict_name}", settings = [("user", user_name)], exitcode=exitcode, message=message)
        finally:
            with Finally("I reattach the dictionary", flags=TE):
                node.query(f"ATTACH DICTIONARY IF NOT EXISTS {dict_name}")
            with And("I drop the dictionary", flags=TE):
                node.query(f"DROP DICTIONARY IF EXISTS {dict_name}")
    with Scenario("user with ALL privilege"):
        dict_name = f"dict_{getuid()}"
        try:
            with Given("I have a dictionary"):
                node.query(f"CREATE DICTIONARY {dict_name}(x Int32, y Int32) PRIMARY KEY x LAYOUT(FLAT()) SOURCE(CLICKHOUSE()) LIFETIME(0)")
            with When("I grant ALL privilege"):
                node.query(f"GRANT ALL ON *.* TO {grant_target_name}")
            with Then("I attempt to detach a dictionary"):
                node.query(f"DETACH DICTIONARY {dict_name}", settings = [("user", user_name)])
        finally:
            with Finally("I reattach the dictionary", flags=TE):
                node.query(f"ATTACH DICTIONARY IF NOT EXISTS {dict_name}")
            with And("I drop the dictionary", flags=TE):
                node.query(f"DROP DICTIONARY IF EXISTS {dict_name}")