Skip to content

Tests: Add system tests for groupadd in test_groupadd.py#1655

Open
asakure wants to merge 3 commits into
shadow-maint:masterfrom
asakure:system_tests_groupadd
Open

Tests: Add system tests for groupadd in test_groupadd.py#1655
asakure wants to merge 3 commits into
shadow-maint:masterfrom
asakure:system_tests_groupadd

Conversation

@asakure

@asakure asakure commented Jun 23, 2026

Copy link
Copy Markdown

Add system tests for groupadd in test_groupadd.py.

@ikerexxe ikerexxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the inline comments I have some generic ones:

  • Add the path to the test that you are transforming in the commit message. Just to give you an example as how it should look like: b19a9d2 and 89aaea2
  • Use and instead of the informal & in test steps

Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
Comment thread tests/system/tests/test_groupadd.py Outdated
This is Python transformation of the test located in
`tests/grouptools/groupadd/05_groupadd_set_GID/groupadd.test`
which checks that `groupadd` can create group with sepcified GID
using -g flag

Signed-off-by: Akshay Sakure <asakure@redhat.com>
@asakure asakure force-pushed the system_tests_groupadd branch from 8ba884c to 9cafdaf Compare June 24, 2026 18:38

@ikerexxe ikerexxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been improved quite a bit. There are still some minor things to improve, but I think we are on the right track

Comment thread tests/system/tests/test_groupadd.py Outdated
Comment on lines +98 to +99
1. Check group entry in group file
2. Check group entry in gshadow file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the in * file suffix. This should be:

1. Check group entry
2. Check gshadow entry

Comment thread tests/system/tests/test_groupadd.py Outdated
Comment on lines +125 to +127
1. Command groupadd -f tgroup exits successfully without error
2. Group entry in group file is unchanged with the original name
3. Group entry in gshadow file is unchanged with the original name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation issue

:customerscenario: False
"""
shadow.groupadd("-p Secret123 tgroup")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the group entry check:

group_entry = shadow.tools.getent.group("tgroup")
assert group_entry is not None, "Group tgroup should be found"
...

Comment thread tests/system/tests/test_groupadd.py Outdated


@pytest.mark.topology(KnownTopology.Shadow)
def test_groupadd__f_option_add_existing_group(shadow: Shadow):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about test_groupadd__force_group_creation?

Comment on lines +132 to +133
existing_group_entry = shadow.tools.getent.group("tgroup")
assert existing_group_entry is not None, "Group should be found"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing in the steps

Comment thread tests/system/tests/test_groupadd.py Outdated
:setup:
1. Create group tgroup
:steps:
1. Run groupadd command with -f option to add an existing group

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrase this to bring it into line with the project’s conventions

Comment thread tests/system/tests/test_groupadd.py Outdated

if shadow.host.features["gshadow"]:
gshadow_entry = shadow.tools.getent.gshadow("tgroup")
assert gshadow_entry is noit None, "Group should be found"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/noit/not

@ikerexxe

Copy link
Copy Markdown
Collaborator

Please also check CI failures

@asakure asakure force-pushed the system_tests_groupadd branch from 9cafdaf to 2680fa4 Compare June 25, 2026 10:28
asakure added 2 commits June 25, 2026 16:12
This is Python transformation of the test located in
`tests/grouptools/groupadd/04_groupadd_set_password/groupadd.test`
which checks that `groupadd` can create group with password using
-p flag

Signed-off-by: Akshay Sakure <asakure@redhat.com>
This is Python transformation of the test located in
`tests/grouptools/groupadd/06_groupadd_-f_add_existing_group/groupadd.test`
which verifies if groupadd -f exits successfully when the
specified group already exists.

Signed-off-by: Akshay Sakure <asakure@redhat.com>
@asakure asakure force-pushed the system_tests_groupadd branch from 2680fa4 to 4010eba Compare June 25, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants