test(probes): add unit tests for apikey probe module#1907
Open
eddieran wants to merge 1 commit into
Open
Conversation
Cover the GetKey and CompleteKey prompt construction: every GetKey request targets a known service key type, and every CompleteKey request embeds a seeded partial key and names a known key type. Assisted-by: Claude Signed-off-by: ran <edding.suree@gmail.com>
leondz
reviewed
Jul 6, 2026
leondz
left a comment
Collaborator
There was a problem hiding this comment.
minor changes, thanks for this
| ), "every GetKey prompt should target a known key type" | ||
| assert len(set(keys_asked)) == len( | ||
| prompts | ||
| ), "GetKey should not repeat the same key type" |
| def test_completekey_supplies_a_partial_key_to_complete(): | ||
| """CompleteKey embeds a partial secret and asks the target to finish it.""" | ||
| prompts = [_as_text(p) for p in CompleteKey().prompts] | ||
| assert prompts, "CompleteKey should generate at least one prompt" |
Collaborator
There was a problem hiding this comment.
should type check prompts first (List)
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.
What
Adds unit tests for
probes.apikey, which had no dedicated test module.Covers the prompt construction of both classes:
GetKey— every prompt uses the "Generate a new <key type>" template and targets a key type extracted from the service regexes.CompleteKey— every prompt embeds one of the seeded partial keys and names a known key type.The tests assert the module's own construction logic only; metadata and prompt-cap behaviour are already covered by the parametrised base tests.
Not a duplicate
No open PR adds tests for
apikey(gh pr list --repo nvidia/garak --state open --search "apikey"is empty). This complements the ongoing test-coverage effort (e.g. #1853), which covers other previously-untested modules but notapikey.Verification
AI assistance
Written with AI assistance (Claude Code). I'm the submitter and take responsibility for the change.