|
24 | 24 | from cassandra.concurrent import execute_concurrent_with_args
|
25 | 25 | from cassandra.query import BatchStatement, BatchType
|
26 | 26 | from ccmlib import common
|
| 27 | +from ccmlib.node import ToolError |
27 | 28 |
|
28 | 29 | from .cqlsh_tools import monkeypatch_driver, unmonkeypatch_driver
|
29 | 30 | from dtest import Tester, create_ks, create_cf
|
@@ -2589,6 +2590,33 @@ def test_cjk_output(self):
|
2589 | 2590 | """
|
2590 | 2591 | assert stdout_lines_sorted.find(expected) >= 0
|
2591 | 2592 |
|
| 2593 | + @since('4.0') |
| 2594 | + def test_no_file_io(self): |
| 2595 | + def run_cqlsh_catch_toolerror(cmd, env): |
| 2596 | + """ |
| 2597 | + run_cqlsh will throw ToolError if cqlsh exits with a non-zero exit code. |
| 2598 | + """ |
| 2599 | + try: |
| 2600 | + out, err, _ = self.node1.run_cqlsh(cmd, env) |
| 2601 | + except ToolError as e: |
| 2602 | + return e.stdout, e.stderr |
| 2603 | + |
| 2604 | + cqlsh_stdout, cqlsh_stderr, = run_cqlsh_catch_toolerror('COPY foo.bar FROM \'blah\';', ['--no-file-io']) |
| 2605 | + assert cqlsh_stdout == '' |
| 2606 | + assert 'No file I/O permitted' in cqlsh_stderr |
| 2607 | + |
| 2608 | + cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('DEBUG', ['--no-file-io']) |
| 2609 | + assert cqlsh_stdout == '' |
| 2610 | + assert 'No file I/O permitted' in cqlsh_stderr |
| 2611 | + |
| 2612 | + cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('CAPTURE \'nah\'', ['--no-file-io']) |
| 2613 | + assert cqlsh_stdout == '' |
| 2614 | + assert 'No file I/O permitted' in cqlsh_stderr |
| 2615 | + |
| 2616 | + cqlsh_stdout, cqlsh_stderr = run_cqlsh_catch_toolerror('SOURCE \'nah\'', ['--no-file-io']) |
| 2617 | + assert cqlsh_stdout == '' |
| 2618 | + assert 'No file I/O permitted' in cqlsh_stderr |
| 2619 | + |
2592 | 2620 |
|
2593 | 2621 | class TestCqlLogin(Tester, CqlshMixin):
|
2594 | 2622 | """
|
|
0 commit comments