summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorStavros Kroustouris <kroustou@users.noreply.github.com>2026-06-25 22:30:57 +0300
committerGitHub <noreply@github.com>2026-06-26 05:30:57 +1000
commit6d7a2184e970624f74f333931f7f70a1f900f7b5 (patch)
treee7b9b58c5b8e4705446850cb7cd131be5f018243 /tests/unit
parent5b80cd0cbddd014e54b01e7fa1cd0c0777d94724 (diff)
downloadvyos.vyos-6d7a2184e970624f74f333931f7f70a1f900f7b5.tar.gz
vyos.vyos-6d7a2184e970624f74f333931f7f70a1f900f7b5.zip
T2295: vyos_user: quote plaintext-password in generated set commands (#480)
* vyos_user: quote plaintext-password in generated set commands VyOS requires quoted values for passwords with special characters. Align with encrypted-password and integration test conventions. Co-authored-by: Cursor <cursoragent@cursor.com> * T2295: escape plaintext-password values in vyos_user set commands Quote passwords for VyOS special-character handling and escape embedded single quotes. Update RETURN sample, add unit tests, refresh changelog. Co-authored-by: Cursor <cursoragent@cursor.com> * T2295: shorten changelog fragment for ansible-lint line-length Co-authored-by: Cursor <cursoragent@cursor.com> * T2295: use shlex.quote() for plaintext-password values Replace custom _quote_config_value() with stdlib shlex.quote() per review feedback; update unit tests and RETURN sample accordingly. Co-authored-by: Cursor <cursoragent@cursor.com> * T2295: add complex plaintext-password quoting unit test Cover spaces, shell metacharacters, embedded quotes, and backslashes in one password; assert command output matches shlex.quote(). Co-authored-by: Cursor <cursoragent@cursor.com> * T2295: assert explicit quoting in complex password unit test Replace shlex.quote()-derived expectation with a fixed command string, matching the other password quoting tests. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix RETURN doc sample, add docstrings and workflow permissions - RETURN sample was missing the username token in the example command - Add docstrings to all undocumented module-level functions to bring docstring coverage above the 80% threshold - Add explicit permissions: contents: read to codecoverage.yml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Revert "Fix RETURN doc sample, add docstrings and workflow permissions" This reverts commit 827809ee49cf472a8bf30ec0b24d347a75fcb083. --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: omnom62 <75066712+omnom62@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_user.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/modules/network/vyos/test_vyos_user.py b/tests/unit/modules/network/vyos/test_vyos_user.py
index d1e7f162..2cbd3820 100644
--- a/tests/unit/modules/network/vyos/test_vyos_user.py
+++ b/tests/unit/modules/network/vyos/test_vyos_user.py
@@ -62,6 +62,36 @@ class TestVyosUserModule(TestVyosModule):
["set system login user ansible authentication plaintext-password test"],
)
+ def test_vyos_user_password_special_chars(self):
+ set_module_args(dict(name="ansible", configured_password="test$123!@"))
+ result = self.execute_module(changed=True)
+ self.assertEqual(
+ result["commands"],
+ [
+ "set system login user ansible authentication plaintext-password 'test$123!@'",
+ ],
+ )
+
+ def test_vyos_user_password_embedded_quote(self):
+ set_module_args(dict(name="ansible", configured_password="pa'ss"))
+ result = self.execute_module(changed=True)
+ self.assertEqual(
+ result["commands"],
+ [
+ "set system login user ansible authentication plaintext-password 'pa'\"'\"'ss'",
+ ],
+ )
+
+ def test_vyos_user_password_complex_special_chars(self):
+ set_module_args(dict(name="ansible", configured_password="P@ss w0rd!$#'xy\\"))
+ result = self.execute_module(changed=True)
+ self.assertEqual(
+ result["commands"],
+ [
+ "set system login user ansible authentication plaintext-password 'P@ss w0rd!$#'\"'\"'xy\\'",
+ ],
+ )
+
def test_vyos_user_delete(self):
set_module_args(dict(name="ansible", state="absent"))
result = self.execute_module(changed=True)