Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1dee03d

Browse files
committed
tests/system/tests/test_newgrp.py: change to new group
Change to a new group using `newgrp`. Signed-off-by: Iker Pedrosa <[email protected]>
1 parent e2da706 commit 1dee03d

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/system/tests/test_newgrp.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
Test newgrp
3+
"""
4+
5+
from __future__ import annotations
6+
7+
import pytest
8+
9+
from framework.roles.shadow import Shadow
10+
from framework.topology import KnownTopology
11+
12+
13+
@pytest.mark.topology(KnownTopology.Shadow)
14+
def test_newgrp__change_to_new_group(shadow: Shadow):
15+
"""
16+
:title: Change to a new group using newgrp
17+
:setup:
18+
1. Create a test user
19+
2. Create a test group
20+
3. Add user to the group
21+
:steps:
22+
1. Use newgrp to change to the new group
23+
2. Check that the group change worked
24+
:expectedresults:
25+
1. newgrp command succeeds
26+
2. Current group ID matches the new group
27+
:customerscenario: False
28+
"""
29+
shadow.useradd("tuser")
30+
shadow.groupadd("tgroup")
31+
shadow.usermod("-a -G tgroup tuser")
32+
33+
cmd, gid = shadow.newgrp("tgroup", user="tuser")
34+
assert cmd.rc == 0, "newgrp command should succeed"
35+
assert gid == 1001, f"Current GID should be {1001}, got {gid}"

0 commit comments

Comments
 (0)