提交 5a547c91 编写于 作者: K Kohsuke Kawaguchi

Fixed an overzealous form validation

上级 6ceafac2
......@@ -405,7 +405,9 @@ public abstract class Slave extends Node implements Serializable {
if(value.startsWith("\\\\") || value.startsWith("/net/"))
return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning());
if (!value.startsWith("\\") && !value.startsWith("/")) {
if (!value.contains("\\") && !value.startsWith("/")) {
// Unix-looking path that doesn't start with '/'
// TODO: detect Windows-looking relative path
return FormValidation.error(Messages.Slave_the_remote_root_must_be_an_absolute_path());
}
......
......@@ -24,10 +24,14 @@
package hudson.model
import hudson.slaves.DumbSlave
import hudson.util.FormValidation
import org.jvnet.hudson.test.GroovyHudsonTestCase
import org.apache.commons.io.IOUtils
import hudson.slaves.JNLPLauncher
import static hudson.util.FormValidation.Kind.ERROR
import static hudson.util.FormValidation.Kind.WARNING
/**
*
*
......@@ -78,4 +82,13 @@ public class SlaveTest extends GroovyHudsonTestCase {
con.outputStream.close();
IOUtils.copy(con.inputStream,System.out)
}
public void testRemoteFsCheck() {
def d = jenkins.getDescriptorByType(DumbSlave.DescriptorImpl.class)
assert d.doCheckRemoteFS("c:\\")==FormValidation.ok();
assert d.doCheckRemoteFS("/tmp")==FormValidation.ok();
assert d.doCheckRemoteFS("relative/path").kind==ERROR;
assert d.doCheckRemoteFS("/net/foo/bar/zot").kind==WARNING;
assert d.doCheckRemoteFS("\\\\machine\\folder\\foo").kind==WARNING;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册