Skip to content

Improve SMTP host and port validation with descriptor checks and unit…#1471

Open
wisekiran wants to merge 1 commit intojenkinsci:mainfrom
wisekiran:improve-smtp-validation
Open

Improve SMTP host and port validation with descriptor checks and unit…#1471
wisekiran wants to merge 1 commit intojenkinsci:mainfrom
wisekiran:improve-smtp-validation

Conversation

@wisekiran
Copy link

Summary

This PR improves validation for SMTP host and port fields in the MailAccount descriptor.

Changes include:

  • Added backend validation to ensure SMTP port is numeric and within the valid range (1–65535)
  • Added basic validation to prevent invalid SMTP host values (e.g., containing spaces)
  • Added unit tests to verify validation behavior

This change improves configuration UX and adds defensive validation without altering existing email sending behavior.


Testing done

Automated testing

  • Added unit tests covering:
    • Non-numeric SMTP port
    • Out-of-range SMTP port
    • Valid SMTP port
    • Invalid SMTP host containing spaces
    • Valid SMTP host
  • Verified mvn clean install completes successfully.

Manual testing

  • Ran Jenkins locally using mvn hpi:run
  • Verified validation messages appear correctly in the UI
  • Confirmed valid values save successfully
  • Confirmed existing email sending behavior remains unchanged

UI Before

image

UI After

image

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira (no existing issue; UX improvement)
  • Link to relevant pull requests
  • Ensure you have provided tests that demonstrate the feature works

@wisekiran wisekiran requested a review from a team as a code owner February 26, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant