Skip to content

Consider adding Hypothesis for property-based testing of authorization logic #1587

@adamtheturtle

Description

@adamtheturtle

Summary

The authorization_header() and related functions build HMAC-SHA1 signatures from (method, content, content_type, date, request_path). This is ideal for property-based testing.

Benefits

  • Determinism: Same inputs should always produce the same output — trivial to verify with @given(st.text(), st.binary(), ...)
  • Robustness: Edge cases — empty content, Unicode, very long strings, special characters in method/path — would be systematically explored
  • No crashes: authorization_header should never raise on valid-type inputs

Suggested properties

  1. authorization_header(access_key=k, secret_key=s, method=m, content=c, ...) is deterministic for fixed inputs
  2. Empty content (None, b"", "") is handled correctly
  3. Unicode in content is encoded without crashing
  4. Arbitrary request_path strings (including special chars) produce valid output

Note

.hypothesis/ is already in .gitignore, suggesting Hypothesis may have been considered. No implementation exists yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions