Skip to content

test(ingestor): TestStatsFileHasNoCredentials_118 flakes when a stats number contains '1234' #250

Description

@dborup

Problem

TestStatsFileHasNoCredentials_118 in cmd/ingestor/mqtt_status_credentials_118_test.go fails intermittently:

mqtt_status_credentials_118_test.go:222: stats file leaks "1234": {"sampledAt":"...", ...}

secretParts118 includes very short numeric "secrets" ("1234", "2024") and "abc". The test then asserts that none of them occurs anywhere in the whole stats-file JSON. That JSON contains timestamps, Unix times, counters and byte sizes, so any number that happens to contain 1234 fails the test, even though no credential leaked. It was seen on PR #246, a server-only change.

Proposed fix

  • Use secret test values that cannot occur by chance in numbers or timestamps, e.g. zq1234zq and pw2024pw, in the broker URLs and in secretParts118. Keep the coverage: masked user, password, query and fragment parts.
  • Optionally, assert only on the string fields that can carry broker text (error texts, broker labels) instead of the whole JSON blob.

Acceptance

  • The test still fails if masking is removed (mutant: errForLog returns the raw error).
  • It no longer depends on numeric content. Prove it with a run that injects a counter or timestamp containing 1234, or with -count=200.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions