-
Notifications
You must be signed in to change notification settings - Fork 37
e2e-tests: Add tests for authctl set-uid/set-gid commands
#1385
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
nooreldeenmansour
wants to merge
3
commits into
main
Choose a base branch
from
authctl-set-uid/gid-tests
base: main
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.
+187
−2
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| *** Settings *** | ||
| Resource ./resources/authd/utils.resource | ||
| Resource ./resources/authd/authd.resource | ||
| Resource ./resources/broker/broker.resource | ||
|
|
||
| # Test Tags robot:exit-on-failure | ||
|
|
||
| Test Setup utils.Test Setup ${snapshot} | ||
| Test Teardown utils.Test Teardown | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${snapshot} %{BROKER}-installed | ||
| ${username} %{E2E_USER} | ||
| ${local_password} qwer1234 | ||
| ${new_gid} 60500 | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Test authctl group set-gid | ||
| [Documentation] Test that authctl group set-gid changes the GID of a remote group | ||
| ... and updates the home directory ownership. | ||
|
|
||
| Log In | ||
|
|
||
| Open Terminal | ||
| Log In With Remote User Through CLI: QR Code ${username} ${local_password} | ||
| Check If User Was Added Properly ${username} | ||
| Log Out From Terminal Session | ||
| Close Focused Window | ||
|
|
||
| # No session termination needed here: unlike set-uid (which calls | ||
| # proc.CheckUserBusy), set-gid does not check for running processes. | ||
|
|
||
| ${group_name} = SSH.Execute id -gn ${username} | ||
| Should Not Be Empty ${group_name} | ||
|
|
||
| ${home_dir} = SSH.Execute getent passwd ${username} | cut -d: -f6 | ||
| Should Not Be Empty ${home_dir} | ||
| SSH.Execute sudo -u ${username} touch ${home_dir}/test-file | ||
|
|
||
| ${output} = SSH.Execute sudo authctl group set-gid ${group_name} ${new_gid} 2>&1 | ||
| Should Contain ${output} GID of group '${group_name}' set to ${new_gid}. | ||
|
|
||
| ${actual_gid} = SSH.Execute getent group ${group_name} | cut -d: -f3 | ||
| Should Be Equal As Strings ${actual_gid} ${new_gid} | ||
|
|
||
| ${reverse_lookup} = SSH.Execute getent group ${new_gid} | cut -d: -f1 | ||
| Should Be Equal As Strings ${reverse_lookup} ${group_name} | ||
|
|
||
| ${passwd_gid} = SSH.Execute getent passwd ${username} | cut -d: -f4 | ||
| Should Be Equal As Strings ${passwd_gid} ${new_gid} | ||
|
|
||
| ${home_gid} = SSH.Execute stat -c %g ${home_dir} | ||
| Should Be Equal As Strings ${home_gid} ${new_gid} | ||
| ${file_gid} = SSH.Execute sudo stat -c %g ${home_dir}/test-file | ||
| Should Be Equal As Strings ${file_gid} ${new_gid} | ||
|
|
||
| Open Terminal | ||
| Log In With Remote User Through CLI: Local Password ${username} ${local_password} | ||
| ${post_login_gid} = SSH.Execute getent passwd ${username} | cut -d: -f4 | ||
| Should Be Equal As Strings ${post_login_gid} ${new_gid} | ||
| Log Out From Terminal Session | ||
| Close Focused Window |
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,65 @@ | ||
| *** Settings *** | ||
| Resource ./resources/authd/utils.resource | ||
| Resource ./resources/authd/authd.resource | ||
| Resource ./resources/broker/broker.resource | ||
|
|
||
| # Test Tags robot:exit-on-failure | ||
|
|
||
| Test Setup utils.Test Setup ${snapshot} | ||
| Test Teardown utils.Test Teardown | ||
|
|
||
|
|
||
| *** Variables *** | ||
| ${snapshot} %{BROKER}-installed | ||
| ${username} %{E2E_USER} | ||
| ${local_password} qwer1234 | ||
| ${new_uid} 60500 | ||
|
|
||
|
|
||
| *** Test Cases *** | ||
| Test authctl user set-uid | ||
| [Documentation] Test that authctl user set-uid changes the UID of a remote user | ||
| ... and updates the home directory ownership. | ||
|
|
||
| Log In | ||
|
|
||
| Open Terminal | ||
| Log In With Remote User Through CLI: QR Code ${username} ${local_password} | ||
| Check If User Was Added Properly ${username} | ||
| Log Out From Terminal Session | ||
| Close Focused Window | ||
|
|
||
| ${home_dir} = SSH.Execute getent passwd ${username} | cut -d: -f6 | ||
| Should Not Be Empty ${home_dir} | ||
| SSH.Execute sudo -u ${username} touch ${home_dir}/test-file | ||
|
|
||
| # Terminate the remote user's session so that proc.CheckUserBusy (which | ||
| # rejects set-uid when any process runs under that UID) does not block the | ||
| # operation. Use loginctl to tear down the session gracefully, then poll | ||
| # until all processes have exited rather than relying on a hard sleep. | ||
| SSH.Execute sudo loginctl terminate-user ${username} || true | ||
| Wait Until Keyword Succeeds 30s 1s SSH.Execute test -z "$(pgrep -u ${username})" | ||
|
|
||
| ${output} = SSH.Execute sudo authctl user set-uid ${username} ${new_uid} 2>&1 | ||
| Should Contain ${output} UID of user '${username}' set to ${new_uid}. | ||
|
|
||
| ${actual_uid} = SSH.Execute getent passwd ${username} | cut -d: -f3 | ||
| Should Be Equal As Strings ${actual_uid} ${new_uid} | ||
|
|
||
| ${reverse_lookup} = SSH.Execute getent passwd ${new_uid} | cut -d: -f1 | ||
| Should Be Equal As Strings ${reverse_lookup} ${username} | ||
|
|
||
| ${id_output} = SSH.Execute id ${username} | ||
| Should Contain ${id_output} uid=${new_uid} | ||
|
|
||
| ${home_uid} = SSH.Execute stat -c %u ${home_dir} | ||
| Should Be Equal As Strings ${home_uid} ${new_uid} | ||
| ${file_uid} = SSH.Execute sudo stat -c %u ${home_dir}/test-file | ||
| Should Be Equal As Strings ${file_uid} ${new_uid} | ||
|
|
||
| Open Terminal | ||
| Log In With Remote User Through CLI: Local Password ${username} ${local_password} | ||
| ${id_uid} = SSH.Execute id -u ${username} | ||
| Should Be Equal As Strings ${id_uid} ${new_uid} | ||
| Log Out From Terminal Session | ||
| Close Focused Window | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check that the ownership of files is changed recursively, we could create a file (e.g.
touch foo) above, in line 27, and then check the ownership of that file here. Same in theset-gidtest.