diff options
Diffstat (limited to 'smoketest/scripts/cli')
| -rw-r--r-- | smoketest/scripts/cli/base_vyostest_shim.py | 6 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_protocols_bgp.py | 36 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_system_login.py | 20 | 
3 files changed, 59 insertions, 3 deletions
| diff --git a/smoketest/scripts/cli/base_vyostest_shim.py b/smoketest/scripts/cli/base_vyostest_shim.py index edf940efd..f0674f187 100644 --- a/smoketest/scripts/cli/base_vyostest_shim.py +++ b/smoketest/scripts/cli/base_vyostest_shim.py @@ -94,14 +94,18 @@ class VyOSUnitTestSHIM:          def cli_commit(self):              if self.debug:                  print('commit') -            self._session.commit()              # During a commit there is a process opening commit_lock, and run()              # returns 0              while run(f'sudo lsof -nP {commit_lock}') == 0:                  sleep(0.250) +            # Return the output of commit +            # Necessary for testing Warning cases +            out = self._session.commit()              # Wait for CStore completion for fast non-interactive commits              sleep(self._commit_guard_time) +            return out +          def op_mode(self, path : list) -> None:              """              Execute OP-mode command and return stdout diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py index d8d5415b5..8403dcc37 100755 --- a/smoketest/scripts/cli/test_protocols_bgp.py +++ b/smoketest/scripts/cli/test_protocols_bgp.py @@ -1540,6 +1540,42 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase):          self.assertIn(f'neighbor OVERLAY remote-as {int(ASN) + 1}', conf)          self.assertIn(f'neighbor OVERLAY local-as {int(ASN) + 1}', conf) +    def test_bgp_30_import_vrf_routemap(self): +        router_id = '127.0.0.3' +        table = '1000' +        vrf = 'red' +        vrf_base = ['vrf', 'name', vrf] +        self.cli_set(vrf_base + ['table', table]) +        self.cli_set(vrf_base + ['protocols', 'bgp', 'system-as', ASN]) +        self.cli_set( +            vrf_base + ['protocols', 'bgp', 'parameters', 'router-id', +                        router_id]) + +        self.cli_set( +            base_path + ['address-family', 'ipv4-unicast', 'import', +                         'vrf', vrf]) +        self.cli_set( +            base_path + ['address-family', 'ipv4-unicast', 'route-map', +                         'vrf', 'import',  route_map_in]) + +        self.cli_commit() + +        # Verify FRR bgpd configuration +        frrconfig = self.getFRRconfig(f'router bgp {ASN}', +                                      endsection='^exit') +        self.assertIn(f'router bgp {ASN}', frrconfig) +        self.assertIn(f' address-family ipv4 unicast', frrconfig) + +        self.assertIn(f'  import vrf {vrf}', frrconfig) +        self.assertIn(f'  import vrf route-map {route_map_in}', frrconfig) + +        # Verify FRR bgpd configuration +        frr_vrf_config = self.getFRRconfig( +            f'router bgp {ASN} vrf {vrf}', endsection='^exit') +        self.assertIn(f'router bgp {ASN} vrf {vrf}', frr_vrf_config) +        self.assertIn(f' bgp router-id {router_id}', frr_vrf_config) + +      def test_bgp_99_bmp(self):          target_name = 'instance-bmp'          target_address = '127.0.0.1' diff --git a/smoketest/scripts/cli/test_system_login.py b/smoketest/scripts/cli/test_system_login.py index d79f5521c..ed72f378e 100755 --- a/smoketest/scripts/cli/test_system_login.py +++ b/smoketest/scripts/cli/test_system_login.py @@ -25,7 +25,9 @@ import shutil  from base_vyostest_shim import VyOSUnitTestSHIM +from contextlib import redirect_stdout  from gzip import GzipFile +from io import StringIO, TextIOWrapper  from subprocess import Popen  from subprocess import PIPE  from pwd import getpwall @@ -42,6 +44,7 @@ from vyos.xml_ref import default_value  base_path = ['system', 'login']  users = ['vyos1', 'vyos-roxx123', 'VyOS-123_super.Nice'] +weak_passwd_user = ['test_user', 'passWord1']  ssh_test_command = '/opt/vyatta/bin/vyatta-op-cmd-wrapper show version' @@ -194,18 +197,20 @@ class TestSystemLogin(VyOSUnitTestSHIM.TestCase):      def test_system_login_user(self):          for user in users:              name = f'VyOS Roxx {user}' +            passwd = f'{user}-pSWd-t3st'              home_dir = f'/tmp/smoketest/{user}' -            self.cli_set(base_path + ['user', user, 'authentication', 'plaintext-password', user]) +            self.cli_set(base_path + ['user', user, 'authentication', 'plaintext-password', passwd])              self.cli_set(base_path + ['user', user, 'full-name', name])              self.cli_set(base_path + ['user', user, 'home-directory', home_dir])          self.cli_commit()          for user in users: +            passwd = f'{user}-pSWd-t3st'              tmp = ['su','-', user]              proc = Popen(tmp, stdin=PIPE, stdout=PIPE, stderr=PIPE) -            tmp = f'{user}\nuname -a' +            tmp = f'{passwd}\nuname -a'              proc.stdin.write(tmp.encode())              proc.stdin.flush()              (stdout, stderr) = proc.communicate() @@ -229,6 +234,17 @@ class TestSystemLogin(VyOSUnitTestSHIM.TestCase):          tmp = cmd(f'sudo passwd -S {locked_user}')          self.assertIn(f'{locked_user} P ', tmp) +    def test_system_login_weak_password_warning(self): +        self.cli_set(base_path + [ +            'user', weak_passwd_user[0], 'authentication', +            'plaintext-password', weak_passwd_user[1] +        ]) + +        out = self.cli_commit().strip() + +        self.assertIn('WARNING: The password complexity is too low', out) +        self.cli_delete(base_path + ['user', weak_passwd_user[0]]) +      def test_system_login_otp(self):          otp_user = 'otp-test_user'          otp_password = 'SuperTestPassword' | 
