提交 5f5e86de 编写于 作者: D Daniel Beck 提交者: GitHub

Merge pull request #2726 from Vlatombe/JENKINS-41511

[JENKINS-41511] Don't try to set slaveAgentPort when it is enforced
......@@ -79,7 +79,7 @@ public class GlobalSecurityConfiguration extends ManagementLink implements Descr
* @since 2.24
* @return true if the slave agent port is enforced on this instance.
*/
@Restricted(DoNotUse.class) // only for index.groovy
@Restricted(NoExternalUse.class)
public boolean isSlaveAgentPortEnforced() {
return Jenkins.getInstance().isSlaveAgentPortEnforced();
}
......@@ -114,10 +114,12 @@ public class GlobalSecurityConfiguration extends ManagementLink implements Descr
j.setDisableRememberMe(security.optBoolean("disableRememberMe", false));
j.setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm"));
j.setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization"));
try {
j.setSlaveAgentPort(new ServerTcpPort(security.getJSONObject("slaveAgentPort")).getPort());
} catch (IOException e) {
throw new hudson.model.Descriptor.FormException(e, "slaveAgentPortType");
if (!isSlaveAgentPortEnforced()) {
try {
j.setSlaveAgentPort(new ServerTcpPort(security.getJSONObject("slaveAgentPort")).getPort());
} catch (IOException e) {
throw new hudson.model.Descriptor.FormException(e, "slaveAgentPortType");
}
}
Set<String> agentProtocols = new TreeSet<>();
if (security.has("agentProtocol")) {
......
package jenkins.bugs;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import hudson.security.HudsonPrivateSecurityRealm;
import jenkins.model.Jenkins;
public class Jenkins41511Test {
@BeforeClass
public static void setUpClass() {
System.setProperty(Jenkins.class.getName()+".slaveAgentPort", "10000");
System.setProperty(Jenkins.class.getName()+".slaveAgentPortEnforce", "true");
}
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
public void configRoundTrip() throws Exception {
Jenkins.getInstance().setSecurityRealm(new HudsonPrivateSecurityRealm(true, false, null));
j.submit(j.createWebClient().goTo("configureSecurity").getFormByName("config"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册