Explicitly switch user for code execution.

Co-authored-by: Maximilian Pass <maximilian.pass@student.hpi.uni-potsdam.de>
This commit is contained in:
Sebastian Serth
2022-09-18 01:52:15 +02:00
committed by Sebastian Serth
parent 69237fb415
commit 1a5a49d7c8
13 changed files with 144 additions and 67 deletions

View File

@@ -82,6 +82,19 @@ func (s *E2ETestSuite) TestOutputToStderr() {
}
}
func (s *E2ETestSuite) TestUserNomad() {
s.Run("unprivileged", func() {
stdout, _, _ := ExecuteNonInteractive(&s.Suite, tests.DefaultEnvironmentIDAsInteger,
&dto.ExecutionRequest{Command: "id --name --user", PrivilegedExecution: false}, nil)
s.Require().NotEqual("root", stdout)
})
s.Run("privileged", func() {
stdout, _, _ := ExecuteNonInteractive(&s.Suite, tests.DefaultEnvironmentIDAsInteger,
&dto.ExecutionRequest{Command: "id --name --user", PrivilegedExecution: true}, nil)
s.Require().Equal("root\r\n", stdout)
})
}
// AWS environments do not support stdin at this moment therefore they cannot take this test.
func (s *E2ETestSuite) TestCommandHead() {
hello := "Hello World!"