Promote develop to main - #108
Merged
Merged
Conversation
Implements the previously-missing "History" area of the Pi-hole v6 API (GET /history, /history/database, /history/clients, /history/database/clients) as new PiHoleShell/Public/History functions: - Get-PiHoleHistory - live "total queries over time" graph data (~last 24h) - Get-PiHoleHistoryDatabase - same, from the long-term on-disk database, with From/Until (defaulting to the last 8 hours, matching the existing Stats(database) functions' convention) - Get-PiHoleHistoryClient - live per-client activity graph data, one object per timestamp with a nested Clients breakdown (IP/Name/Count) - Get-PiHoleHistoryDatabaseClient - same, from the long-term database Get-PiHoleHistoryDatabaseClient has one notable wrinkle, verified against a real server: the API keys its per-timestamp client breakdown by an internal numeric client ID, not by IP, while the separate client summary it also returns is keyed by IP - there's no shared key to join the two on. So this function returns ClientId as-is rather than pretending to resolve a name/IP it doesn't actually have (documented in its .DESCRIPTION). Verified against a real Pi-hole v6 server, all 4 functions, both formatted and RawOutput, plus bad-password error handling. Added dedicated integration test files per function (14 tests total). README regenerated. Co-Authored-By: Claude Sonnet 5 <[email protected]>
The "errors when given a bad password" tests printed the entire captured -ErrorVariable array via Write-Host "Error: [\$errOut]". For functions that make several internal calls before their own API call (e.g. Add-PiHoleList calls Get-PiHoleList and Get-PiHoleGroup first, both of which also authenticate), a single bad password produces one error entry per nested auth failure - each one a multi-line HttpResponseException dump - plus the final, actually-relevant error repeated several times as it re-wraps through each layer's own catch block. All of that got dumped to the console. None of this affected correctness - the assertion only checks that $errOut is non-empty - but the wall of text made the test output hard to read for no benefit. Now prints the entry count and just the last (most relevant) error instead. Co-Authored-By: Claude Sonnet 5 <[email protected]>
feat: add History feature (4 new functions)
… tests
New-PiHoleGroup, Update-PiHoleGroup, and Remove-PiHoleGroup all had the same
stray break in their catch blocks (silently aborts the entire calling
script on error, even with -ErrorAction SilentlyContinue) and were missing
proper comment-based help.
Update-PiHoleGroup had two more serious bugs, found while writing tests:
- The PUT /groups/{name} endpoint replaces the whole group, per its own API
docs ("Ensure to send all the required parameters... to ensure these
properties are retained"). The function only sent whichever of
Comment/Enabled the caller passed, so updating just one would silently
wipe the other back to its default (Comment to $null, Enabled to $false).
Now reads the group's current values first and only overrides the
field(s) actually passed.
- [bool]$Enabled can never be $null in PowerShell, so the existing
"$Enabled -eq $null" checks (both the "you must specify something"
validation and the "keep current value" fallback) could never be true -
changed to [Nullable[bool]] and switched all "was this passed" checks to
$PSBoundParameters.ContainsKey(), which is the only case-proof way to
detect an omitted parameter (also caught the same problem with $Comment:
an unbound [string] parameter binds to "" not $null, regardless of
whether you write "= $null" as its default).
Also switched New-PiHoleGroup and Update-PiHoleGroup's formatted output to
reflect the real API response (name/comment/enabled/id/dates) instead of
echoing back the input parameters, matching the rest of the module.
Remove-PiHoleGroup's WIP flag is dropped now that it's verified working.
Verified against a real Pi-hole v6 server using a "PesterGroup" test group:
create, duplicate-create warning, partial updates (confirming the other
field is preserved), update validation/not-found errors, delete, and
bad-password errors for all three functions. Added dedicated integration
test files (14 tests). README regenerated.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ostics test: trim noisy bad-password error diagnostics
fix: make GroupManagement functions production ready, add integration tests
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.
Summary
Promotes the following merged PRs from
developtomain:Get-PiHoleHistory,Get-PiHoleHistoryDatabase,Get-PiHoleHistoryClient,Get-PiHoleHistoryDatabaseClientNew-PiHoleGroup,Update-PiHoleGroup,Remove-PiHoleGroup) plus new integration testsTest plan
develop🤖 Generated with Claude Code