Skip to content

test: add edge-case tests for gpgkeystate and passwordconfig#1495

Merged
annejan merged 1 commit into
mainfrom
test/gpgkeystate-passwordconfig-tests
May 16, 2026
Merged

test: add edge-case tests for gpgkeystate and passwordconfig#1495
annejan merged 1 commit into
mainfrom
test/gpgkeystate-passwordconfig-tests

Conversation

@nogeenharrie
Copy link
Copy Markdown
Contributor

@nogeenharrie nogeenharrie commented May 16, 2026

Summary

gpgkeystate (17 → 23 tests):

  • Multiple uid records: only the first sets the name (guards the isEmpty() check)
  • pub record never sets have_secret, even when secret=true is passed
  • sec record sets have_secret only when secret=true; false otherwise
  • Created/expiry timestamps parsed from epoch seconds and round-trip correctly
  • fpr record with empty key_id is a no-op (guards the !isEmpty() check)

passwordconfig (6 → 11 tests):

  • CHARSETS_COUNT equals 4 (enum sentinel value)
  • ALPHANUMERIC contains only chars satisfying isLetterOrNumber()
  • ALPHABETICAL contains only chars satisfying isLetter()
  • CUSTOM defaults to the same content as ALLCHARS

Test plan

  • make check passes locally: gpgkeystate 22/22, passwordconfig 11/11, 0 failures
  • clang-format --style=file applied

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Tests
    • Expanded test coverage for GPG key state parsing behavior
    • Added validation tests for password configuration settings

Review Change Stack

gpgkeystate (17 → 23 tests):
- multipleUidRecordsOnlyFirstNameUsed: only the first uid record sets name
- pubRecordDoesNotSetHaveSecret: pub never sets have_secret, even with secret=true
- secRecordSetsHaveSecretOnlyWhenSecretTrue: sec sets have_secret iff secret=true
- createdDateParsedFromEpoch: pub created timestamp round-trips through epoch
- expiryDateParsedFromEpoch: pub expiry timestamp round-trips through epoch
- fprWithEmptyKeyIdIsNoop: fpr guard prevents update when key_id is empty

passwordconfig (6 → 11 tests):
- charsetCountIsCorrect: CHARSETS_COUNT == 4
- alphanumericContainsNoSpecialChars: every char passes isLetterOrNumber()
- alphabeticalContainsNoDigits: every char passes isLetter()
- customCharsDefaultMatchAllChars: CUSTOM initially equals ALLCHARS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: c2fcf72e-dca7-48c1-a4f6-574c0c149cf3

📥 Commits

Reviewing files that changed from the base of the PR and between 0643ef4 and 61ed8e1.

📒 Files selected for processing (2)
  • tests/auto/gpgkeystate/tst_gpgkeystate.cpp
  • tests/auto/passwordconfig/tst_passwordconfig.cpp

📝 Walkthrough

Walkthrough

This PR extends two independent test suites with new Qt test slots. The gpgkeystate tests validate GPG colon-output parsing for multiple UIDs, pub/sec record behavior, epoch date conversions, and FPR record handling. The passwordconfig tests validate charset constants and verify generated charset content meets expected invariants.

Changes

GPG Key State Parsing Tests

Layer / File(s) Summary
GPG key state test slots and implementations
tests/auto/gpgkeystate/tst_gpgkeystate.cpp
Six new test slots (multipleUidRecordsOnlyFirstNameUsed, pubRecordDoesNotSetHaveSecret, secRecordSetsHaveSecretOnlyWhenSecretTrue, createdDateParsedFromEpoch, expiryDateParsedFromEpoch, fprWithEmptyKeyIdIsNoop) with corresponding test implementations validate parseGpgColonOutput result fields for name selection, secret-flag handling, date parsing, and handleFprRecord behavior when key-id is empty.

Password Configuration Tests

Layer / File(s) Summary
Password configuration test slots and implementations
tests/auto/passwordconfig/tst_passwordconfig.cpp
Four new test slots (charsetCountIsCorrect, alphanumericContainsNoSpecialChars, alphabeticalContainsNoDigits, customCharsDefaultMatchAllChars) validate that CHARSETS_COUNT equals 4 and that ALPHANUMERIC, ALPHABETICAL, and CUSTOM character sets contain only their intended character types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • IJHack/QtPass#979: Extends tests/auto/gpgkeystate/tst_gpgkeystate.cpp with additional gpgkeystate parsing coverage, particularly around handlePubSecRecord and handleFprRecord edge cases.
  • IJHack/QtPass#925: Modifies the same test file's gpgkeystate assertions (e.g., parseMultiKeyPublic, parseKeyRollover), providing related coverage.
  • IJHack/QtPass#921: Updates have_secret assertions in tst_gpgkeystate.cpp::parseMultiKeyPublic(), directly related to the pub/sec record secret-flag test coverage added here.

Suggested labels

size:M

Poem

🐰 Six tests for keys that parse and sort,
Four tests for charsets, quite the fort!
UIDs and secrets, dates and FPRs too,
Our coverage grows—QtPass shines bright and true! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding edge-case tests for two modules (gpgkeystate and passwordconfig).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/gpgkeystate-passwordconfig-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 53.977% (+0.02%) from 53.962% — test/gpgkeystate-passwordconfig-tests into main

@annejan annejan merged commit 2bc3bd0 into main May 16, 2026
23 of 25 checks passed
@annejan annejan deleted the test/gpgkeystate-passwordconfig-tests branch May 16, 2026 03:17
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