Skip to content

fix: Add tests for screensaver and power settings with localization#482

Merged
dz0ny merged 2 commits intomainfrom
fix/win-sleep-check
Jan 28, 2026
Merged

fix: Add tests for screensaver and power settings with localization#482
dz0ny merged 2 commits intomainfrom
fix/win-sleep-check

Conversation

@dz0ny
Copy link
Member

@dz0ny dz0ny commented Jan 28, 2026

  • Add more detailed reasons for check failures on Windows.
  • Remove hibernation from consideration in ScreensaverTimeout check.

…upport

- Add more detailed reasons for check failures on Windows.
- Remove hibernation from consideration in ScreensaverTimeout check.
Copilot AI review requested due to automatic review settings January 28, 2026 09:01
@github-actions
Copy link

github-actions bot commented Jan 28, 2026

🚀 Dev Builds Available

Development builds for this PR are available in the workflow artifacts.

Available builds:

  • Windows (agent, installer, tray)
  • Linux (agent)
  • macOS (agent)

Download the build artifact to test the latest changes.

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ParetoSecurity/agent/checks/windows 78.09% (+1.30%) 👍
Total 50.23%

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ParetoSecurity/agent/checks/windows/screensaver_password.go 87.21% (-3.01%) 172 (+80) 150 (+67) 22 (+13) 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ParetoSecurity/agent/checks/windows/screensaver_password_test.go

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR significantly improves Windows screensaver and power settings checks by adding comprehensive test coverage, supporting localized Windows output, and providing more detailed failure messages.

Changes:

  • Added extensive test coverage for screensaver timeout and password checks with 18 new test cases covering desktop, laptop, localized Windows, and modern Windows scenarios
  • Refactored screensaver timeout check to use powercfg for display timeouts instead of relying solely on screensaver settings, with detailed failure messages for AC/DC power states
  • Enhanced password check to support modern Windows where CONSOLELOCK is not exposed, with fallback to lock screen detection

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
checks/windows/screensaver_password_test.go Added 18 comprehensive test cases with sample powercfg output including Slovenian localization, tests for display timeout, screensaver timeout, and password protection scenarios for both desktop and laptop configurations
checks/windows/screensaver_password.go Refactored to check display power settings via powercfg, added battery detection using Get-CimInstance, implemented regex-based parsing for localized output, added modern Windows fallback for CONSOLELOCK, and provided detailed status messages for different failure scenarios

…etween integer types

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@dz0ny dz0ny requested a review from zupo January 28, 2026 09:08
Copy link
Member

@zupo zupo left a comment

Choose a reason for hiding this comment

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

👍

@dz0ny dz0ny merged commit f040593 into main Jan 28, 2026
48 of 49 checks passed
@dz0ny dz0ny deleted the fix/win-sleep-check branch January 28, 2026 11:01
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