diff --git a/scrapli/driver/core/juniper_junos/base_driver.py b/scrapli/driver/core/juniper_junos/base_driver.py index 68cf7998..7371bef3 100644 --- a/scrapli/driver/core/juniper_junos/base_driver.py +++ b/scrapli/driver/core/juniper_junos/base_driver.py @@ -5,7 +5,7 @@ PRIVS = { "exec": ( PrivilegeLevel( - pattern=r"^({\w+:\d}\n){0,1}[\w\-@()/:\.]{1,63}>\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\n){0,1}[\w\-@()/:\.]{1,63}>\s?$", name="exec", previous_priv="", deescalate="", @@ -16,7 +16,7 @@ ), "configuration": ( PrivilegeLevel( - pattern=r"^({\w+:\d}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration", previous_priv="exec", deescalate="exit configuration-mode", @@ -27,7 +27,7 @@ ), "configuration_exclusive": ( PrivilegeLevel( - pattern=r"^({\w+:\d}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration_exclusive", previous_priv="exec", deescalate="exit configuration-mode", @@ -38,7 +38,7 @@ ), "configuration_private": ( PrivilegeLevel( - pattern=r"^({\w+:\d}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", + pattern=r"^({\w+(:(\w+){0,1}\d){0,1}}\[edit\]\n){0,1}[\w\-@()/:\.]{1,63}#\s?$", name="configuration_private", previous_priv="exec", deescalate="exit configuration-mode", diff --git a/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py b/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py index 6a544990..5fc54ac8 100644 --- a/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py +++ b/tests/unit/driver/core/juniper_junos/test_juniper_junos_base_driver.py @@ -12,7 +12,13 @@ ("configuration", "boxen# "), ("exec", "box_en> "), ("exec", "rancid@router2.xyz6> "), + ("exec", "{master}\nusername@MX-960-PE1>"), + ("exec", "{backup}\nusername@MX-480-PE2>"), + ("exec", "{primary:node0}\nusername@SRX-4600-FW1>"), ("configuration", "rancid@router2.xyz6# "), + ("configuration", "{master}[edit]\nusername@MX-960-PE1#"), + ("configuration", "{backup}[edit]\nusername@MX-480-PE2#"), + ("configuration", "{primary:node0}[edit]\nusername@SRX-4600-FW1#"), ("shell", "asdfklsdjlf\n%"), ("shell", "[vrf:foo] regress@EVOvFOOBAR_RE0-re0:~$"), ("root_shell", "root@%"), @@ -24,7 +30,13 @@ "configuration", "exec_underscore", "exec_w_period", + "exec-mx-master-re", + "exec-mx-backup-re", + "exec-srx-primary-node", "configuration_w_period", + "configuration-mx-master-re", + "configuration-mx-backup-re", + "configuration-srx-primary-node", "shell", "shell-re0", "root",