Skip to content

test(tui): cover saved config privacy and corrupt fallback - #430

Merged
TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:test/413-saved-config-safety
Nov 17, 2026
Merged

TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
laozhej:test/413-saved-config-safety

Conversation

@laozhej

@laozhej laozhej commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Description

Add regression coverage for the saved TUI form's privacy and corrupt-file fallback. On Unix, saving with umask 000 must create a 0600 file, including when replacing an existing 0666 file. The umask is restored after the non-parallel test.

Truncated JSON and a valid JSON object with an invalid field type must return an empty config with ok=false. New() must still start on the form with every field and toggle at its default. The second case also guards against retaining a partially decoded domain.

Related Issue

Fixes #413.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvements
  • Test updates

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • I have added/updated appropriate comments to the code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable; no user-facing behavior change)

Ethical Considerations

  • This change maintains or improves the security controls in the tool
  • This change follows the educational/legitimate security testing focus of the project
  • I have considered potential misuse cases and taken appropriate steps to prevent them

Additional Information

Validated on macOS arm64 with Go 1.26.11 and golangci-lint 2.15.0:

  • go test ./internal/tui/ -run Config -count=1 passes.
  • Mutation checks through temporary Go overlays prove the new tests fail when the temporary file is created as 0666 or a partially decoded config is returned on an unmarshal error. Neither mutation is included in this PR.
  • go test -race -shuffle=on ./... passes the full suite.
  • make lint reports 0 issues; make build, gofmt, and git diff --check pass. The installed Command Line Tools make was used because the selected Xcode make launcher requires license acceptance.

Tests use temporary configuration directories and local fixtures only. Prepared with OpenAI Codex assistance.

@TMHSDigital
TMHSDigital merged commit fee3073 into TMHSDigital:main Nov 17, 2026
17 checks passed
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.

TUI saved form: 0600 mode and corrupt-file fallback have no test

2 participants