test: kill escaped mutants in certificate FileService - #8079
Merged
vitormattos merged 1 commit intoAug 27, 2026
Conversation
Infection reported 8 escaped mutants in lib/Service/Certificate/FileService.php (Covered Code MSI 57.89%): the path concatenation in loadCertificateFileByGeneration() and the file_exists/is_readable guards in readCertificateFile() were never exercised with an existing certificate file. Add scenarios reading real ca.pem/ca-key.pem files from the virtual filesystem and an existing-but-unreadable file case. Covered Code MSI is now 100% for this scope (20/20 mutants killed). Ref LibreSign#8053 Assisted-by: Claude Code:claude-fable-5 Signed-off-by: André Maia <andrefnkmm@gmail.com>
vitormattos
approved these changes
Aug 27, 2026
Member
|
/backport to stable35 |
Member
|
/backport to stable34 |
Member
|
/backport to stable33 |
Member
|
/backport to stable32 |
|
The backport to # Switch to the target branch and update it
git checkout stable32
git pull origin stable32
# Create the new backport branch
git checkout -b backport/8079/stable32
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick c015a47a
# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/8079/stable32Error: Failed to push branch backport/8079/stable32: remote: Invalid username or token. Password authentication is not supported for Git operations. Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports. |
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref: #8053
📝 Summary
One focused source/test pair from #8053:
lib/Service/Certificate/FileService.phptests/php/Unit/Service/Certificate/FileServiceTest.phpInfection reported 8 escaped mutants for this file (Covered Code MSI 57.89%): the path concatenation in
loadCertificateFileByGeneration()(5 Concat/ConcatOperandRemoval mutants) and the guards inreadCertificateFile()(3 LogicalNot/LogicalOr mutants). All existing scenarios asserted only the empty-string fallback and never read an existing certificate file, so mutants that broke the path building or the guards kept every test green.This PR only adds tests — no production code changes:
testReturnsContentOfExistingCertificateFile(data provider): creates realca.pem/ca-key.pemfiles in the vfsStream virtual filesystem, with different contents, and asserts each public method returns the content of its own file. Kills the 5 path-concatenation mutants and 2 of the guard mutants.testReturnsEmptyStringWhenCertificateFileIsNotReadable: existing file withchmod 0o000in the virtual filesystem; asserts the guard rejects it silently (empty string, no debug log). Kills the remaining||→&&guard mutant.After the change, Infection reports 20/20 mutants killed — Covered Code MSI 100% for this scope, with no errors and no timeouts.
Note on the
||→&&guard mutant: original and mutated code both return''for an existing-but-unreadable file. What kills the mutant is that the mutated code reachesfile_get_contents()and triggers a PHP warning, which fails the run because the project setsfailOnWarning="true"intests/php/phpunit.xml. The observable behavior protected here is "an unreadable file is rejected by the guard without attempting to read it".🧪 How to test
composer test:unit -- --filter FileServiceTest XDEBUG_MODE=coverage vendor/bin/infection --configuration=infection.json5 \ --test-framework-options="--testsuite=unit" --show-mutations \ lib/Service/Certificate/FileService.phpExpected: 12 tests green; 20 mutants generated, 20 killed, Covered Code MSI 100%.
⚙️ API / Back‑end changes
Test-only change; no production code, capabilities, or API documentation affected.
✅ Checklist
php-cs-fixerpass for the changed file.🤖 AI (if applicable)