提交 4666a876 编写于 作者: K Kohsuke Kawaguchi

Needed to resurrect validation, too.

上级 5541c42e
......@@ -3,9 +3,13 @@ package jenkins.model;
import hudson.Extension;
import hudson.Util;
import hudson.XmlFile;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
......@@ -84,5 +88,23 @@ public class JenkinsLocationConfiguration extends GlobalConfiguration {
return true;
}
/**
* Checks the URL in <tt>global.jelly</tt>
*/
public FormValidation doCheckUrl(@QueryParameter String value) {
if(value.startsWith("http://localhost"))
return FormValidation.warning(Messages.Mailer_Localhost_Error());
return FormValidation.ok();
}
public FormValidation doCheckAdminAddress(@QueryParameter String value) {
try {
new InternetAddress(value);
return FormValidation.ok();
} catch (AddressException e) {
return FormValidation.error(e.getMessage());
}
}
private static final Logger LOGGER = Logger.getLogger(JenkinsLocationConfiguration.class.getName());
}
......@@ -62,6 +62,7 @@ CLI.safe-shutdown.shortDescription=Puts Jenkins into the quiet mode, wait for ex
DefaultProjectNamingStrategy.DisplayName=Default
Mailer.Address.Not.Configured=address not configured yet <nobody@nowhere>
Mailer.Localhost.Error=Please set a valid host name, instead of localhost
PatternProjectNamingStrategy.DisplayName=Pattern
PatternProjectNamingStrategy.NamePatternRequired=Name Pattern is required
......
......@@ -51,3 +51,4 @@ CLI.reload-configuration.shortDescription=Genindl\u00e6s alle data fra filsystem
Nyttigt hvis du har modificeret konfigurationsfiler direkte, udenom Jenkins.
Mailer.Address.Not.Configured=Adresse ikke konfigureret <nobody@nowhere>
Mailer.Localhost.Error=Venligst inds\u00e6t et gyldigt v\u00e6rtsnavn, istedet for localhost
......@@ -53,3 +53,4 @@ CLI.reload-configuration.shortDescription=Alle Daten im Speicher verwerfen und K
CLI.safe-restart.shortDescription=Startet Jenkins neu.
Mailer.Address.Not.Configured=Adresse nicht konfiguriert <nobody@nowhere>
Mailer.Localhost.Error=Bitte verwenden Sie einen konkreten Hostnamen anstelle von ''localhost''.
......@@ -61,3 +61,4 @@ CauseOfInterruption.ShortDescription=Cancelado por {0}
PatternProjectNamingStrategy.NamePatternInvalidSyntax=La sintaxis de la expresin regular no es vlida
Mailer.Address.Not.Configured=Direccin no configurada todava <nobody@nowhere>
Mailer.Localhost.Error=Escriba un nombre de servidor correcto en lugar de "localhost"
......@@ -61,3 +61,4 @@ PatternProjectNamingStrategy.NamePatternRequired=\u30d1\u30bf\u30fc\u30f3\u306f\
PatternProjectNamingStrategy.NamePatternInvalidSyntax=\u6b63\u898f\u8868\u73fe\u306b\u8aa4\u308a\u304c\u3042\u308a\u307e\u3059\u3002
Mailer.Address.Not.Configured=\u307e\u3060\u30a2\u30c9\u30ec\u30b9\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002 <nobody@nowhere>
Mailer.Localhost.Error=localhost\u306e\u4ee3\u308f\u308a\u306b\u59a5\u5f53\u306a\u30db\u30b9\u30c8\u540d\u3092\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002
......@@ -46,3 +46,5 @@ CLI.keep-build.shortDescription=Marcar a constru\u00e7\u00e3o como permanente
# address not configured yet <nobody@nowhere>
Mailer.Address.Not.Configured=Endere\u00e7o ainda n\u00e3o configurado <nobody@nowhere>
# Please set a valid host name, instead of localhost
Mailer.Localhost.Error=Por favor insira uma nome de host v\u00e1lido.
package jenkins.model;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.jvnet.hudson.test.HudsonTestCase;
/**
* @author Kohsuke Kawaguchi
*/
public class JenkinsLocationConfigurationTest extends HudsonTestCase {
/**
* Makes sure the use of "localhost" in the Hudson URL reports a warning.
*/
public void testLocalHostWarning() throws Exception {
HtmlPage p = new WebClient().goTo("configure");
HtmlInput url = p.getFormByName("config").getInputByName("_.url");
url.setValueAttribute("http://localhost:1234/");
assertTrue(p.getDocumentElement().getTextContent().contains("instead of localhost"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册