From d6e6e31c7c89e354da694eca5392465a2610ab71 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Wed, 12 Aug 2020 07:27:54 -0700 Subject: [PATCH] Fix JENKINS-63367 - Used "default" instead of "value" in the form element - Added test for this specific issue --- .../hudson/plugins/emailext/MailAccount.java | 2 +- .../emailext/MailAccount/config.groovy | 2 +- .../ExtendedEmailPublisherDescriptorTest.java | 21 +++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/hudson/plugins/emailext/MailAccount.java b/src/main/java/hudson/plugins/emailext/MailAccount.java index 8e89f0ba9..5a6d6a849 100644 --- a/src/main/java/hudson/plugins/emailext/MailAccount.java +++ b/src/main/java/hudson/plugins/emailext/MailAccount.java @@ -38,7 +38,7 @@ public MailAccount(JSONObject jo){ } @DataBoundConstructor - public MailAccount(){ + public MailAccount() { } diff --git a/src/main/resources/hudson/plugins/emailext/MailAccount/config.groovy b/src/main/resources/hudson/plugins/emailext/MailAccount/config.groovy index 46fc1dfd7..8e42e761d 100644 --- a/src/main/resources/hudson/plugins/emailext/MailAccount/config.groovy +++ b/src/main/resources/hudson/plugins/emailext/MailAccount/config.groovy @@ -16,7 +16,7 @@ f.entry(field: "smtpHost", title: _("SMTP Server")) { f.textbox() } f.entry(field: "smtpPort", title: _("SMTP Port")) { - f.number(value: 25) + f.number(default: "25") } f.advanced { diff --git a/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java b/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java index 5da5b324d..61e7e5f7d 100644 --- a/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java +++ b/src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptorTest.java @@ -50,8 +50,8 @@ public void testGlobalConfigDefaultState() throws Exception { assertEquals("SMTP Server should be blank by default", "", smtpHost.getText()); HtmlNumberInput smtpPort = page.getElementByName("_.smtpPort"); - assertNotNull("SMTP Server should be present", smtpPort); - assertEquals("SMTP Server should be blank by default", "25", smtpPort.getText()); + assertNotNull("SMTP Port should be present", smtpPort); + assertEquals("SMTP Port should be 25 by default", "25", smtpPort.getText()); HtmlTextInput defaultSuffix = page.getElementByName("_.defaultSuffix"); assertNotNull("Default suffix should be present", defaultSuffix); @@ -151,6 +151,23 @@ public void testGlobalConfigSimpleRoundTrip() throws Exception { assertEquals("mickey@disney.com", descriptor.getDefaultRecipients()); } + @Test + @Issue("JENKINS-63367") + public void testSmtpPortRetainsSetValue() throws Exception { + ExtendedEmailPublisherDescriptor descriptor = j.jenkins.getDescriptorByType(ExtendedEmailPublisherDescriptor.class); + JenkinsRule.WebClient client = j.createWebClient(); + HtmlPage page = client.goTo("configure"); + HtmlNumberInput smtpPort = page.getElementByName("_.smtpPort"); + smtpPort.setValueAttribute("587"); + j.submit(page.getFormByName("config")); + + assertEquals("587", descriptor.getMailAccount().getSmtpPort()); + + page = client.goTo("configure"); + smtpPort = page.getElementByName("_.smtpPort"); + assertEquals("587", smtpPort.getValueAttribute()); + } + @Test @Issue("JENKINS-20133") public void testPrecedenceBulkSettingRoundTrip() throws Exception {