Skip to content

Conversation

@sarroutbi
Copy link
Contributor

@sarroutbi sarroutbi commented Jul 22, 2025

This series of commits significantly refactors the evidence collection logic in the push model agent and substantially increases the test coverage for the struct_filler and state_machine modules.

The primary motivation is to improve code quality by removing dead code paths and ensuring the core state transition logic is robust and well-tested.

  • Key Changes:

    • struct_filler.rs Refactoring (Commit 1/3):

      • Removed Dead Code: The unused FillerFromFile and FillerFromCode structs, along with their associated helper functions, have been completely removed. This significantly simplifies the module's public API and internal logic.

      • Simplified Logic: The get_filler_request function has been streamlined. It now has a single decision point: it returns a FillerFromHardware if a TPM ContextInfo is provided, otherwise it falls back to the TestingFiller. This makes the code's intent clearer and easier to maintain.

    • Increased Coverage for struct_filler.rs (Commit 2/3):

      Following the refactoring, a comprehensive suite of unit tests has been added to cover the remaining logic in struct_filler.rs. The new tests verify:

      • Correct dispatcher behavior in get_filler_request for both Some(Context) and None cases.

      • The default behavior of the TestingFiller.

      • Error handling paths in FillerFromHardware, such as when parsing a malformed verifier response or when underlying hardware/TPM access fails.

    • Increased Coverage for state_machine.rs (Commit 3/3):

      • A new suite of integration-style tests has been added for the StateMachine.

      • These tests use a mock registration module (injected via conditional compilation) and a mock AttestationClient to test the state machine's flow control in isolation from network and hardware dependencies.

      • The tests now cover the "happy path" of the run() method from Unregistered to Complete, as well as failure transitions if the negotiation or attestation phases fail.

Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
@sarroutbi sarroutbi force-pushed the 202507221130-code-grooming branch 3 times, most recently from 51e5dac to 9efdb26 Compare July 22, 2025 11:33
@ansasaki ansasaki mentioned this pull request Jul 22, 2025
30 tasks
@codecov
Copy link

codecov bot commented Jul 22, 2025

Codecov Report

Attention: Patch coverage is 34.14634% with 27 lines in your changes missing coverage. Please review.

Project coverage is 58.92%. Comparing base (b2e7fba) to head (dc05d3d).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
keylime-push-model-agent/src/struct_filler.rs 19.35% 25 Missing ⚠️
keylime-push-model-agent/src/attestation.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 58.92% <34.14%> (+1.04%) ⬆️
upstream-unit-tests 58.92% <34.14%> (+1.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
keylime-push-model-agent/src/state_machine.rs 45.66% <100.00%> (+35.49%) ⬆️
keylime-push-model-agent/src/attestation.rs 61.06% <0.00%> (+16.03%) ⬆️
keylime-push-model-agent/src/struct_filler.rs 23.61% <19.35%> (+0.24%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
@sarroutbi sarroutbi force-pushed the 202507221130-code-grooming branch from e1854a0 to 90c4e29 Compare July 22, 2025 13:42
@sarroutbi sarroutbi changed the title Groom code (remove dead code) Groom code (remove dead code, increase coverage) Jul 22, 2025
@sarroutbi sarroutbi marked this pull request as ready for review July 22, 2025 13:52
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
@ansasaki ansasaki merged commit 390ea3d into keylime:master Jul 23, 2025
15 of 16 checks passed
@sarroutbi sarroutbi deleted the 202507221130-code-grooming branch July 23, 2025 08:29
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.

3 participants