From d23f31e240d4da04576a674ec927c82065096b20 Mon Sep 17 00:00:00 2001 From: Akshay Sakure Date: Tue, 21 Jul 2026 23:21:39 +0530 Subject: [PATCH 1/3] Tests: Groupadd command displays usage with -h option This is Python transformation of the test located in `tests/grouptools/groupadd/22_groupadd_usage/groupadd.test` which checks that `groupadd` command shows usage with -h option Signed-off-by: Akshay Sakure --- tests/system/tests/test_groupadd.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/system/tests/test_groupadd.py b/tests/system/tests/test_groupadd.py index e5a0faae54..da34b46b27 100644 --- a/tests/system/tests/test_groupadd.py +++ b/tests/system/tests/test_groupadd.py @@ -8,6 +8,7 @@ import pytest from passlib.hash import sha512_crypt +from pytest_mh.conn import ProcessError from framework.misc import shadow_password_pattern from framework.roles.shadow import Shadow @@ -150,3 +151,21 @@ def test_groupadd__force_group_creation(shadow: Shadow): gshadow_entry = shadow.tools.getent.gshadow("tgroup") assert gshadow_entry is not None, "Group should be found" assert gshadow_entry.name == "tgroup", "Incorrect groupname" + + +@pytest.mark.topology(KnownTopology.Shadow) +def test_groupadd__usage(shadow: Shadow): + """ + :title: Groupadd command displays usage with -h option and exits successfully + :setup: + 1. None required + :steps: + 1. Run groupadd command with -h option + 2. Verify that groupadd command exits successfully + :expectedresults: + 1. Command shows usage help + 2. groupadd command completes successfully + :customerscenario: False + """ + result = shadow.groupadd("-h") + assert result.rc == 0, f"Expected return code 0(success), got {result.rc}" From 30cb786727d1a64ec1bb675d548162f85b88b228 Mon Sep 17 00:00:00 2001 From: Akshay Sakure Date: Tue, 21 Jul 2026 23:24:05 +0530 Subject: [PATCH 2/3] Tests: Groupadd command fails when no groupname is mentioned This is Python transformation of the test located in `tests/grouptools/groupadd/23_groupadd_no_groups/groupadd.test` which checks that `groupadd` fails when no groupname is mentioned Signed-off-by: Akshay Sakure --- tests/system/tests/test_groupadd.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/system/tests/test_groupadd.py b/tests/system/tests/test_groupadd.py index da34b46b27..f91ff1a234 100644 --- a/tests/system/tests/test_groupadd.py +++ b/tests/system/tests/test_groupadd.py @@ -169,3 +169,22 @@ def test_groupadd__usage(shadow: Shadow): """ result = shadow.groupadd("-h") assert result.rc == 0, f"Expected return code 0(success), got {result.rc}" + + +@pytest.mark.topology(KnownTopology.Shadow) +def test_groupadd__no_group(shadow: Shadow): + """ + :title: Groupadd command fails when no group is mentioned + :setup: + 1. None required + :steps: + 1. Run groupadd command without any argument + 2. Verify that groupadd command fails + :expectedresults: + 1. Command without any argument fails + 2. groupadd command fails with error (invalid usage) + :customerscenario: False + """ + with pytest.raises(ProcessError) as exc_info: + shadow.host.conn.run("groupadd") + assert exc_info.value.rc == 2, f"Expected return code 2(invalid usage), got {exc_info.value.rc}" From cbb8850534b22f8266af66e9b914f7f5ede2432e Mon Sep 17 00:00:00 2001 From: Akshay Sakure Date: Tue, 21 Jul 2026 23:27:33 +0530 Subject: [PATCH 3/3] Tests: Groupadd command fails when two groupnames are mentioned This is Python transformation of the test located in `tests/grouptools/groupadd/24_groupadd_2_groups/groupadd.test` which checks that `groupadd` command fails when two groupnames are mentioned Signed-off-by: Akshay Sakure --- tests/system/tests/test_groupadd.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/system/tests/test_groupadd.py b/tests/system/tests/test_groupadd.py index f91ff1a234..fab4eb0353 100644 --- a/tests/system/tests/test_groupadd.py +++ b/tests/system/tests/test_groupadd.py @@ -188,3 +188,22 @@ def test_groupadd__no_group(shadow: Shadow): with pytest.raises(ProcessError) as exc_info: shadow.host.conn.run("groupadd") assert exc_info.value.rc == 2, f"Expected return code 2(invalid usage), got {exc_info.value.rc}" + + +@pytest.mark.topology(KnownTopology.Shadow) +def test_groupadd__two_groups(shadow: Shadow): + """ + :title: Groupadd command fails when two groups are mentioned + :setup: + 1. None required + :steps: + 1. Run groupadd command with two groupnames + 2. Verify that groupadd command fails + :expectedresults: + 1. Command with two groupnames fails + 2. groupadd command fails with error (invalid usage) + :customerscenario: False + """ + with pytest.raises(ProcessError) as exc_info: + shadow.groupadd("tgroup1 tgroup2") + assert exc_info.value.rc == 2, f"Expected return code 0(invalid usage), got {exc_info.value.rc}"