Skip to content

test: improve mutation coverage for certificate validation edge cases - #8065

Merged
vitormattos merged 1 commit into
LibreSign:mainfrom
UmairRathore:test/8053-validate-service
Aug 26, 2026
Merged

test: improve mutation coverage for certificate validation edge cases#8065
vitormattos merged 1 commit into
LibreSign:mainfrom
UmairRathore:test/8053-validate-service

Conversation

@UmairRathore

@UmairRathore UmairRathore commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Related to #8053

📝 Summary

Improves mutation-test coverage for ValidateService by adding focused regression cases around certificate field validation boundaries.

The added tests cover:

  • whitespace-only values for required string fields
  • whitespace-only entries in optional array fields
  • the exact OU maximum item boundary of 10
  • invalid non-string values inside OU

No production code is changed.

Mutation testing results

Metric Before After
PHPUnit tests 27 31
PHPUnit assertions 41 47
Generated mutants 78 80
Killed mutants 66 72
Escaped mutants 12 8
Mutation Code Coverage 100% 100%
Covered Code MSI 84% 90%

The generated-mutant count changed between runs as the additional tests exercised more behavior, so the most relevant comparison is the reduction from 12 to 8 escaped mutants and the Covered Code MSI improvement from 84% to 90%.

The remaining escaped mutants correspond to behavior that is currently non-observable with the existing certificate rules, primarily because OU is optional (required = false) and has minItems = 0. I did not add artificial test cases or change mutation configuration solely to increase the score.

🧪 How to test

Run the focused PHPUnit tests:

composer test:unit -- --filter ValidateServiceTest

Expected result:

OK (31 tests, 47 assertions)

Run Infection against the corresponding source file:

composer mutation:test -- \
  lib/Service/Certificate/ValidateService.php \
  --test-framework-options="--filter ValidateServiceTest" \
  --show-mutations \
  --no-progress \
  --no-interaction

Expected mutation-testing summary:

Mutation Code Coverage: 100%
Covered Code MSI: 90%

The focused run generates 80 mutants, with 72 killed and 8 escaped.

⚙️ API / Back-end changes

  • Added certificate validation boundary and invalid-input test coverage
  • Unit tests added
  • Capabilities updated (not applicable)
  • Documentation updated (not applicable)
  • API documentation updated (not applicable)

✅ Checklist

  • I have read and followed the contribution guide.
  • Focused PHPUnit tests pass.
  • Focused Infection run completed successfully.
  • No production behavior was changed.
  • No mutation exclusions, disabled mutators, or threshold changes were added.
  • Commit includes DCO sign-off.

🤖 AI (if applicable)

  • The content of this PR was partially or fully generated using AI

Signed-off-by: Umair Rathore <umairrathore05@gmail.com>

@vitormattos vitormattos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work! Thanks!

@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in Roadmap Aug 26, 2026
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable34

@vitormattos

Copy link
Copy Markdown
Member

/backport to stable33

@vitormattos
vitormattos merged commit 1169140 into LibreSign:main Aug 26, 2026
72 checks passed
@github-project-automation github-project-automation Bot moved this from 1. to do to 4. to release in Roadmap Aug 26, 2026
@LibreSign LibreSign deleted a comment from backportbot-libresign Bot Aug 26, 2026
@vitormattos vitormattos added this to the Next Major (35) milestone Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

2 participants