From 209438b10fd0baaeaf7a5b9ffe2b2ca3aacc96da Mon Sep 17 00:00:00 2001 From: Ivan Davydenko Date: Fri, 24 May 2024 23:08:01 +0300 Subject: [PATCH] [cli-sessions] unittests for ssh-server and serial-console commands. --- config/main.py | 4 ++-- tests/cli_sessions_test.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/cli_sessions_test.py diff --git a/config/main.py b/config/main.py index 905ab7a0507..dc27ef50d58 100644 --- a/config/main.py +++ b/config/main.py @@ -7753,7 +7753,7 @@ def notice(db, category_list, max_events, namespace): # # 'serial_console' group ('config serial_console') # -@config.group() +@config.group(cls=clicommon.AbbreviationGroup, name='serial_console') def serial_console(): """Configuring system serial-console behavior""" pass @@ -7786,7 +7786,7 @@ def inactivity_timeout_serial(inactivity_timeout): # # 'ssh' group ('config ssh') # -@config.group() +@config.group(cls=clicommon.AbbreviationGroup, name='ssh') def ssh(): """Configuring system ssh behavior""" pass diff --git a/tests/cli_sessions_test.py b/tests/cli_sessions_test.py new file mode 100644 index 00000000000..89fb56b3721 --- /dev/null +++ b/tests/cli_sessions_test.py @@ -0,0 +1,32 @@ +from click.testing import CliRunner + +import config.main as config +import show.main as show +from utilities_common.db import Db + + +class TestCliSessionsCommands: + def test_config_command(self): + runner = CliRunner() + + db = Db() + + result = runner.invoke(config.config.commands['serial_console'].commands['sysrq-capabilities'], + ['enabled'], obj=db) + assert result.exit_code == 0 + + result = runner.invoke(config.config.commands['serial_console'].commands['inactivity-timeout'], + [180], obj=db) + assert result.exit_code == 0 + + result = runner.invoke(show.cli.commands['serial_console'], obj=db) + assert result.exit_code == 0 + + result = runner.invoke(config.config.commands['ssh'].commands['inactivity-timeout'], [190], obj=db) + assert result.exit_code == 0 + + result = runner.invoke(config.config.commands['ssh'].commands['max-sessions'], [60], obj=db) + assert result.exit_code == 0 + + result = runner.invoke(show.cli.commands['ssh'], obj=db) + assert result.exit_code == 0