Shaman: fail unit test when running as root user (linux) #104234
No reviewers
Labels
No Label
Good First Issue
Priority
High
Priority
Low
Priority
Normal
Status
Archived
Status
Confirmed
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Job Type
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: studio/flamenco#104234
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "michael-2/flamenco:mgr_api_meta_test_TestCheckSharedStoragePath"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Related: #104233
If the mock tests are run by root user then this specific test of inaccessible path fails because root can write files to anywhere on the filesystem. It is not clear that Flamenco Manager test TestCheckSharedStoragePath is checking inaccessible file locations when it fails and that it should be run by an unprivileged user.
Fix is to fail the permission test if the tests are run as a root user.
This IMO is not a good idea, especially because it happens silently. If this test is known to require a non-root account, it should simply fail if that requirement is not met.
@ -198,1 +193,4 @@
currentUser, err := user.Current()
if err != nil {
t.FailNow()
I feel there's too much nesting going on here. Also
t.FailNow()
wouldn't show the actual content oferr
. Finally, the original code was written before I realised I could dorequire.NoError(...)
instead ofassert.NoError(...)
and it would immediately stop the test.This would be better:
Thanks for the review. I agree with your points and failing on root is a better solution and using your code snippet makes sense.
Tested as root user inside a Docker container...
Flamenco Unit Test - meta_test.go - TestCheckSharedStoragePath ignore permission test if tests are run as root user (linux)to Flamenco Unit Test - meta_test.go - TestCheckSharedStoragePath fail permission test if tests are run as root user (linux)Flamenco Unit Test - meta_test.go - TestCheckSharedStoragePath fail permission test if tests are run as root user (linux)to Shaman: fail unit test when running as root user (linux)@ -203,6 +214,7 @@ func TestCheckSharedStoragePath(t *testing.T) {
assert.Equal(t, testPath, result.Path)
assert.False(t, result.IsUsable)
assert.Contains(t, result.Cause, "Unable to create a file")
Please keep unrelated formatting changes out of a PR. I'll remove this before landing; this is just a request for other/future PRs.
Thanks!