schemathesis: [BUG] Generating invalid HTTP headers

Describe the bug Schemathesis generates headers like:

x-api-key: \x80

The \x80 character is not a part of ISO-8859-1 (AKA Latin-1). This is an issue because according to the HTTP 1.1 standard, all HTTP headers are encoded with ISO-8859-1. This means that my tests will always fail because of something I can’t actually control.

To Reproduce

  1. In your OpenAPI Schema, add a security schema:
      securitySchemes:
        ApiKey:
          type: apiKey
          in: header
          name: x-custom-api-key-header
    security:
      - ApiKey: []
    
  2. Run Schemathesis

Expected behavior

I expect Schemathesis to not generate things that are unsupported due to the HTTP spec. By definition, these things will not have stable behaviour, so it’ll be impossible to test with Schemathesis.

Environment (please complete the following information):

  • OS: Windows 10
  • Python version: 3.9.2
  • Schemathesis version: 3.6.3
  • Spec version: Open API 3.0.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (12 by maintainers)

Commits related to this issue

Most upvoted comments

FYI, the fix for the recent issue is released in 3.11

@hoog1511

Thank you, it confirms, that the root cause is this commit. It should be relatively easy to fix, I’ll work on this today/tomorrow

Cool! Thank you for the detailed report! 😃

I will take a look today