File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 } "
You can’t perform that action at this time.
0 commit comments