-
Notifications
You must be signed in to change notification settings - Fork 251
Expand system test framework #1340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ikerexxe
wants to merge
11
commits into
shadow-maint:master
Choose a base branch
from
ikerexxe:test-newusers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
34da0c7
share/ansible/: create the newusers PAM service file
ikerexxe 773b054
tests/system/framework/roles/shadow.py: implement binding for `newusers`
ikerexxe 945b4ed
tests/system/tests/test_newusers.py: create multiple users from stdin
ikerexxe 3849046
tests/system/tests/test_newusers.py: create multiple users using file…
ikerexxe ac20b9b
share/ansible/: create the groupmems PAM service file
ikerexxe 100f260
tests/system/framework/roles/shadow.py: implement binding for `groupm…
ikerexxe 741f5ed
tests/system/tests/test_groupmems.py: add user to group as root user
ikerexxe 9af06c4
share/ansible/: install `expect` package
ikerexxe 3b72b95
share/ansible/: Make sure `expect` is found in Alpine
ikerexxe 16fa2b8
tests/system/framework/roles/shadow.py: implement binding for `newgrp`
ikerexxe 390aa4a
tests/system/tests/test_newgrp.py: change to new group
ikerexxe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
- autoconf | ||
- automake | ||
- diffutils | ||
- expect | ||
- gawk | ||
- gcc | ||
- gettext-tools | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Test groupmems | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from framework.roles.shadow import Shadow | ||
from framework.topology import KnownTopology | ||
|
||
|
||
@pytest.mark.topology(KnownTopology.Shadow) | ||
def test_groupmems__add_user_as_root(shadow: Shadow): | ||
""" | ||
:title: Add user to group as root user | ||
:setup: | ||
1. Create test user and group | ||
:steps: | ||
1. Add user to group using groupmems as root | ||
2. Check group and gshadow entry | ||
:expectedresults: | ||
1. User is added to group | ||
2. group and gshadow entry values are correct | ||
:customerscenario: False | ||
""" | ||
shadow.useradd("tuser") | ||
shadow.groupadd("tgroup") | ||
|
||
shadow.groupmems("-g tgroup -a tuser") | ||
|
||
group_entry = shadow.tools.getent.group("tgroup") | ||
assert group_entry is not None, "Group should be found" | ||
assert group_entry.name == "tgroup", "Incorrect groupname" | ||
assert "tuser" in group_entry.members, "User should be member of group" | ||
|
||
if shadow.host.features["gshadow"]: | ||
gshadow_entry = shadow.tools.getent.gshadow("tgroup") | ||
assert gshadow_entry is not None, "Group should be found" | ||
assert gshadow_entry.name == "tgroup", "Incorrect groupname" | ||
assert gshadow_entry.password == "!", "Incorrect password" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Test newgrp | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import pytest | ||
|
||
from framework.roles.shadow import Shadow | ||
from framework.topology import KnownTopology | ||
|
||
|
||
@pytest.mark.topology(KnownTopology.Shadow) | ||
def test_newgrp__change_to_new_group(shadow: Shadow): | ||
""" | ||
:title: Change to a new group using newgrp | ||
:setup: | ||
1. Create test user and group | ||
2. Add user to the group | ||
:steps: | ||
1. Use newgrp to change to the new group | ||
2. Check that the group change worked | ||
:expectedresults: | ||
1. newgrp command succeeds | ||
2. Current group ID matches the new group | ||
:customerscenario: False | ||
""" | ||
shadow.useradd("tuser") | ||
shadow.groupadd("tgroup") | ||
shadow.usermod("-a -G tgroup tuser") | ||
|
||
cmd, gid = shadow.newgrp("tgroup", run_as="tuser") | ||
assert cmd.rc == 0, "newgrp command should succeed" | ||
assert gid == 1001, f"Current GID should be {1001}, got {gid}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.