提交 552d2835 编写于 作者: O Oliver Gondža

Address review comment

上级 d165579a
......@@ -426,7 +426,7 @@ public class CLI implements AutoCloseable {
System.exit(_main(_args));
} catch (NotTalkingToJenkinsException ex) {
System.err.println(ex.getMessage());
System.exit(-1);
System.exit(3);
} catch (Throwable t) {
// if the CLI main thread die, make sure to kill the JVM.
t.printStackTrace();
......
......@@ -174,14 +174,14 @@ public class CLITest {
r.waitForCompletion(p.getLastBuild());
}
@Test
@Test @Issue("JENKINS-44361")
public void reportNotJenkins() throws Exception {
home = tempHome();
grabCliJar();
for (String transport: Arrays.asList("-remoting", "-http", "-ssh")) {
String url = r.getURL().toExternalForm() + "not-jenkins/";
for (String transport : Arrays.asList("-remoting", "-http", "-ssh")) {
String url = "http://jenkins.io";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int ret = new Launcher.LocalLauncher(StreamTaskListener.fromStderr()).launch().cmds(
"java", "-Duser.home=" + home, "-jar", jar.getAbsolutePath(), "-s", url, transport, "-user", "asdf", "who-am-i"
......@@ -191,8 +191,38 @@ public class CLITest {
assertNotEquals(0, ret);
}
}
@TestExtension("reportNotJenkins")
public static final class NoJenkinsAction extends CrumbExclusion implements UnprotectedRootAction, StaplerProxy {
@Test
@Override public String getIconFileName() {
return "not-jenkins";
}
@Override public String getDisplayName() {
return "not-jenkins";
}
@Override public String getUrlName() {
return "not-jenkins";
}
@Override public Object getTarget() {
doDynamic(Stapler.getCurrentRequest(), Stapler.getCurrentResponse());
return this;
}
public void doDynamic(StaplerRequest req, StaplerResponse rsp) {
rsp.setStatus(200);
}
@Override // Permit access to cli-proxy/XXX without CSRF checks
public boolean process(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, response);
return true;
}
}
@Test @Issue("JENKINS-44361")
public void redirectToEndpointShouldBeFollowed() throws Exception {
home = tempHome();
grabCliJar();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册