Skip to content

Expand tests to verify multipart structure and body content#1557

Open
Faheem12005 wants to merge 1 commit intojenkinsci:mainfrom
Faheem12005:fix/multipart-tests
Open

Expand tests to verify multipart structure and body content#1557
Faheem12005 wants to merge 1 commit intojenkinsci:mainfrom
Faheem12005:fix/multipart-tests

Conversation

@Faheem12005
Copy link
Copy Markdown

Resolves the TODO in testShouldSendEmailUsingUtf8ByDefault

this PR tightens and broadens multipart validation by enforcing expected MIME structure and body-part semantics across relevant tests.
testShouldSendEmailUsingUtf8ByDefault previously had a silent fallback for if the message wasn't a MimeMessage. I've replaced this with a stricter assertion so potentially broken email implementations don't pass through.
Defined a new helper assertMultipartSubtype to verify the multipart subtypes (eg: mixed, alternative) on both the outer message header and the parsed MimeMultipart object, and applied it to existing tests to increase multipart coverage.

Testing done

Modifications to tests only

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main 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
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@Faheem12005 Faheem12005 requested a review from a team as a code owner April 4, 2026 15:17
@ArpanC6
Copy link
Copy Markdown

ArpanC6 commented Apr 6, 2026

@Faheem12005 The findFirstPartByContentType() helper looks good overall but one thing worth considering: the recursive call has no depth limit. For deeply or maliciously nested MimeMultipart structures this could theoretically lead to a stack overflow. Since this is test code it's low risk but adding a simple depth guard (e.g. maxDepth parameter) would make it more robust.

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.

2 participants