Allow the user that runs the app to be specified via an env var
See gh-16973
This commit is contained in:
committed by
Andy Wilkinson
parent
ea6d9f3328
commit
b57f35893c
@@ -267,6 +267,36 @@ public class SysVinitLaunchScriptIT {
|
||||
assertThat(output).contains("Log written");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@MethodSource("parameters")
|
||||
public void launchWithRunAs(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-run-as.sh");
|
||||
assertThat(output).contains("wagner root");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@MethodSource("parameters")
|
||||
public void launchWithRunAsInvalidUser(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-run-as-invalid-user.sh");
|
||||
assertThat(output).contains("Status: 5");
|
||||
assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user"));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@MethodSource("parameters")
|
||||
public void launchWithRunAsPreferUserInformed(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-run-as-prefer-user-informed.sh");
|
||||
assertThat(output).contains("wagner root");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0} {1}")
|
||||
@MethodSource("parameters")
|
||||
public void launchWithRunAsRootRequired(String os, String version) throws Exception {
|
||||
String output = doTest(os, version, "launch-with-run-as-root-required.sh");
|
||||
assertThat(output).contains("Status: 6");
|
||||
assertThat(output).has(coloredString(AnsiColor.RED, "root required to run as 'wagner'"));
|
||||
}
|
||||
|
||||
static List<Object[]> parameters() {
|
||||
List<Object[]> parameters = new ArrayList<>();
|
||||
for (File os : new File("src/test/resources/conf").listFiles()) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
source ./test-functions.sh
|
||||
install_service
|
||||
|
||||
echo 'RUN_AS_USER=johndoe' > /test-service/spring-boot-app.conf
|
||||
|
||||
start_service
|
||||
echo "Status: $?"
|
||||
@@ -0,0 +1,13 @@
|
||||
source ./test-functions.sh
|
||||
install_service
|
||||
|
||||
useradd wagner
|
||||
echo 'RUN_AS_USER=wagner' > /test-service/spring-boot-app.conf
|
||||
|
||||
useradd phil
|
||||
chown phil /test-service/spring-boot-app.jar
|
||||
|
||||
start_service
|
||||
await_app
|
||||
|
||||
ls -la /var/log/spring-boot-app.log
|
||||
@@ -0,0 +1,9 @@
|
||||
source ./test-functions.sh
|
||||
install_service
|
||||
|
||||
useradd wagner
|
||||
echo 'RUN_AS_USER=wagner' > /test-service/spring-boot-app.conf
|
||||
echo "JAVA_HOME='$JAVA_HOME'" >> /test-service/spring-boot-app.conf
|
||||
|
||||
su - wagner -c "$(which service) spring-boot-app start"
|
||||
echo "Status: $?"
|
||||
@@ -0,0 +1,10 @@
|
||||
source ./test-functions.sh
|
||||
install_service
|
||||
|
||||
useradd wagner
|
||||
echo 'RUN_AS_USER=wagner' > /test-service/spring-boot-app.conf
|
||||
|
||||
start_service
|
||||
await_app
|
||||
|
||||
ls -la /var/log/spring-boot-app.log
|
||||
Reference in New Issue
Block a user